使用 marathon 在 mesosphere DCOS 集群上配置 Prometheus nginx exporter

Configure Prometheus nginx exporter on mesosphere DCOS cluster using marathon

我已按照 https://github.com/discordianfish/nginx_exporter 中给出的步骤为 nginx exporter 设置了一个 docker 容器。

现在我想在 mesosphere 集群上使用 marathon 安装 nginx 的 docker 容器。如何向 docker 容器提供参数 'nginx.scrape_uri'。 我曾尝试在 link https://mesosphere.github.io/marathon/docs/native-docker.html 中使用 'Privileged Mode and Arbitrary Docker Options' 中给出的 'parameter' 原语 但是,在 JSON 中添加参数原语会使应用程序卡在 'deploying'状态。

我用来使用 marathon 为 nginx-exporter 创建应用程序的 JSON 文件是:

{
  "id": "/nginx-exporter",
  "instances": 1,
  "cpus": 0.1,
  "mem": 25,
  "constraints": [["hostname", "UNIQUE"]],
  "acceptedResourceRoles": ["slave_public"],
  "container": {
    "type": "DOCKER",
    "docker": {
        "image": "fish/nginx-exporter",
        "network": "BRIDGE",
        "portMappings": [
                           {
                              "containerPort": 9113,
                              "hostPort": 9113,
                              "protocol": "tcp"
                           }
                        ],
        "parameters":   [   {"key": "nginx.scrape_uri", "value": "http://52.76.26.53:8080" }
                        ]
              }
  },
  "healthChecks": [{
    "protocol": "TCP",
    "gracePeriodSeconds": 600,
    "intervalSeconds": 30,
    "portIndex": 0,
    "timeoutSeconds": 10,
    "maxConsecutiveFailures": 2
  }]
}

请告诉我将参数 'nginx.scrape_uri' 添加到 JSON 文件的正确方法。 谢谢

您应该使用 "args" 而不是 "parameters",例如:

{
  ...
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "fish/nginx-exporter",
      "network": "BRIDGE",
      "portMappings": [
        {
          "containerPort": 9113,
          "hostPort": 9113,
          "protocol": "tcp"
        }
      ]
    }
  },
  "args": [ "-nginx.scrape_uri", "http://52.76.26.53:8080" ],
  ...
}

请记住,您需要启用 nginx 存根状态模块并将导出器指向该端点:http://nginx.org/en/docs/http/ngx_http_stub_status_module.html