curl -u admin http://localhost:9090/metrics Enter host password for user 'admin':
这应该返回 Prometheus 指标输出,它应该如下所示:
# HELP go_gc_duration_seconds A summary of the GC invocation durations. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 0.0001343 go_gc_duration_seconds{quantile="0.25"} 0.0002032 go_gc_duration_seconds{quantile="0.5"} 0.0004485 ...
$ curl http://localhost:39100/metrics Client sent an HTTP request to an HTTPS server. root@zabbix:/opt/node_exporter# curl https://localhost:39100/metrics curl: (60) SSL certificate problem: self signed certificate More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.
可以看到不能直接访问了,下面带上证书及用户密码再次测试
$ curl -u prometheus -s --cacert node_exporter.crt https://localhost:39100/metrics |grep node_exporter_build_info Enter host password for user 'prometheus': # HELP node_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which node_exporter was built. # TYPE node_exporter_build_info gauge node_exporter_build_info{branch="HEAD",goversion="go1.19.3",revision="1b48970ffcf5630534fb00bb0687d73c66d1c959",version="1.5.0"} 1