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". API Version: ≥ 1.8 Method: POST Resource: /push/event Description: The method sends the event to Traffic Monitor via HTTP protocol. Example: | Блок кода |
|---|
| title | A query for getting 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": "goodledrive.com/user/folder/"
}
]
}
],
"evt_destination": {
"identity_id": 4,
"identity_type": 3,
"identity_contacts": [],
"identity_attributes": [
{
"name": "name",
"value": "googledrive.com"
}
]
}
}' \
-F 'files[]=' |
| Блок кода |
|---|
| title | A query for getting 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": "capture_tsauth",
"value": "2023-10-26T20:07:51+03:00"
userlogin@domain"},
{
{"name": "email", "namevalue": "capture_server_ip",test@example.com"}
"value": "127.0.0.1"]
},
{
"nameidentity_id": "capture_server_fqdn"4,
"valueidentity_type": "localhost"1,
}
],
"evtidentity_senderscontacts": [
{
{"name": "dnshostname", "identity_idvalue": 1,"computername.domain"}
"identity_type": 0 ],
"identity_contactsattributes": [
{
"name": "authworkstation_type",
"value": "userws_type_name@iwcomputer"}
]
}
],
"evt_receivers": ]
[
{
} "identity_id": 2,
{ "identity_type": 2,
"identity_idcontacts": 2[],
"identity_typeattributes": 1,[
"identity_contacts{"name": "device_name", "value": ["PrinterName"},
{"name": "print_port_name", "value": "Some print port name"},
"name{"name": "print_server", "value": "dnshostnamePrinter Xerox"},
{"name": "print_location", "value": "localhost.computer.domain"
Kitchen"}
]
}
],
"evt_receiversdata": [
{
"identitydata_id": 31,
"data_attributes": [
{"name": "identity_typeprint_copies", "value": "3"},
{"identity_contactsname": []
"print_job_name", "value": "Print job name"}
],
"evt_data": [ ]
{}
"data_id": 1,]
}' \
-F 'files[]=' |
| Блок кода |
|---|
| title | Response |
|---|
| collapse | true |
|---|
| {
"data_attributes": [{
"document_id": "string"
{
"name": "filename",
"value": "res.txt"
},
{
"name": "destination_file_path",
"value": "goodledrive.com/user/folder/"}
} |
| Блок кода |
|---|
| title | A query for getting 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": "evt_destination": {
"identity_id": 4capture_ts", "value": "2024-03-25T23:41:21+03:00" },
{ "identity_typename": 3,
"identity_contacts": [],
"identity_attributes": ["capture_server_ip", "value": "127.0.0.1" },
{
"name": "namecapture_server_fqdn",
"value": "googledrive.com"
}
captureservername.domain" }
],
}
}' \"evt_senders": [
-F 'files[]=' | | Блок кода |
|---|
| title | A query for getting events with the Print type |
|---|
| curl -X 'POST' \{
'https://server.company.ru/xapi/push/event' \
'X-API-Auth-Token: brse99dugp1cdbr69axz'
'X-API-CompanyId: iw'"identity_id": 3,
'X-API-Version: 1.8'
-F 'event=
{
"evtidentity_classtype": 20,
"evt_service "identity_contacts": "print"[],
"evt_attributes "identity_contacts_with_meta": [
{"name": "capture_ts", "value": "2024-03-06T08:45:00+03:00"},
{"name": "capture_server_ip", "value": "127.0.0.1"},
"contact": { "name": "capture_server_fqdnauth", "value": "captureservername.domainuserlogin@domain" },
{"name": "print_copies", "value": "3"}
],
"evt_senders": [ }
]
},
{
"identity_id": 34,
"identity_type": 01,
"identity_contacts": [],
{"name": "auth", "valueidentity_attributes": "userlogin@domain"},[
{ "name": "emailworkstation_type", "value": "test@example.com"ws_type_computer" }
]
}],
{
"identity_idcontacts_with_meta": 4,[
"identity_type": 1, {
"identity_contacts": [
"contact": { "name": "dnshostname", "value": "computername.domain" }
],
"identity_attributes": [ }
{"name": "workstation_type", "value": "ws_type_computer"} ]
]
}
],
"evt_receivers": [
{
"identity_id": 2,
{
"identity_type": 2,
"identity_contactsid": []2,
"identity_attributestype": [3,
{"name": "deviceidentity_namecontacts", "value": "PrinterName"}[],
{"name "identity_attributes": "print_port_name", "value": "Some print port name"},
[
{ "name": "printres_destination_serverhost", "value": "testhost.com"Printer Xerox"},
{ "name": "printres_destination_locationurl", "value": "Kitchen"\/file\/test.php" }
]
}
],
"evt_data": [
{
}
],
"evtdata_dataid": [1
{
}
"data_id": 1,
"data_attributes": [
{"name": "print_copies", "value": "3"},
{"name": "print_job_name", "value": "Print job name"}
]
}
]
}' \
-F 'files[]=' | | Блок кода |
|---|
| {
"data": {
"document_id": "string"
}
}]
} |
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. | Блок кода |
|---|
| 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------ |
| Блок кода |
|---|
| 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------ |
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
|