Create prometheus role
This commit is contained in:
Родитель
fc9dae8e9f
Коммит
7af600ad2f
|
@ -15,6 +15,7 @@
|
|||
- watchtower
|
||||
- docker-gc
|
||||
- traefik
|
||||
- prometheus
|
||||
|
||||
- hosts: dchi
|
||||
roles:
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
prometheus_container: prom/prometheus:v1.5.1
|
|
@ -0,0 +1,5 @@
|
|||
- name: restart prometheus
|
||||
systemd:
|
||||
name: prometheus
|
||||
state: restarted
|
||||
daemon_reload: yes
|
|
@ -0,0 +1,28 @@
|
|||
- name: prometheus
|
||||
notify:
|
||||
- restart prometheus
|
||||
template:
|
||||
src: prometheus.j2
|
||||
dest: /etc/prometheus.yml
|
||||
|
||||
- name: service
|
||||
notify:
|
||||
- restart prometheus
|
||||
template:
|
||||
src: service.j2
|
||||
dest: /etc/systemd/system/prometheus.service
|
||||
|
||||
- name: default
|
||||
notify:
|
||||
- restart prometheus
|
||||
template:
|
||||
src: default.j2
|
||||
dest: /etc/default/prometheus
|
||||
|
||||
- name: start
|
||||
systemd:
|
||||
name: prometheus
|
||||
state: started
|
||||
daemon_reload: yes
|
||||
masked: no
|
||||
enabled: yes
|
|
@ -0,0 +1,32 @@
|
|||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
external_labels:
|
||||
monitor: 'exporter-metrics'
|
||||
|
||||
# rule_files: TODO: Add rules for alertmanager
|
||||
# - "prometheus.rules"
|
||||
|
||||
scrape_configs:
|
||||
- job_name: 'node-exporter'
|
||||
dns_sd_configs:
|
||||
- names:
|
||||
- node-exporter
|
||||
refresh_interval: 15s
|
||||
type: A
|
||||
port: 9100
|
||||
|
||||
- job_name: 'prometheus'
|
||||
static_configs:
|
||||
- targets:
|
||||
- '127.0.0.1:9090'
|
||||
|
||||
- job_name: 'alertmanager'
|
||||
static_configs:
|
||||
- targets:
|
||||
- 'alertmanager:9093'
|
||||
|
||||
- job_name: 'traefik-exporter'
|
||||
static_configs:
|
||||
- targets:
|
||||
- 'traefik-exporter.traefik.rancher.internal:9000'
|
|
@ -0,0 +1,25 @@
|
|||
[Unit]
|
||||
Description=Prometheus
|
||||
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
|
||||
EnvironmentFile=/etc/default/prometheus
|
||||
ExecStop=/bin/sh -c '/usr/bin/docker ps | /bin/grep %p 1> /dev/null && /usr/bin/docker stop %p || true'
|
||||
ExecStartPre=/bin/sh -c '/usr/bin/docker ps | /bin/grep %p 1> /dev/null && /usr/bin/docker kill %p || true'
|
||||
ExecStartPre=/bin/sh -c '/usr/bin/docker ps -a | /bin/grep %p 1> /dev/null && /usr/bin/docker rm %p || true'
|
||||
ExecStartPre=/usr/bin/docker pull {{ prometheus_container }}
|
||||
|
||||
ExecStart=/usr/bin/docker run --rm \
|
||||
--name %p \
|
||||
--volume /var/lib/prometheus:/prometheus \
|
||||
--publish 127.0.0.1:9090:9090 \
|
||||
{{ prometheus_container }} \
|
||||
-config.file=/etc/prometheus.yml \
|
||||
-alertmanager.url=http://alertmanager:9093
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Загрузка…
Ссылка в новой задаче