r/vmalert: Deploy vmalert

`vmalert` is a component of Victoria Metrics. It handles alerting and
recording rules, periodically executing queries and dispatching alerts
or writing aggregated data back to the TSDB.
btop
Dustin 2022-08-10 19:45:08 -05:00
parent 0dab3afc85
commit b3403268a8
6 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,2 @@
vmalert_rules:
groups: []

View File

@ -0,0 +1,9 @@
- name: restart vmalert
service:
name: vmalert
state: restarted
- name: reload vmalert
uri:
url: http://[::1]:8880/-/reload
changed_when: true

View File

@ -0,0 +1,59 @@
- name: ensure victoria metrics config directory exists
file:
path: /etc/victoria-metrics
mode: u=rwx,go=rx
owner: root
group: root
state: directory
tags:
- config
- name: ensure vmalert rules directory exists
file:
path: /etc/victoria-metrics/rules
mode: u=rwx,go=rx
owner: root
group: root
state: directory
tags:
- config
- name: ensure vmalert alert rules are configured
copy:
dest: /etc/victoria-metrics/rules/alerts.yml
content: |+
{{ vmalert_rules | to_nice_yaml(indent=2) }}
mode: u=rw,go=r
owner: root
group: root
notify:
- reload vmalert
tags:
- config
- alerts-config
- name: ensure vmalert environment variables are set
template:
src: vmalert.sysconfig.j2
dest: /etc/sysconfig/vmalert
mode: u=rw,go=r
owner: root
group: root
notify:
- restart vmalert
tags:
- config
- name: ensure vmalert starts at boot
service:
name: vmalert
enabled: true
tags:
- service
- name: flush handlers
meta: flush_handlers
- name: ensure vmalert is running
service:
name: vmalert
state: started
tags:
- service

View File

@ -0,0 +1,7 @@
- block:
# - import_tasks: install.yml
# tags:
# - install
- import_tasks: deploy.yml
tags:
- vmalert

View File

@ -0,0 +1,12 @@
{% if vmalert_datasource_url|d %}
datasource_url={{ vmalert_datasource_url }}
{% endif %}
{% if vmalert_notifier_url|d %}
notifier_url={{ vmalert_notifier_url }}
{% endif %}
{% if vmalert_remote_read_url|d %}
remoteRead_url={{ vmalert_remote_read_url }}
{% endif %}
{% if vmalert_remote_write_url|d %}
remoteWrite_url={{ vmalert_remote_write_url }}
{% endif %}

View File

@ -6,3 +6,7 @@
- hosts: vmagent
roles:
- vmagent
- hosts: vmalert
roles:
- vmalert