正在加载

Elastic APM Agent 配置 API

Elastic Stack

APM Server 公开了 API 端点,允许 Elastic APM Agent 查询 APM Server 以获取配置更改。 有关此功能的更多信息,请参阅 Kibana 中的 APM Agent 配置

名称 端点
Agent 配置采集 /config/v1/agents
RUM 配置采集 /config/v1/rum/agents

Agent 配置端点接受 HTTP GETHTTP POST 请求。 如果配置了 API 密钥密钥令牌,则必须对该端点的请求进行身份验证。

service.name 是必需的查询字符串参数。

http(s)://{hostname}:{port}/config/v1/agents?service.name=SERVICE_NAME

HTTP POST

将参数编码为正文中的 JSON 对象。 service.name 是必需参数。

http(s)://{hostname}:{port}/config/v1/agents
{
  "service": {
      "name": "test-service",
      "environment": "all"
  },
  "CAPTURE_BODY": "off"
}
  • 成功 - 200
  • APM Server 配置为从 Elasticsearch 获取 Agent 配置,但配置无效 - 403
  • APM Server 正在启动或 Elasticsearch 无法访问 - 503

示例 Agent 配置 GET 请求,包括服务名称“test-service”

curl -i http://127.0.0.1:8200/config/v1/agents?service.name=test-service

示例 Agent 配置 POST 请求,包括服务名称“test-service”

curl -X POST http://127.0.0.1:8200/config/v1/agents \
  -H "Authorization: Bearer secret_token" \
  -H 'content-type: application/json' \
  -d '{"service": {"name": "test-service"}}'
HTTP/1.1 200 OK
Cache-Control: max-age=30, must-revalidate
Content-Type: application/json
Etag: "7b23d63c448a863fa"
Date: Mon, 24 Feb 2020 20:53:07 GMT
Content-Length: 98

{
    "capture_body": "off",
    "transaction_max_spans": "500",
    "transaction_sample_rate": "0.3"
}
© . All rights reserved.