Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.
Комментарий: Published by Scroll Versions from space TMAG and version 7.12
Sv translation
languageru

Для отправки события в Traffic Monitor по HTTP-протоколу реализован метод REST API JsonPush, который преобразует запрос в PushAPI-формат. Подробнее о REST API см. "Функциональное описание программного интерфейса REST API".

Предупреждение
titleВажно!
Убедитесь, что настроен и запущен сервис iw_rest2push. Подробнее см. "InfoWatch Traffic Monitor. Справочник по конфигурационным файлам", статья "rest2push.conf и iw_rest2push.service".

Версия API: ≥ 1.8

Метод: POST

Ресурс: /push/event

Описание: Метод отправляет событие в Traffic Monitor по протоколу HTTP.

Примеры запросов:

  • Блок кода
    languagetext
    titleОтправка событий с типом Облачные хранилища
    collapsetrue
    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": 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[]='
  • Блок кода
    languagetext
    titleОтправка событий с типом Печать
    collapsetrue
    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[]='
  • Блок кода
    languagetext
    titleОтправка событий с типом Веб-сообщение
    collapsetrue
    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:

    • Блок кода
      languagetext
      titleПример запроса для отправляемых текстовых событий
      collapsetrue
      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------
    • Блок кода
      languagetext
      titleПример запроса для отправляемых файлов
      collapsetrue
      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------
Блок кода
languagetext
titleПример успешного ответа
collapsetrue
{
  "data": {
    "document_id": "string"
  }
}

Получение вердикта события, загруженного по протоколу HTTP

Для получения вердикта события используйте DataExport API. Необходимо предоставить массив с ID документа, полученным при загрузке события в Traffic Monitor, и датой: {documentID, date}.

Блок кода
languagetext
titleПример получения вердикта для двух событий:
collapsetrue
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.ru:9106/xapi/event/verdict?documentId=41a43cf1-bec3-44ae-9fd9-c1fe962e7886,7b6ad1fe-413c-486e-9dd1-c8e5a94a198b&date=2024-07-17"

В примере выше server.company.ru – сервер с ролью Перехватчики.

Подробнее см. "Получение вердикта".

Рекомендации по производительности API при отправке событий в TM:

  • Для улучшения производительности NGINX:
    1. В файле /etc/nginx/nginx.conf измените значение параметра worker_processes на 2.
    2. Сохраните изменения и перезагрузите сервис с помощью команды:

      Блок кода
      languagetext
      systemctl restart nginx
  • При высокой нагрузке в журнале ошибок NGINX /var/log/nginx/error.log могут возникать сообщения вида:

socket() failed (24: Too many open files) while connecting to upstream.

В этом случае требуется увеличить ограничение сервиса на количество открытых файлов, например, до 10000:

    1. Войдите в режим редактирования службы NGINX с помощью команды:

      Блок кода
      languagetext
      systemctl edit nginx.service
    2. Вставьте следующие строки в поле редактора:

      Блок кода
      languagetext
      [Service]
      
      LimitNOFILE=10000
    3. Сохраните изменения (Ctrl+O) и выйдите из режима редактирования (Ctrl+X).

    4. Перезагрузите сервис с помощью команды:

      Блок кода
      languagetext
      systemctl restart nginx
Sv translation
languageen

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".

Предупреждение
titleImportant!

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:

  • Блок кода
    languagetext
    titleSend events with the Cloud Storage type
    collapsetrue
    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[]='
  • Блок кода
    languagetext
    titleSend events with the Print type
    collapsetrue
    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[]='
  • Блок кода
    languagetext
    titleSend events with the Web Message type
    collapsetrue
    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
          }
      ]
    }
    Информация
    titleNote:

    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.

    Блок кода
    languagetext
    titleExample query for text events being sent
    collapsetrue
    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------
    Блок кода
    languagetext
    titleExample query for files being sent
    collapsetrue
    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------
Блок кода
languagetext
titleSuccessful response example
collapsetrue
{
  "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}.

Блок кода
languagetext
titleExample of getting verdict for two events
collapsetrue
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:
    1. In /etc/nginx/nginx.conf, change the worker_processes parameter value to 2.
    2. Restart the service with the command:

      Блок кода
      languagetext
      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:

    1. Enter the NGINX service editing mode using the command:

      Блок кода
      languagetext
      systemctl edit nginx.service
    2. Paste the following lines into the editor:

      Блок кода
      languagetext
      [Service]
      
      LimitNOFILE=10000
    3. Save changes (Ctrl+O) and exit (Ctrl+X).
    4. Restart the service with the command:

      Блок кода
      languagetext
      systemctl restart nginx