两者看起来都很简单:
-
NGINX exporter
-
官方Microsoft SQL Server exporter
请更新您的问题并解释:
- 正是您尝试过的(包括代码和配置)
- 您收到了哪些错误
示例
这会更好,例如Docker Compose 但是...
nginx.conf:
events {
use epoll;
worker_connections 128;
}
http {
server {
location = /basic_status {
stub_status;
}
}
}
运行 NGINX(默认为 :80):
docker run \
--interactive --tty --rm \
--net=host \
--volume=${PWD}/nginx.conf:/etc/nginx/nginx.conf:ro \
nginx
测试一下:
curl \
--request GET \
http://localhost/basic_status
运行导出器:
docker run \
--interactive --tty --rm \
--net=host \
nginx/nginx-prometheus-exporter \
-nginx.scrape-uri=http://localhost/basic_status
测试一下:
curl \
--request GET \
http://localhost:9113/metrics
产量:
# HELP nginx_connections_accepted Accepted client connections
# TYPE nginx_connections_accepted counter
nginx_connections_accepted 1
# HELP nginx_connections_active Active client connections
# TYPE nginx_connections_active gauge
nginx_connections_active 1
# HELP nginx_connections_handled Handled client connections
# TYPE nginx_connections_handled counter
nginx_connections_handled 1
# HELP nginx_connections_reading Connections where NGINX is reading the request header
# TYPE nginx_connections_reading gauge
nginx_connections_reading 0
# HELP nginx_connections_waiting Idle client connections
# TYPE nginx_connections_waiting gauge
nginx_connections_waiting 0
# HELP nginx_connections_writing Connections where NGINX is writing the response back to the client
# TYPE nginx_connections_writing gauge
nginx_connections_writing 1
# HELP nginx_http_requests_total Total http requests
# TYPE nginx_http_requests_total counter
nginx_http_requests_total 2
# HELP nginx_up Status of the last metric scrape
# TYPE nginx_up gauge
nginx_up 1
# HELP nginxexporter_build_info Exporter build information
# TYPE nginxexporter_build_info gauge
nginxexporter_build_info{commit="5f88afbd906baae02edfbab4f5715e06d88538a0",date="2021-03-22T20:16:09Z",version="0.9.0"} 1
prometheus.yml:
scrape_configs:
# Self
- job_name: "prometheus-server"
static_configs:
- targets:
- "localhost:9090"
# NGINX
- job_name: "nginx"
static_configs:
- targets:
- "localhost:9113"
然后:
docker run \
--interactive --tty --rm \
--net=host \
--volume=${PWD}/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus:v2.26.0 \
--config.file=/etc/prometheus/prometheus.yml
然后:
目标:
图表: