yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce
systemctl start docker
systemctl enable docker
docker pull prom/prometheus
mkdir prometheus
cd /opt
cd prometheus/
vi prometheus.yml
----{----
# my global config
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).
alerting:
alertmanagers:
- static_configs:
- targets: ['10.80.10.7:9093']
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- rules.yml
# - "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: ['127.0.0.1:9090']
- job_name: 'spring-actuator'
metrics_path: '/bzfzngl/actuator/prometheus'
scrape_interval: 5s
static_configs:
- targets: ['10.80.10.15:8080']
----}----
vi rules.yml
----{----
groups:
- name: default
rules:
- alert: service_down
expr: up{job="spring-actuator"} == 0
labels:
severity: major
annotations:
description: Service {{ $labels.instance }} is unavailable.
value: DOWN ({{ $value }})
----}----
docker run -d --name=prometheus -p 9090:9090 -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -v /opt/prometheus/rules.yml:/etc/prometheus/rules.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml
docker pull grafana/grafana
docker run -d --name=grafana -p 3000:3000 grafana/grafana
docker pull prom/alertmanager
cd /opt
mkdir alertmanager
cd alertmanager
vi alertmanager.yml
----{----
global:
resolve_timeout: 1m
smtp_from: 'xxxxxxxx@qq.com'
smtp_smarthost: 'smtp.qq.com:465'
smtp_auth_username: 'xxxxxxxx@qq.com'
smtp_auth_password: 'xxxxxxxx'
smtp_require_tls: false
route:
receiver: 'mail-notifications'
receivers:
- name: 'mail-notifications'
email_configs:
- to: 'xxxxxxxx@nationstech.com, xxxxxxxx@qq.com'
send_resolved: true
----}----
docker run -d --name=alertmanager -p 9093:9093 -v /opt/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml prom/alertmanager --config.file=/etc/alertmanager/alertmanager.yml