PushGateway
# ===== 重点:PushGateway配置 ===== - job_name: 'pushgateway' scrape_interval: 15s honor_labels: true # 重要!保留Agent的标签 static_configs: - targets: ['localhost:9091']
upstream pushgateway {
server 127.0.0.1:9091;
}
server {
listen 443 ssl http2;
server_name push.example.com;
ssl_certificate /etc/letsencrypt/live/push.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/push.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
limit_req_zone $binary_remote_addr zone=limit:10m rate=10r/s;
location / {
auth_basic "PushGateway";
auth_basic_user_file /etc/nginx/conf.d/pushgateway.htpasswd;
limit_req zone=limit burst=20 nodelay;
proxy_pass http://pushgateway;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
server_name push.example.com;
return 301 https://$server_name$request_uri;
}
scrape_configs:
- job_name: 'pushgateway'
honor_labels: true
static_configs:
- targets: ['push.example.com:443']
scheme: https
basic_auth:
username: 'prometheus'
password: 'YourPassword'
tls_config:
insecure_skip_verify: false