| Sv translation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Для отправки события в Traffic Monitor по HTTP-протоколу реализован метод REST API Версия API: ≥ 1.8 Метод: Ресурс: Описание: Метод отправляет событие в Traffic Monitor по протоколу HTTP. ПримерПримеры запросов:
To upload events to Traffic Monitor via HTTP protocol, use API Version: ≥ 1.8 Method: Resource: Description: The method sends an event to Traffic Monitor via HTTP protocol. Example: Блок кода | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||
curl -X 'POST' \
'https://server.company.ru/xapi/push/event' \
'X-API-Auth-Token: brse99dugp1cdbr69axz'
'X-API-CompanyId: iw'
'X-API-Version: 1.8'
-F 'event=
{
"evt_class": 2,
"evt_service": "print",
"evt_attributes": [
{"name": "capture_ts", "value": "2024-03-06T08:45:00+03:00"},
{"name": "capture_server_ip", "value": "127.0.0.1"},
{"name": "capture_server_fqdn", "value": "captureservername.domain"},
{"name": "print_copies", "value": "3"}
],
"evt_senders": [
{
"identity_id": 3,
"identity_type": 0,
"identity_contacts": [
{"name": "auth", "value": "userlogin@domain"},
{"name": "email", "value": "test@example.com"}
]
},
{
"identity_id": 4,
"identity_type": 1,
"identity_contacts": [
{"name": "dnshostname", "value": "computername.domain"}
],
"identity_attributes": [
{"name": "workstation_type", "value": "ws_type_computer"}
]
}
],
"evt_receivers": [
{
"identity_id": 2,
"identity_type": 2,
"identity_contacts": [],
"identity_attributes": [
{"name": "device_name", "value": "PrinterName"},
{"name": "print_port_name", "value": "Some print port name"},
{"name": "print_server", "value": "Printer Xerox"},
{"name": "print_location", "value": "Kitchen"}
]
}
],
"evt_data": [
{
"data_id": 1,
"data_attributes": [
{"name": "print_copies", "value": "3"},
{"name": "print_job_name", "value": "Print job name"}
]
}
]
}' \
-F 'files[]=' |
| Блок кода | |||
|---|---|---|---|
|
{
"data": {
"document_id": "string"
}
}Рекомендации по производительности API при отправке событий в TM:
- Для улучшения производительности NGINX:
- В файле
/etc/nginx/nginx.confизмените значение параметраworker_processesна2. - Сохраните изменения и перезагрузите сервис с помощью команды:
systemctl restart nginx
- В файле
- При высокой нагрузке в журнале ошибок NGINX
/var/log/nginx/error.logмогут возникать сообщения вида:
socket() failed (24: Too many open files) while connecting to upstream.
В этом случае требуется увеличить ограничение сервиса на количество открытых файлов, например, до 10000:
- Войдите в режим редактирования службы NGINX с помощью команды:
systemctl edit nginx.service Вставьте следующие строки в поле редактора:
[Service]LimitNOFILE=10000Сохраните изменения (Ctrl+O) и выйдите из режима редактирования (Ctrl+X).
- Перезагрузите сервис с помощью команды:
systemctl restart nginx
- Войдите в режим редактирования службы NGINX с помощью команды:
| language | en |
|---|
Отправка событий с типом веб-сообщение collapse true curl -X 'POST' \ 'https://109.73.44.69/xapi/push/event' \ -H 'accept: application/json' \ -H 'X-API-Auth-Token: 198igrnlnuonix672uq9' \ -H 'X-API-CompanyId: Yandex' \ -H 'X-API-Version: 1.8' \ -H 'Content-Type: multipart/form-data' \ -H 'X-Enable-OpenAPI: 1' \ -F 'event= { "evt_class": 3, "evt_service": "web_common", "evt_attributes": [ { "name": "event_name", "value": "Web Event Name" }, { "name": "capture_ts", "value": "2024-03-25T23:41:21+03:00" }, { "name": "capture_server_ip", "value": "127.0.0.1" }, { "name": "capture_server_fqdn", "value": "captureservername.domain" } ], "evt_senders": [ { "identity_id": 3, "identity_type": 0, "identity_contacts": [], "identity_contacts_with_meta": [ { "contact": { "name": "auth", "value": "userlogin@domain" } } ] }, { "identity_id": 4, "identity_type": 1, "identity_contacts": [], "identity_attributes": [ { "name": "workstation_type", "value": "ws_type_computer" } ], "identity_contacts_with_meta": [ { "contact": { "name": "dnshostname", "value": "computername.domain" } } ] } ], "evt_receivers": [ { "identity_id": 2, "identity_type": 3, "identity_contacts": [], "identity_attributes": [ { "name": "res_destination_host", "value": "testhost.com" }, { "name": "res_destination_url", "value": "\/file\/test.php" } ] } ], "evt_data": [ { "data_id": 1 } ] }Информация title Примечание: В примере выше значение
3поля"evt_class"соответствует константеkWeb. Вместе с ним необходимо передать POST-запрос, например, в формате multipart:Блок кода language text title Пример запроса для отправляемых текстовых событий collapse true POST /file/test.php HTTP/1.1 Content-Type: multipart/form-data; boundary="----1234567890----" Content-Length: 110 Host: testhost.com ------1234567890---- Content-Type: text/plain Content-Disposition: inline Hello World ------1234567890------Блок кода language text title Пример запроса для отправляемых файлов collapse true POST /file/test.php HTTP/1.1 Content-Type: multipart/form-data; boundary="----1234567890----" Content-Length: 156 Host: testhost.com ------1234567890---- Content-Type: text/plain Content-Disposition: attachment; filename="file.txt" Hello World. This is text file. ------1234567890------
| Блок кода | ||||||
|---|---|---|---|---|---|---|
| ||||||
{
"data": {
"document_id": "string"
}
} |
Рекомендации по производительности API при отправке событий в TM:
- Для улучшения производительности NGINX:
- В файле
/etc/nginx/nginx.confизмените значение параметраworker_processesна2. Сохраните изменения и перезагрузите сервис с помощью команды:
Блок кода language text systemctl restart nginx
- В файле
- При высокой нагрузке в журнале ошибок NGINX
/var/log/nginx/error.logмогут возникать сообщения вида:
socket() failed (24: Too many open files) while connecting to upstream.
В этом случае требуется увеличить ограничение сервиса на количество открытых файлов, например, до 10000:
Войдите в режим редактирования службы NGINX с помощью команды:
Блок кода language text systemctl edit nginx.serviceВставьте следующие строки в поле редактора:
Блок кода language text [Service] LimitNOFILE=10000Сохраните изменения (Ctrl+O) и выйдите из режима редактирования (Ctrl+X).
Перезагрузите сервис с помощью команды:
Блок кода language text systemctl restart nginx
| Sv translation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To upload events to Traffic Monitor via HTTP protocol, use API Version: ≥ 1.8 Method: Resource: Description: The method sends the event to Traffic Monitor via HTTP protocol. Query examples:
Блок кода | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
{ "name": "capture_ts", "value": "2024-03-25T23:41:21+03:00" }, { "name": "capture_server_ip", "value": "127.0.0.1" }, { "name": "capture_server_fqdn", "value": "captureservername.domain" } ], "evt_senders": [ { "identity_id": 3, "identity_type": 0, "identity_contacts": [], "identity_contacts_with_meta": [ { "contact": { "name": "auth", "value": " |
userlogin@domain" }
} ] }, { "identity_id":
4, "identity_type":
1, "identity_contacts": [],
"
identity_attributes":
[ { "name": "
workstation_type", "value": "
ws_type_computer" }
],
"identity_contacts_with_
meta":
[
{
"contact": {
"name": "dnshostname", "value": "computername.domain" }
}
]
} ], "evt_receivers": [
{
"identity_
id":
2, "identity_
type":
3,
"
identity_contacts":
[],
"identity_attributes":
[ { "name": "
res_destination_
host", "value": "
testhost.com" }, { "name": "
res_destination_
url", "value": "
\/file\/test.php" } ] } ], "evt_data": [ {
"data_id": 1 } ] }Информация title Note: In the example above, value
3of the"evt_class"field corresponds to thekWebconstant. Along with it, you must send a POST request, for example, in multipart format.Блок кода language text title Example query for text events being sent collapse true POST /file/test.php HTTP/1.1 Content-Type: multipart/form-data; boundary="----1234567890----" Content-Length: 110 Host: testhost.com ------1234567890---- Content-Type: text/plain Content-Disposition: inline Hello World ------1234567890------Блок кода language text title Example query for files being sent collapse true POST /file/test.php HTTP/1.1 Content-Type: multipart/form-data; boundary="----1234567890----" Content-Length: 156 Host: testhost.com ------1234567890---- Content-Type: text/plain Content-Disposition: attachment; filename="file.txt" Hello World. This is text file. ------1234567890------
| Блок кода | ||||||
|---|---|---|---|---|---|---|
| ||||||
{
"data": {
"document_id": "string"
}
} |
Recommendations on API performance when uploading events to TM:
- To improve NGINX performance:
- In
/etc/nginx/nginx.conf, change theworker_processesparameter value to2. Restart the service with the command:
Блок кода language text systemctl restart nginx
- In
- In case of high load, the NGINX log file
/var/log/nginx/error.logmay contain messages which look as follows:
socket() failed (24: Too many open files) while connecting to upstream.
To avoid the error, increase the file-opening limit of the service, for example, to 10000:
- Enter the NGINX service editing mode using the command:
Блок кода language text systemctl edit nginx.service
- Paste the following lines into the editor:
Блок кода language text [Service]LimitNOFILE=10000
- Save changes (Ctrl+O) and exit (Ctrl+X).
- Restart the service with the command:
Блок кода language text systemctl restart nginx
- Enter the NGINX service editing mode using the command: