traefik公开内部指标

时间:2018-09-04 16:57:49

标签: traefik

我想介绍traefik的内部指标。 阅读文档后,我创建了以下配置文件:

logLevel = "INFO"
[entryPoints]
    [entryPoints.http]
    address = ":80"
    [entryPoints.dashboard]
    address = ":16081"
# API definition
[api]
  entryPoint = "dashboard"
  dashboard = true
  debug = false
  [api.statistics]
    recentErrors = 10
# Metrics definition
[metrics]
  # DataDog metrics exporter type
  [metrics.datadog]
    address = "172.17.0.1:8125"
    pushInterval = "10s"
################################################################
# Mesos/Marathon Provider
################################################################
# Enable Marathon Provider.
[marathon]
endpoint = "http://mesos.lan:8080/"
watch = true
domain = "service.lan"
exposedByDefault = false

查询仪表板入口点时,在/ metrics上出现404错误:

curl -s http://localhost:16081/health | jq
{
  "pid": 1,
  "uptime": "3h31m3.5252748s",
  "uptime_sec": 12663.5252748,
  "time": "2018-09-04 16:53:17.7128687 +0000 UTC m=+12663.602939001",
  "unixtime": 1536079997,
  "status_code_count": {},
  "total_status_code_count": {
    "404": 5
  },
  "count": 0,
  "total_count": 5,
  "total_response_time": "390.7µs",
  "total_response_time_sec": 0.0003907,
  "average_response_time": "78.14µs",
  "average_response_time_sec": 7.814e-05,
  "recent_errors": [
    {
      "status_code": 404,
      "status": "Not Found",
      "method": "GET",
      "host": "localhost:16081",
      "path": "/metrics",
      "time": "2018-09-04T16:53:12.0232879Z"
    },
    {
      "status_code": 404,
      "status": "Not Found",
      "method": "GET",
      "host": "localhost:16081",
      "path": "/metrics",
      "time": "2018-09-04T13:18:52.7206202Z"
    },
    {
      "status_code": 404,
      "status": "Not Found",
      "method": "GET",
      "host": "localhost:16081",
      "path": "/metrics",
      "time": "2018-09-04T13:18:51.853093Z"
    },
    {
      "status_code": 404,
      "status": "Not Found",
      "method": "GET",
      "host": "localhost:16081",
      "path": "/metrics",
      "time": "2018-09-04T13:18:50.9894516Z"
    },
    {
      "status_code": 404,
      "status": "Not Found",
      "method": "GET",
      "host": "localhost:16081",
      "path": "/metrics",
      "time": "2018-09-04T13:18:49.8598176Z"
    }
  ]
}
curl -s http://localhost:16081/metrics
404 page not found

我错过了什么吗?

我的主要目标是能够获取每个前端/后端的指标。 我希望能够知道每个前端的请求数量和返回的状态代码。

谢谢

雷诺(Renaud)

1 个答案:

答案 0 :(得分:0)

这已解决,总之,/ metrics仅在启用promotheus提供程序时才公开。启用Datadog提供程序后,所有指标都会发送到datadog。

详细信息可以在这里找到:github.com/containous/traefik/issues/3877