Search code examples
mesosphereprometheus

Configure Prometheus nginx exporter on mesosphere DCOS cluster using marathon


I have followed steps given in https://github.com/discordianfish/nginx_exporter to set up a docker container for nginx exporter.

Now I want to install the docker container for nginx using marathon on mesosphere cluster. How do I provide parameter 'nginx.scrape_uri' to the docker container. I have tried using the 'parameter' primitive given in 'Privileged Mode and Arbitrary Docker Options' in this link https://mesosphere.github.io/marathon/docs/native-docker.html However, adding the parameter primitive in the JSON keeps the app stuck in 'deploying' state.

My JSON file that I am using to create app for nginx-exporter using marathon is:

{
  "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
  }]
}

Please let me know the correct way of adding parameter 'nginx.scrape_uri' to the JSON file. Thanks.


Solution

  • You should use "args" instead of "parameters", something like:

    {
      ...
      "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" ],
      ...
    }
    

    Keep in mind that you need to enable the nginx stub status module and point the exporter to that endpoint: http://nginx.org/en/docs/http/ngx_http_stub_status_module.html