config-api

Перед работой api сервиса рекомендуется ознакомиться с архитектурой продукта и особенностями обращения к api с использованием Bearer Token Authentication.

Сервис config-api располагается за просксирующим компонентом для защиты эндпоинта используется авторизация через jwt токены. С процессом настройки можно ознакомиться в разделе конфигурирования платформы.

Ниже представлена полная документация на api config-api сервис конфигурирования агентов. Он выступает централизованой точкой взаимодействия агентов с платформой, а так же отвечает за конфигурирвоание агентов мониторинга.

GET /configs

Получение всех активных конфигураций

Получение списка последних конфигураций для всех активных агентов

Status Codes:
  • 200 OK – Все активные конфигурации

  • 401 Unauthorized – Недействительный AuthToken в заголовке Authorization

  • 500 Internal Server Error – Внутренняя ошибка сервера

Response JSON Object:
  • [].author (string) – Author is the developer/manager/system that updates config for the last time.

  • [].can_run (boolean) – CanRun indicates whether the agent can run based on license limits. If false, the agent should not run and all exporters will be set to «not_allowed» status.

  • [].config (any) – Config is the config that should be applied on the agent.

  • [].config_not_found (boolean) – ConfigNotFound marks that there is no confing in return.

  • [].config_version (integer) – ConfigVersion is the version of the returned config.

  • [].id (string) – ID is an idetifier of the config.

  • [].should_register (boolean) – ShouldRegister marks that the agent should register.

  • [].update_time (string) – UpdateTime is the time when the returned config was stored in DB in RFC3339 format.

GET /configs/{id}

Получение конфигурации по ID

Получение текущей конфигурации агента по его ID

Parameters:
  • id (string) – ID агента

Query Parameters:
  • version (integer) – Текущая применённая версия конфигурации на агенте

Status Codes:
  • 200 OK – Текущая конфигурация агента

  • 400 Bad Request – Некорректная версия в параметре запроса

  • 401 Unauthorized – Недействительный AuthToken в заголовке Authorization

  • 500 Internal Server Error – Внутренняя ошибка сервера

Response JSON Object:
  • author (string) – Author is the developer/manager/system that updates config for the last time.

  • can_run (boolean) – CanRun indicates whether the agent can run based on license limits. If false, the agent should not run and all exporters will be set to «not_allowed» status.

  • config (any) – Config is the config that should be applied on the agent.

  • config_not_found (boolean) – ConfigNotFound marks that there is no confing in return.

  • config_version (integer) – ConfigVersion is the version of the returned config.

  • id (string) – ID is an idetifier of the config.

  • should_register (boolean) – ShouldRegister marks that the agent should register.

  • update_time (string) – UpdateTime is the time when the returned config was stored in DB in RFC3339 format.

POST /register

Регистрация агента

Проверяет, был ли ранее зарегистрирован указанный ID агента, возвращает Config и сохраняет предоставленную информацию о состоянии

Request JSON Object:
  • agent_name (string) – AgentName is the name of the agent.

  • config (any) – Config is the configuration from a local config file of the agent. agent runs with this config if it is first registration and wantDefault == false. Validation: required is wantDefault == false. (required)

  • force_local (boolean) – ForceLocal is the mark that sended config should be applied in any case.

  • hostname (string) – Hostname is the name of the host where the agent started. Validation: required, valid DNS name. (required)

  • id (string) – ID is an idetifier of the agent. It should be sent in the second registration requests. Validation: required, special AM IDs from go-lib/amid. (required)

  • no_configuration (boolean) – NoConfiguration is the mark that agent doesn’t want to get any configuration from Config API.

  • register_as_upstream (boolean) – RegisterAsUpstream is the mark that agent should be registered as upstream.

  • request_time (string) – RequestTime is the time when the agent sent the registration HTTP request. Validation: required, after startupTime, string in RFC3339 format. (required)

  • startup_time (string) – StartupTime is the time when the agent started. Validation: required, time in RFC3339 format. (required)

  • state (any) – State is the state of agent at the moment of sending register request. Validation: required. (required)

  • upstream_name (string) – UpstreamName is the name of the upstream that agent uses to send data. Validation: required (required)

  • want_default (boolean) – WantDefault is the mark is agent «wants» to get default config from Config API at initial registration.

Status Codes:
  • 200 OK – Агент уже был зарегистрирован, «result»: «old

  • 201 Created – Новый агент зарегистрирован, «result»: «new

  • 400 Bad Request – Некорректный JSON в теле запроса

  • 401 Unauthorized – Недействительный AuthToken в заголовке Authorization

  • 500 Internal Server Error – Внутренняя ошибка сервера

Request Headers:
  • X-Am-Proxy-Id – ID агентов-прокси, через которые прошел агент

Response JSON Object:
  • can_run (boolean) – CanRun indicates whether the agent can run based on license limits. If false, the agent should not run and all exporters will be set to «not_allowed» status.

  • config (any) – Config is the config that should be applied on the agent. New agent - return and apply config only when wantDefault == true. Old agent - return current config from DB that should be applied.

  • config_not_found (boolean) – ConfigNotFound marks that there is no confing in return.

  • config_version (integer) – ConfigVersion is the version of the returned config.

  • result (string) – Result is the result of registration. There is two possible variants: new or old. «new» - first registration request «old» - not first registration request with provided ID.

  • update_time (string) – UpdateTime is the time when the returned config was stored in DB in RFC3339 format.

  • can_run – CanRun indicates whether the agent can run based on license limits. If false, the agent should not run and all exporters will be set to «not_allowed» status.

  • config – Config is the config that should be applied on the agent. New agent - return and apply config only when wantDefault == true. Old agent - return current config from DB that should be applied.

  • config_not_found – ConfigNotFound marks that there is no confing in return.

  • config_version – ConfigVersion is the version of the returned config.

  • result – Result is the result of registration. There is two possible variants: new or old. «new» - first registration request «old» - not first registration request with provided ID.

  • update_time – UpdateTime is the time when the returned config was stored in DB in RFC3339 format.

