To upload events to Traffic Monitor via HTTP protocol, use JsonPush REST API method, which transforms a query into PushAPI format. For details on REST API, see "Functional description of REST API programming interface". | Предупреждение |
|---|
| Make sure that iw_rest2push service is configured and running. For details, see "InfoWatch Traffic Monitor. Configuration Files Guide", "rest2push.conf and iw_rest2push.service" article. |
API Version: ≥ 1.8 Method: POST Resource: /push/event Description: The method sends the event to Traffic Monitor via HTTP protocol. Query examples: | Блок кода |
|---|
| language | text |
|---|
| title | Send events with the Cloud Storage type |
|---|
| collapse | true |
|---|
| curl -X 'POST' \
'https://server.company.com/xapi/push/event' \
'X-API-Auth-Token: brse99dugp1cdbr69axz'
'X-API-CompanyId: iw'
'X-API-Version: 1.8'
-F 'event={
"evt_class": 4,
"evt_service": "cloud_storage",
"evt_attributes": [
{
"name": "capture_ts",
"value": "2023-10-26T20:07:51+03:00"
},
{
"name": "capture_server_ip",
"value": "127.0.0.1"
},
{
"name": "capture_server_fqdn",
"value": "localhost"
}
],
"evt_senders": [
{
"identity_id": 1,
"identity_type": 0,
"identity_contacts": [
{
"name": "auth",
"value": "user_name@iw"
}
]
},
{
"identity_id": 2,
"identity_type": 1,
"identity_contacts": [
{
"name": "dnshostname",
"value": "localhost.computer.domain"
}
]
}
],
"evt_receivers": [
{
"identity_id": 3,
"identity_type": 3,
"identity_contacts": []
}
],
"evt_data": [
{
"data_id": 1,
"data_attributes": [
{
"name": "filename",
"value": "res.txt"
},
{
"name": "destination_file_path",
"value": "googledrive.com/user/folder/"
}
]
}
],
"evt_destination": {
"identity_id": 4,
"identity_type": 3,
"identity_contacts": [],
"identity_attributes": [
{
"name": "name",
"value": "googledrive.com"
}
]
}
}' \
-F 'files[]=' |
| Блок кода |
|---|
| language | text |
|---|
| title | Send events with the Print type |
|---|
| collapse | true |
|---|
| 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[]=' |
| Блок кода |
|---|
| language | text |
|---|
| title | Send events with the Web Message type |
|---|
| 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
}
]
} |
| Информация |
|---|
| In the example above, value 3 of the "evt_class" field corresponds to the kWeb constant. 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------ |
|
| Блок кода |
|---|
| language | text |
|---|
| title | Successful response example |
|---|
| collapse | true |
|---|
| {
"data": {
"document_id": "string"
}
} |
Getting verdict for events uploaded via HTTP protocol To get verdict for an event, use DataExport API. Provide an array of document ID, which you received as output after the event had been uploaded to Traffic Monitor, and date: {documentID, date}. | Блок кода |
|---|
| language | text |
|---|
| title | Example of getting verdict for two events |
|---|
| collapse | true |
|---|
| curl -v -k -H "X-API-CompanyId: iw" \
-H "X-API-ProductName: PRODUCT" \
-H "X-API-Auth-Token: akkw713dh9a1awwhrn1" \
-H "X-API-Version: 1.8" \
"https://server.company.com:9106/xapi/event/verdict?documentId=41a43cf1-bec3-44ae-9fd9-c1fe962e7886,7b6ad1fe-413c-486e-9dd1-c8e5a94a198b&date=2024-07-17" |
In the example above, server.company.com is a server with Interceptors role. For details, see "Получение вердикта". Recommendations on API performance when uploading events to TM: - To improve NGINX performance:
- In
/etc/nginx/nginx.conf, change the worker_processes parameter value to 2. Restart the service with the command: | Блок кода |
|---|
| systemctl restart nginx |
- In case of high load, the NGINX log file
/var/log/nginx/error.log may 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: | Блок кода |
|---|
| systemctl edit nginx.service |
Paste the following lines into the editor: | Блок кода |
|---|
| [Service]
LimitNOFILE=10000 |
- Save changes (Ctrl+O) and exit (Ctrl+X).
Restart the service with the command: | Блок кода |
|---|
| systemctl restart nginx |
|