我已按照https://github.com/discordianfish/nginx_exporter中的步骤为 nginx导出程序设置docker容器。
现在我想在mesosphere集群上使用marathon为nginx安装docker容器。如何向docker容器提供参数'nginx.scrape_uri'。 我尝试使用此链接中的“特权模式和任意Docker选项”中给出的“参数”原语https://mesosphere.github.io/marathon/docs/native-docker.html但是,在JSON中添加参数原语会使应用程序停留在“部署”状态。
我用于使用marathon为nginx-exporter创建app的我的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文件的正确方法。 感谢。
答案 0 :(得分:0)
你应该使用" args"而不是"参数",类似于:
{
...
"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