- 一、node-export部署
- 二、alertmanager部署
- 三、prometheus部署
- scrape_timeout is set to the global default (10s).
- Alertmanager configuration
- Load rules once and periodically evaluate them according to the global ‘evaluation_interval’.
- - “first_rules.yml”
- - “second_rules.yml”
- A scrape configuration containing exactly one endpoint to scrape:
- Here it’s Prometheus itself.
- The job name is added as a label
job=<job_name>to any timeseries scraped from this config. - metrics_path defaults to ‘/metrics’
- scheme defaults to ‘http’.
一、node-export部署
docker run -d -p 9100:9100 --name node-exporter --restart always prom/node-exporter:latest
二、alertmanager部署
route:group_by: ['alertname']group_wait: 30sgroup_interval: 5mrepeat_interval: 1hreceiver: 'web.hook'receivers:- name: 'web.hook'webhook_configs:- url: 'http://127.0.0.1:5001/'inhibit_rules:- source_match:severity: 'critical'target_match:severity: 'warning'equal: ['alertname', 'dev', 'instance']
mkdir /opt/alertmanagercd /opt/alertmanagerdocker run -d -p 9093:9093 --name alertmanager -v $PWD/alertmanager.yml:/etc/alertmanager/alertmanager.yml --restart always prom/alertmanager:latest
三、prometheus部署
- /opt/prometheus/prometheus.yml
```json
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # 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:- 192.168.10.10: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=<job_name> to any timeseries scraped from this config.
job_name: “prometheus”
metrics_path defaults to ‘/metrics’
scheme defaults to ‘http’.
static_configs:
- targets: [“localhost:9090”]
- job_name: “node-export”
static_configs:
- targets: [“192.168.10.10:9100”]
- job_name: “alertmanager”
static_configs:
- targets: [“192.168.10.10:9093”] ```
创建容器
mkdir /opt/prometheuscd /opt/prometheusdocker run -d -p 9090:9090 --name prometheus -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml -v $PWD/data:/prometheus -v $PWD/roles:/etc/prometheus/ --restart always prom/prometheus:latest# 如果提示"open /prometheus/queries.active: permission denied"docker exec -it prometheus sh/prometheus $ cat /etc/passwd查看当前容器用户权限nobody:x:65534:65534:nobody:/home:/bin/falsechown -R 65534:65534 /opt/prometheus
prometheus.yml是prometheus的配置文件
- data目录用于存放prometheus程序持久化的数据
四、grafana部署
docker run -d -p 3000:3000 -v /opt/grafana/data:/var/lib/grafana -v /opt/grafana/grafana.ini:/etc/grafana/grafana.ini --name=grafana --restart always grafana/grafana:latest
