systemctl stop firewalld
systemctl enable firewallld
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
yum -y install docker
systemctl start docker
systemctl enable docker
#*************************************
docker search prometheus
docker pull docker.io/prom/prometheus:v2.2.1
mkdir /var/lib/prometheus-data
docker run -d -p 9090:9090 -v /root/prometheus/prometheus-rules/alerting.rules:/etc/prometheus-rules/alerting.rules -v /root/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -v /var/lib/prometheus-data:/prometheus --name prometheus docker.io/prom/prometheus:v2.2.1
#配置文件
cat /root/prometheus/prometheus.yml
global:
scrape_interval: 1m
scrape_timeout: 10s
evaluation_interval: 1m
alerting:
alertmanagers:
- scheme: http
static_configs:
- targets:
- "192.168.1.223:9093"
rule_files:
- /etc/prometheus-rules/*.rules
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets:
- 192.168.1.223:9090
cat /root/prometheus/prometheus-rules/alerting.rules
groups:
- name: example-rules
interval: 30s # defaults to global interval
rules:
- alert: Node Down
expr: up{job="kubernetes-nodes"} == 0
annotations:
miqTarget: "ContainerNode"
severity: "HIGH"
message: "{{$labels.instance}} is down"
groups:- name: example-rules interval: 30s # defaults to global interval rules: - alert: Node Down expr: up{job="kubernetes-nodes"} == 0 annotations: miqTarget: "ContainerNode" severity: "HIGH" message: "{{$labels.instance}} is down" |