【问题标题】:Configure Prometheus nginx exporter on mesosphere DCOS cluster using marathon使用马拉松在 mesosphere DCOS 集群上配置 Prometheus nginx 导出器
【发布时间】:2015-11-04 22:58:21
【问题描述】:

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

现在我想在 mesosphere 集群上使用 marathon 为 nginx 安装 docker 容器。如何向 docker 容器提供参数“nginx.scrape_uri”。 我已经尝试在此链接https://mesosphere.github.io/marathon/docs/native-docker.html 中使用“特权模式和任意 Docker 选项”中给出的“参数”原语,但是,在 JSON 中添加参数原语会使应用程序停留在“部署”状态。

我使用马拉松为 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 文件的正确方法。 谢谢。

【问题讨论】:

    标签: mesosphere prometheus


    【解决方案1】:

    您应该使用“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

    【讨论】:

    • 感谢分享 nginx http stub 模块! args 有效。
    猜你喜欢
    • 2015-11-03
    • 2015-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-27
    • 2021-12-25
    • 2015-06-10
    • 1970-01-01
    相关资源
    最近更新 更多