# my global config global: scrape_interval: 10s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 10s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=` to any timeseries scraped from this config. # metrics_path defaults to '/metrics' # scheme defaults to 'http'. - job_name: "prometheus" static_configs: - targets: ["172.19.10.3:9100"]
consul agent -dev -ui -data-dir=/usr/local/prometheus/consul/data -config-dir=/usr/local/prometheus/consul/etc -client=0.0.0.0
image.png
访问页面
部署成功,访问地址:http://172.19.11.50:8500/ui
image.png
修改Prometheus配置,设置基于Consul发现节点
# my global config global: scrape_interval: 10s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 10s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=` to any timeseries scraped from this config. # metrics_path defaults to '/metrics' # scheme defaults to 'http'. consul_sd_configs: - server: "172.19.11.50:8500" tags: #consul中的节点,若标签存在标签名"prometheus" ,prometheus则会通过该tags去自动发现 - "prometheus" refresh_interval: 15s - job_name: 'nodes' consul_sd_configs: #由file变为consul - server: "172.19.11.50:8500" tags: #consul中的节点,若标签存在nodes ,prometheus则会通过该tags去自动发现 - "nodes" refresh_interval: 15s