many corrections
This commit is contained in:
parent
956515f6ab
commit
7e91930523
@ -17,3 +17,11 @@
|
|||||||
that: "'docker-ce' in ansible_facts.packages"
|
that: "'docker-ce' in ansible_facts.packages"
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
|
||||||
|
- name: 'prometheus | assert | check if docker pyhon libraries are installed'
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'python-docker' in ansible_facts.packages"
|
||||||
|
- "'python3-docker' in ansible_facts.packages"
|
||||||
|
tags:
|
||||||
|
- prometheus
|
||||||
|
@ -2,5 +2,33 @@
|
|||||||
- name: 'prometheus | include asserts'
|
- name: 'prometheus | include asserts'
|
||||||
include_tasks: 'asserts.yml'
|
include_tasks: 'asserts.yml'
|
||||||
|
|
||||||
- name: 'prometheus | install'
|
- name: 'prometheus | server install'
|
||||||
include_tasks: 'install.yml'
|
include_tasks: 'prometheus.yml'
|
||||||
|
when:
|
||||||
|
- prometheus_server_enable is defined
|
||||||
|
- prometheus_server_enable == "true"
|
||||||
|
|
||||||
|
- name: 'prometheus | Node exporter'
|
||||||
|
include_tasks: 'node_exporter.yml'
|
||||||
|
when:
|
||||||
|
- prometheus_node_exporter_enable is defined
|
||||||
|
- prometheus_node_exporter_enable == "true"
|
||||||
|
|
||||||
|
- name: 'prometheus | MongoDB exporter'
|
||||||
|
include_tasks: 'mongodb_exporter.yml'
|
||||||
|
when:
|
||||||
|
- prometheus_mongodb_exporter_enable is defined
|
||||||
|
- prometheus_mongodb_exporter_enable == "true"
|
||||||
|
|
||||||
|
- name: 'prometheus | MySQL exporter'
|
||||||
|
include_tasks: 'mysqld_exporter.yml'
|
||||||
|
when:
|
||||||
|
- prometheus_mysqld_exporter_enable is defined
|
||||||
|
- prometheus_mysqld_exporter_enable == "true"
|
||||||
|
|
||||||
|
- name: 'prometheus | PostgreSQL exporter'
|
||||||
|
include_tasks: 'postgresql_exporter.yml'
|
||||||
|
when:
|
||||||
|
- prometheus_postgres_exporter_enable is defined
|
||||||
|
- prometheus_postgres_exporter_enable == "true"
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
- name: 'prometheus | mongodb exporter | install unit file to systemd'
|
- name: 'prometheus | mongodb exporter | install unit file to systemd'
|
||||||
template:
|
template:
|
||||||
src: templates/systemd/prometheus-mongodb-exporter.service.j2
|
src: systemd/prometheus-mongodb-exporter.service.j2
|
||||||
dest: /etc/systemd/system/prometheus-mongodb-exporter.service
|
dest: /etc/systemd/system/prometheus-mongodb-exporter.service
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
@ -36,5 +36,5 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
state: started
|
||||||
name: mongodb_exporter.service
|
name: prometheus-mongodb-exporter.service
|
||||||
when: prometheus_mongodb_exporter_enable == "true"
|
when: prometheus_mongodb_exporter_enable == "true"
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
- name: 'prometheus | mysqld exporter | install unit file to systemd'
|
- name: 'prometheus | mysqld exporter | install unit file to systemd'
|
||||||
template:
|
template:
|
||||||
src: templates/systemd/prometheus-mysqld-exporter.service.j2
|
src: systemd/prometheus-mysqld-exporter.service.j2
|
||||||
dest: /etc/systemd/system/prometheus-mysqld-exporter.service
|
dest: /etc/systemd/system/prometheus-mysqld-exporter.service
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
@ -52,5 +52,5 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
state: started
|
||||||
name: mysqld_exporter.service
|
name: prometheus-mysqld-exporter.service
|
||||||
when: prometheus_mysqld_exporter_enable == "true"
|
when: prometheus_mysqld_exporter_enable == "true"
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
- name: 'prometheus | node exporter | install unit file to systemd'
|
- name: 'prometheus | node exporter | install unit file to systemd'
|
||||||
template:
|
template:
|
||||||
src: templates/systemd/prometheus_node_exporter.service.j2
|
src: systemd/prometheus-node-exporter.service.j2
|
||||||
dest: /etc/systemd/system/prometheus_node_exporter.service
|
dest: /etc/systemd/system/prometheus-node-exporter.service
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0600
|
mode: 0600
|
||||||
@ -36,5 +36,5 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
state: started
|
||||||
name: node_exporter.service
|
name: prometheus-node-exporter.service
|
||||||
when: prometheus_node_exporter_enable == "true"
|
when: prometheus_node_exporter_enable == "true"
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
mode: 0755
|
mode: 0755
|
||||||
when: prometheus_postgres_exporter_enable == "true"
|
when: prometheus_postgres_exporter_enable == "true"
|
||||||
|
|
||||||
- name: 'prometheus | mysql exporter | configuration'
|
- name: 'prometheus | postgres exporter | configuration'
|
||||||
copy:
|
copy:
|
||||||
dest: '/var/lib/prometheus/.my.cnf'
|
dest: '/var/lib/prometheus/.my.cnf'
|
||||||
owner: root
|
owner: root
|
||||||
@ -58,10 +58,18 @@
|
|||||||
|
|
||||||
- name: 'prometheus | postgres exporter | install unit file to systemd'
|
- name: 'prometheus | postgres exporter | install unit file to systemd'
|
||||||
template:
|
template:
|
||||||
src: templates/systemd/prometheus-postgres-exporter.service.j2
|
src: systemd/prometheus-postgres-exporter.service.j2
|
||||||
dest: /etc/systemd/system/prometheus-postgres-exporter.service
|
dest: /etc/systemd/system/prometheus-postgres-exporter.service
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0600
|
mode: 0600
|
||||||
when: prometheus_postgres_exporter_enable == "true"
|
when: prometheus_postgres_exporter_enable == "true"
|
||||||
|
|
||||||
|
|
||||||
|
- name: 'prometheus | postgres exporter | configure systemd to use service'
|
||||||
|
systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
enabled: yes
|
||||||
|
state: started
|
||||||
|
name: prometheus-postgres-exporter.service
|
||||||
|
when: prometheus_postgres_exporter_enable == "true"
|
||||||
|
@ -1,40 +1,49 @@
|
|||||||
---
|
---
|
||||||
- name: 'prometheus | create docker network'
|
- name: 'prometheus | server | assert | check mandatory vars are defined'
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "prometheus_server_monitor is defined"
|
||||||
|
tags:
|
||||||
|
- prometheus
|
||||||
|
|
||||||
|
- name: 'prometheus | server | create docker network'
|
||||||
docker_network:
|
docker_network:
|
||||||
name: 'prometheus'
|
name: 'prometheus'
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
when: prometheus_enable == "true"
|
when: prometheus_server_enable == "true"
|
||||||
|
|
||||||
- name: 'prometheus | create docker volume data'
|
- name: 'prometheus | server | create docker volume data'
|
||||||
docker_volume:
|
docker_volume:
|
||||||
name: prometheus_data
|
name: prometheus_data
|
||||||
register: register_docker_volume_prometheus__prometheus_data
|
register: register_docker_volume_prometheus__prometheus_data
|
||||||
when: prometheus_enable == "true"
|
when: prometheus_server_enable == "true"
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
|
||||||
- name: 'prometheus | create prometheus directory to /etc'
|
- name: 'prometheus | server | create prometheus directory to /etc'
|
||||||
file:
|
file:
|
||||||
path: /etc/prometheus
|
path: /etc/prometheus
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
when: prometheus_enable == "true"
|
when: prometheus_server_enable == "true"
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
|
||||||
- name: 'prometheus | copy config prometheus yml'
|
- name: 'prometheus | server | copy config prometheus yml'
|
||||||
template:
|
template:
|
||||||
src: templates/prometheus.yml.j2
|
src: prometheus.yml.j2
|
||||||
dest: /etc/prometheus/prometheus.yml
|
dest: /etc/prometheus/prometheus.yml
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
when: prometheus_enable == "true"
|
when:
|
||||||
|
- prometheus_server_enable == "true"
|
||||||
|
- prometheus_server_monitor is defined
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
|
||||||
- name: 'prometheus | deploy container'
|
- name: 'prometheus | server | deploy container'
|
||||||
docker_container:
|
docker_container:
|
||||||
name: prometheus
|
name: prometheus
|
||||||
hostname: '{{ inventory_hostname }}'
|
hostname: '{{ inventory_hostname }}'
|
||||||
@ -52,14 +61,12 @@
|
|||||||
- { name: prometheus }
|
- { name: prometheus }
|
||||||
ports:
|
ports:
|
||||||
- "9090:9090"
|
- "9090:9090"
|
||||||
etc_hosts:
|
|
||||||
foo: 10.1.1.1
|
|
||||||
bar: 10.1.1.2
|
|
||||||
log_driver: syslog
|
log_driver: syslog
|
||||||
log_options:
|
log_options:
|
||||||
tag: docker_prometheus
|
tag: docker_prometheus
|
||||||
restart_policy: 'unless-stopped'
|
restart_policy: 'unless-stopped'
|
||||||
pull: '{{ awh_services_docker_pull|default("no") }}'
|
pull: '{{ awh_services_docker_pull|default("no") }}'
|
||||||
when: prometheus_enable == "true"
|
when: prometheus_server_enable == "true"
|
||||||
tags:
|
tags:
|
||||||
- prometheus
|
- prometheus
|
||||||
|
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
# Sample config for Prometheus.
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
# Attach these labels to any time series or alerts when communicating with
|
|
||||||
# external systems (federation, remote storage, Alertmanager).
|
|
||||||
external_labels:
|
|
||||||
monitor: '{{ prometheus_monitor }}'
|
|
||||||
|
|
||||||
{% if prometheus_rules is defined %}
|
|
||||||
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
|
|
||||||
rule_files:
|
|
||||||
- 'rules.yml'
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# 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'
|
|
||||||
|
|
||||||
# Override the global default and scrape targets from this job every 5 seconds.
|
|
||||||
scrape_interval: 5s
|
|
||||||
scrape_timeout: 5s
|
|
||||||
|
|
||||||
# metrics_path defaults to '/metrics'
|
|
||||||
# scheme defaults to 'http'.
|
|
||||||
|
|
||||||
static_configs:
|
|
||||||
- targets: ['localhost:9090']
|
|
||||||
|
|
||||||
{% if prometheus_node_exporter_enable == "true" %}
|
|
||||||
- job_name: node
|
|
||||||
scrape_interval: 30s
|
|
||||||
scrape_timeout: 10s
|
|
||||||
static_configs:
|
|
||||||
- targets:
|
|
||||||
- foo:9100
|
|
||||||
- bar:9100
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if prometheus_mysqld_exporter_enable == "true" %}
|
|
||||||
- job_name: mysql
|
|
||||||
scrape_interval: 30s
|
|
||||||
scrape_timeout: 10s
|
|
||||||
static_configs:
|
|
||||||
- targets:
|
|
||||||
- foo:9104
|
|
||||||
- bar:9104
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if prometheus_mongodb_exporter_enable == "true" %}
|
|
||||||
- job_name: mongodb
|
|
||||||
scrape_interval: 30s
|
|
||||||
scrape_timeout: 10s
|
|
||||||
static_configs:
|
|
||||||
- targets:
|
|
||||||
- foo:9001
|
|
||||||
- bar:9001
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if prometheus_postgres_exporter_enable == "true" %}
|
|
||||||
- job_name: postgresql
|
|
||||||
scrape_interval: 30s
|
|
||||||
scrape_timeout: 10s
|
|
||||||
static_configs:
|
|
||||||
- targets:
|
|
||||||
- foo:9001
|
|
||||||
- bar:9001
|
|
||||||
{% endif %}
|
|
||||||
|
|
85
templates/prometheus.yml.j2
Normal file
85
templates/prometheus.yml.j2
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
global:
|
||||||
|
scrape_interval: '{{ prometheus_server_global_scrape_interval | default(15) }}'s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
|
||||||
|
evaluation_interval: '{{ prometheus_server_global_evaluation_interval | default(15) }}'s # Evaluate rules every 15 seconds. The default is every 1 minute.
|
||||||
|
|
||||||
|
# Attach these labels to any time series or alerts when communicating with
|
||||||
|
# external systems (federation, remote storage, Alertmanager).
|
||||||
|
external_labels:
|
||||||
|
monitor: '{{ prometheus_server_monitor }}'
|
||||||
|
|
||||||
|
{% if prometheus_server_rules is defined %}
|
||||||
|
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
|
||||||
|
rule_files:
|
||||||
|
- 'rules.yml'
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# 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_server_job_name | default("prometheus") }}'
|
||||||
|
|
||||||
|
# Override the global default and scrape targets from this job every 5 seconds.
|
||||||
|
scrape_interval: '{{ prometheus_server_scrape_interval | default(5) }}'s
|
||||||
|
scrape_timeout: '{{ prometheus_server_scrape_timeout | default(5) }}'s
|
||||||
|
|
||||||
|
# metrics_path defaults to '/metrics'
|
||||||
|
# scheme defaults to 'http'.
|
||||||
|
|
||||||
|
static_configs:
|
||||||
|
- targets: ['localhost:9090']
|
||||||
|
|
||||||
|
{% if (prometheus_node_exporter_enable is defined) and (prometheus_node_exporter_enable == "true") %}
|
||||||
|
- job_name: node
|
||||||
|
scrape_interval: 30s
|
||||||
|
scrape_timeout: 10s
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
{% if prometheus_node_exporter_targets is defined %}
|
||||||
|
{% for target in prometheus_node_exporter_targets %}
|
||||||
|
- {{ target }}:9100
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if (prometheus_mysqld_exporter_enable is defined) and (prometheus_mysqld_exporter_enable == "true") %}
|
||||||
|
- job_name: mysql
|
||||||
|
scrape_interval: 30s
|
||||||
|
scrape_timeout: 10s
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
{% if prometheus_mysql_exporter_targets is defined %}
|
||||||
|
{% for target in prometheus_mysqld_exporter_targets %}
|
||||||
|
- {{ target }}:9104
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if (prometheus_mongodb_exporter_enable is defined) and (prometheus_mongodb_exporter_enable == "true") %}
|
||||||
|
- job_name: mongodb
|
||||||
|
scrape_interval: 30s
|
||||||
|
scrape_timeout: 10s
|
||||||
|
static_configs:
|
||||||
|
- targets
|
||||||
|
{% if prometheus_mongodb_exporter_targets is defined %}
|
||||||
|
{% for target in prometheus_mongodb_exporter_targets %}
|
||||||
|
- {{ target }}:9001
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if (prometheus_postgres_exporter_enable is defined) and (prometheus_postgres_exporter_enable == "true") %}
|
||||||
|
- job_name: postgresql
|
||||||
|
scrape_interval: 30s
|
||||||
|
scrape_timeout: 10s
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
{% if prometheus_postgres_exporter_targets is defined %}
|
||||||
|
{% for target in prometheus_postgres_exporter_targets %}
|
||||||
|
- {{ target }}:9187
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user