Commit ebed87fd authored by HgO's avatar HgO
Browse files

Merge branch '43-playbook-alertmanager' into 'main'

Resolve "Playbook Alertmanager"

Closes #43

See merge request Neutrinet/infra!53
parents 4060c22b a216d52a
Pipeline #374 passed with stage
in 1 minute and 29 seconds
......@@ -129,3 +129,6 @@ probe-01.first.neutri.net
probe-02.ovh.neutri.net
monitoring.htz.neutri.net
man.patata.louise.neutri.net
[alertmanager]
monitoring.htz.neutri.net
---
# Déploiement d'Alertmanager
- hosts: alertmanager
become: true
pre_tasks:
- name: Update cache
apt:
update_cache: true
cache_valid_time: 3600
roles:
- alertmanager
alertmanager_smtp_host: localhost
alertmanager_smtp_port: 25
alertmanager_smtp_from: alertmanager@example.com
alertmanager_smtp_to: dringdring@example.com
alertmanager_smtp_username: alertmanager
alertmanager_smtp_password: neutrinet
# Grab metrics about alertmanager
- targets:
- localhost:9093
labels:
job: alertmanager
- name: restart alertmanager
service:
name: prometheus-alertmanager
state: restarted
- name: reload prometheus
service:
name: prometheus
state: reloaded
- name: reload alertmanager
service:
name: prometheus-alertmanager
state: reloaded
*********************************
Vagrant driver installation guide
*********************************
Requirements
============
* Vagrant
* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop
Install
=======
Please refer to the `Virtual environment`_ documentation for installation best
practices. If not using a virtual environment, please consider passing the
widely recommended `'--user' flag`_ when invoking ``pip``.
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
.. code-block:: bash
$ pip install 'molecule_vagrant'
---
- name: Converge
hosts: all
become: true
roles:
- alertmanager
telegraf_username: telegraf
telegraf_password: neutrinet
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: virtualbox
platforms:
- name: buster-alertmanager-molecule
box: debian/buster64
cpu: 2
memory: 512
interfaces:
- network_name: private_network
type: dhcp
auto_config: true
provisioner:
name: ansible
config_options:
defaults:
interpreter_python: /usr/bin/python3
ssh_connection:
pipelining: true
verifier:
name: ansible
---
- name: Prepare
hosts: all
become: true
pre_tasks:
- name: Mise à jour du cache APT
apt:
update_cache: true
cache_valid_time: 3600
roles:
- prometheus
- name: Installation d'Alertmanager
package:
name: prometheus-alertmanager
state: present
- name: Configuration de l'environnement d'Alertmanager
template:
src: alertmanager/alertmanager.env.j2
dest: /etc/default/prometheus-alertmanager
owner: root
group: root
mode: "u=rw,g=r,o=r"
notify: restart alertmanager
- name: Configuration d'Alertmanager
template:
src: alertmanager/alertmanager.yml.j2
dest: /etc/prometheus/alertmanager.yml
owner: prometheus
group: prometheus
mode: "u=rw,g=r,o="
notify: reload alertmanager
- name: Activation d'Alertmanager au démarrage
service:
name: prometheus-alertmanager
state: started
enabled: yes
- name: Ajout du job alertmanager dans Prometheus
copy:
src: prometheus/alertmanager.yml
dest: /etc/prometheus/conf.d/alertmanager.yml
owner: prometheus
group: prometheus
mode: "u=rw,go=r"
notify: reload prometheus
- name: Création du dossier des rules
file:
path: /etc/prometheus/rules.d
owner: prometheus
group: prometheus
mode: "u=rwx,g=rx,o="
state: directory
notify: reload prometheus
{{ ansible_managed | comment }}
ARGS="--web.listen-address='localhost:9093'"
# Run prometheus-alertmanager -h to view available options.
# --web.listen-address=":9093"
# Address to listen on for the web interface and API.
{{ ansible_managed | comment }}
# See https://prometheus.io/docs/alerting/configuration/ for documentation.
global:
# The smarthost and SMTP sender used for mail notifications.
smtp_smarthost: {{ alertmanager_smtp_host }}:{{ alertmanager_smtp_port }}
smtp_from: {{ alertmanager_smtp_from }}
smtp_auth_username: {{ alertmanager_smtp_username | to_json }}
smtp_auth_password: {{ alertmanager_smtp_password | string | to_json }}
# The directory from which notification templates are read.
templates:
- /etc/prometheus/alertmanager_templates/*.tmpl
# The root route on which each incoming alert enters.
route:
# The labels by which incoming alerts are grouped together. For example,
# multiple alerts coming in for cluster=A and alertname=LatencyHigh would
# be batched into a single group.
group_by: ['alertname', 'cluster', 'service']
# When a new group of alerts is created by an incoming alert, wait at
# least 'group_wait' to send the initial notification.
# This way ensures that you get multiple alerts for the same group that start
# firing shortly after another are batched together on the first
# notification.
group_wait: 30s
# When the first notification was sent, wait 'group_interval' to send a batch
# of new alerts that started firing for that group.
group_interval: 5m
# If an alert has successfully been sent, wait 'repeat_interval' to
# resend them.
repeat_interval: 3h
# A default receiver
receiver: default-receiver
# All the above attributes are inherited by all child routes and can
# overwritten on each.
# The child route trees.
routes:
- receiver: default-receiver
receivers:
- name: default-receiver
email_configs:
- to: {{ alertmanager_smtp_to }}
......@@ -3,7 +3,17 @@
name: prometheus
state: restarted
- name: restart alertmanager
service:
name: prometheus-alertmanager
state: restarted
- name: reload prometheus
service:
name: prometheus
state: reloaded
- name: reload alertmanager
service:
name: prometheus-alertmanager
state: reloaded
- import_tasks: prometheus.yml
tags: ['prometheus']
- name: Installation de Prometheus
package:
name: prometheus
state: present
- name: Configuration de l'environnement de Prometheus
template:
src: prometheus/prometheus.env.j2
dest: /etc/default/prometheus
owner: root
group: root
mode: "u=rw,g=r,o=r"
notify: restart prometheus
- name: Configuration de Prometheus
template:
src: prometheus/prometheus.yml.j2
dest: /etc/prometheus/prometheus.yml
owner: prometheus
group: prometheus
mode: "u=rw,g=r,o="
validate: promtool check config %s
notify: reload prometheus
- name: Création du répertoire des jobs
file:
path: /etc/prometheus/conf.d
owner: prometheus
group: prometheus
mode: "u=rwx,go=rx"
state: directory
- name: Activation de Prometheus au démarrage
service:
name: prometheus
state: started
enabled: yes
- name: Trigger Prometheus handlers
meta: flush_handlers
- name: Installation de Prometheus
package:
name: prometheus
state: present
- name: Configuration de l'environnement de Prometheus
template:
src: prometheus/prometheus.env.j2
dest: /etc/default/prometheus
owner: root
group: root
mode: "u=rw,g=r,o=r"
notify: restart prometheus
- name: Configuration de Prometheus
template:
src: prometheus/prometheus.yml.j2
dest: /etc/prometheus/prometheus.yml
owner: prometheus
group: prometheus
mode: "u=rw,g=r,o="
validate: promtool check config %s
notify: reload prometheus
- name: Activation de Prometheus au démarrage
service:
name: prometheus
state: started
enabled: yes
- name: Trigger Prometheus handlers
meta: flush_handlers
......@@ -27,6 +27,11 @@ rule_files:
# A list of scrape configurations.
scrape_configs:
- job_name: extra-config # This is a default value, it is mandatory.
file_sd_configs:
- files:
- conf.d/*.yml
# Grab metrics about prometheus itself
- job_name: prometheus
static_configs:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment