使用 telegraf 容器监控 NGINX

Monitoring NGINX with telegraf Container

我正在尝试通过 telegraf 容器跟随 post telegraf container 监控 nginx(安装在 CentOS 上)。但不断出现如下错误

2018-09-19T01:31:00Z E! Error in plugin [inputs.nginx]: error making HTTP request to https://127.0.0.1/nginx_status: Get https://127.0.0.1/nginx_status: x509: certificate is valid for 52.37.147.151, not 127.0.0.1

在NGINX中,配置类似

http {
  ssl on;
    ssl_certificate     /**/**/**/**.cert;
    ssl_certificate_key /**/**/**/**.key;
    ssl_protocols  TLSv1.2;
    ssl_ciphers '*****';
    ssl_prefer_server_ciphers on;
    ...
    server {
        listen 127.0.0.1:443;

        location /nginx_status {
            auth_request off;
            stub_status on;
            access_log off;
            allow 127.0.0.1;
            deny all;
        }
     }
}

当我 运行 "curl -k https://127.0.0.1/nginx_status" 时,它工作正常,我得到了 nginx 连接的基本状态。 但是当我向 运行 电报容器声明时,它保留了上面的错误..

知道发生了什么事吗?谢谢

您在 nginx 配置中提供的证书路径仅颁发给本地主机。可以通过文本方式查看证书来验证,

cat <certificate-file-path> | openssl x509 -text

并查找 Subject Alternative NameSubject

解决方案是生成一个新的证书,该证书是为您想要的host/ip颁发的。

我没有注意到 telegraf nginx plugin 中有忽略身份验证的选项。将此设置为 true 它对我有用。 "insecure_skip_verify = true"