DELETE /registry

Очистка всего локального кэша

Удаление всех бинарных файлов из локального кэша

Status Codes:
DELETE /registry/{name}/{version}/{os}/{arch}

Удаление бинарного файла из локального кэша

Удаление бинарного файла приложения из локального кэша

Parameters:
  • name (string) – Тип приложения

  • version (string) – Версия приложения

  • os (string) – Тип ОС

  • arch (string) – Архитектура ОС

Status Codes:
  • 200 OK – Бинарный файл приложения удален из кэша

  • 401 Unauthorized – Недействительный AuthToken в заголовке Authorization

  • 404 Not Found – Приложение не найдено в кэше

  • 500 Internal Server Error – Внутренняя ошибка сервера

GET /registry/{name}/{version}/{os}/{arch}

Получение бинарного файла

Получение бинарного файла приложения из реестра или локального кэша (в заголовке X-File-Checksum возвращается контрольная сумма)

Parameters:
  • name (string) – Тип приложения

  • version (string) – Версия приложения

  • os (string) – Тип ОС

  • arch (string) – Архитектура ОС

Status Codes:
  • 200 OK – Запрошенный файл приложения

  • 401 Unauthorized – Недействительный AuthToken в заголовке Authorization

  • 404 Not Found – Приложение не найдено

  • 500 Internal Server Error – Внутренняя ошибка сервера

GET /states

Получение состояний всех активных агентов

Получение списка состояний всех активных агентов

Status Codes:
  • 200 OK – Состояния всех активных агентов

  • 401 Unauthorized – Недействительный AuthToken в заголовке Authorization

  • 500 Internal Server Error – Внутренняя ошибка сервера

Response JSON Object:
  • [].config_update_time (string) – ConfigUpdateTime is the time when a last config was applied on the agent in RFC3339 format.

  • [].config_version (integer) – ConfigVersion is the version of a last applied config on the agent.

  • [].created_time (string) – CreatedTime is the time when the returned agent was stored in DB in RFC3339 format.

  • [].hostname (string) – Hostname is the name of the host where the agent started.

  • [].id (string) – ID is an identifier of the agent.

  • [].request_time (string) – RequestTime is the time when the agent sent the registration HTTP request in RFC3339 format.

  • [].startup_time (string) – StartupTime is the time when the agent started in RFC3339 format.

  • [].state (any) – State is the state of the agent at the moment of sending request.

  • [].status (string) – Status is the status of the agent.

  • [].updated_time (string) – UpdatedTime is the time when the returned agent was last updated in DB in RFC3339 format.

GET /states/{id}

Получение состояния агента по ID

Получение текущего состояния агента по его ID

Parameters:
  • id (string) – ID агента

Status Codes:
  • 200 OK – Текущее состояние агента

  • 401 Unauthorized – Недействительный AuthToken в заголовке Authorization

  • 500 Internal Server Error – Внутренняя ошибка сервера

Response JSON Object:
  • config_update_time (string) – ConfigUpdateTime is the time when a last config was applied on the agent in RFC3339 format.

  • config_version (integer) – ConfigVersion is the version of a last applied config on the agent.

  • created_time (string) – CreatedTime is the time when the returned agent was stored in DB in RFC3339 format.

  • hostname (string) – Hostname is the name of the host where the agent started.

  • id (string) – ID is an identifier of the agent.

  • request_time (string) – RequestTime is the time when the agent sent the registration HTTP request in RFC3339 format.

  • startup_time (string) – StartupTime is the time when the agent started in RFC3339 format.

  • state (any) – State is the state of the agent at the moment of sending request.

  • status (string) – Status is the status of the agent.

  • updated_time (string) – UpdatedTime is the time when the returned agent was last updated in DB in RFC3339 format.

POST /states/{id}

Установка состояния агента по ID

Обновление информации о состоянии агента

Parameters:
  • id (string) – ID агента

Request JSON Object:
  • config_updated_time (string) – ConfigUpdateTime is the time when a last config was applied on the agent. Validation: required, after startupTime, string in RFC3339 format. (required)

  • config_version (integer) – ConfigVersion is the version of a last applied config on the agent. Validation: required, greater that zero. (required)

  • hostname (string) – Hostname is the name of the host where the agent started. Validation: required, valid DNS name. (required)

  • request_time (string) – RequestTime is the time when the agent sent this HTTP request. Validation: required, after startupTime, string in RFC3339 format. (required)

  • startup_time (string) – StartupTime is the time when the agent started. Validation: required, time in RFC3339 format. (required)

  • state (any) – State is the state of the agent at the moment of sending request. Validation: required. (required)

  • status (string) – Status is the current status of the agent. «running» - every request «shutdown» - last request before shutdown Validation: required, «running» or «shutdown». (required)

Status Codes:
  • 200 OK – Обновлено текущее состояние агента

  • 201 Created – Создано новое состояние агента

  • 400 Bad Request – Некорректный JSON в теле запроса

  • 401 Unauthorized – Недействительный AuthToken в заголовке Authorization

  • 404 Not Found – Агент с указанным ID не зарегистрирован

  • 500 Internal Server Error – Внутренняя ошибка сервера