基于配置文件



scrape_configs:
...

- job_name: "nodes"
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- 192.168.168.106:9100
- 192.168.168.105:9100


基于文件



[root@ops ~]# cd /opt/prometheus
[root@ops prometheus]# mkdir targets
[root@ops prometheus]# cd targets/
[root@ops targets]# cat prometheus-server.yml
- targets:
- 127.0.0.1:9090
labels:
app: prometheus-server

[root@ops targets]# cat nodes-linux.yml
- targets:
- 192.168.168.106:9100
- 192.168.168.105:9100
labels:
app: node_exporter

# 主配置文件

scrape_configs:
- job_name: "prometheus"
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
file_sd_configs:
- files:
- targets/prometheus-*.yml
refresh_interval: 1m

- job_name: "nodes"
honor_timestamps: true
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
file_sd_configs:
- files:
- targets/nodes-*.yml
refresh_interval: 1m


基于 Consl

基于DNS

基于Kubernetes API