1
0

change prometheus_server role variable structure

This commit is contained in:
cuqmbr 2025-07-03 19:59:22 +03:00
parent 0363813807
commit 1b30ca221e
Signed by: cuqmbr
GPG Key ID: 1F62396D020F375C
5 changed files with 234 additions and 236 deletions

View File

@ -28,24 +28,19 @@ users:
openpgp:0xAD2BFD7F" openpgp:0xAD2BFD7F"
opendoas_settings: "permit nopass ansible" opendoas_settings: "permit nopass ansible"
prometheus_options: prometheus_settings:
config:
global: global:
alerting: alerting:
alertmanagers: alertmanagers:
- static_configs: - static_configs:
- targets: - targets:
- 192.168.0.252:9093 - 192.168.0.252:9093
rule_files:
- alerting_rules/*.yml
scrape_configs: scrape_configs:
- job_name: prometheus - job_name: prometheus
static_configs: static_configs:
- targets: - targets:
- 192.168.0.252:9090 - 192.168.0.252:9090
- job_name: node - job_name: node
static_configs: static_configs:
- targets: - targets:
@ -90,7 +85,6 @@ prometheus_options:
labels: labels:
env: common env: common
hostname: monitoring hostname: monitoring
- job_name: nginx - job_name: nginx
static_configs: static_configs:
- targets: - targets:
@ -100,43 +94,7 @@ prometheus_options:
env: common env: common
hostname: monitoring hostname: monitoring
alerting_rules:
prometheus_alertmanager_options:
global:
smtp_smarthost: mail.cuqmbr.xyz:587
smtp_require_tls: true
smtp_from: '"Homelab Alertmanager" <no-reply@cuqmbr.xyz>'
smtp_auth_username: no-reply
smtp_auth_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
31393866316539633838303936366464613935393933333338336531656239333361653664346637
3665316532336339633432303036626339363239343065630a326361306233656632653134643966
39663138303439323636666665653364396132333532383463626337653061356461643734336363
6266353533656566330a346536333836356131343832616631666330653462613436313062643330
61616664646439643839366630396137616533393664323965366630363566333632
templates:
- /etc/prometheus/alertmanager_templates/*.tmpl
route:
group_by:
- env
- hostname
group_wait: 30s
group_interval: 5m
repeat_interval: 1d
receiver: default
receivers:
- name: default
email_configs:
- to: notifications@cuqmbr.xyz
prometheus_alerting_rules:
groups: groups:
- name: DefaultMetrics - name: DefaultMetrics
rules: rules:
@ -243,6 +201,40 @@ prometheus_alerting_rules:
description: "Clock not synchronising. Ensure NTP is configured on this host.\n VALUE = {{'{{'}} $value {{'}}'}}\n LABELS = {{'{{'}} $labels {{'}}'}}" description: "Clock not synchronising. Ensure NTP is configured on this host.\n VALUE = {{'{{'}} $value {{'}}'}}\n LABELS = {{'{{'}} $labels {{'}}'}}"
prometheus_alertmanager_options:
global:
smtp_smarthost: mail.cuqmbr.xyz:587
smtp_require_tls: true
smtp_from: '"Homelab Alertmanager" <no-reply@cuqmbr.xyz>'
smtp_auth_username: no-reply
smtp_auth_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
31393866316539633838303936366464613935393933333338336531656239333361653664346637
3665316532336339633432303036626339363239343065630a326361306233656632653134643966
39663138303439323636666665653364396132333532383463626337653061356461643734336363
6266353533656566330a346536333836356131343832616631666330653462613436313062643330
61616664646439643839366630396137616533393664323965366630363566333632
templates:
- /etc/prometheus/alertmanager_templates/*.tmpl
route:
group_by:
- env
- hostname
group_wait: 30s
group_interval: 5m
repeat_interval: 1d
receiver: default
receivers:
- name: default
email_configs:
- to: notifications@cuqmbr.xyz
loki_settings: loki_settings:
config: config:
auth_enabled: false auth_enabled: false

View File

@ -1,59 +1,53 @@
--- ---
prometheus_options: prometheus_settings:
prometheus_default_settings:
config:
global: global:
# Set the scrape interval to every 15 seconds. Default is every 1 minute. # Set the scrape interval to every 15 seconds. Default is every 1 minute.
scrape_interval: 15s scrape_interval: 15s
# Evaluate rules every 15 seconds. The default is every 1 minute. # Evaluate rules every 15 seconds. The default is every 1 minute.
evaluation_interval: 15s evaluation_interval: 15s
# scrape_timeout is set to the global default (10s). # scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with # Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager). # external systems (federation, remote storage, Alertmanager).
external_labels: # external_labels:
monitor: 'example' # monitor: 'example'
# Alertmanager configuration # Alertmanager configuration
alerting: # alerting:
alertmanagers: # alertmanagers:
- static_configs: # - static_configs:
- targets: ['localhost:9093'] # - targets: ['localhost:9093']
# Load rules and evaluate them according to the global 'evaluation_interval'
# Load rules and evaluate them according to the global 'evaluation_interval'.
rule_files: rule_files:
- alerting_rules/*.yml - alerting_rules/*.yml
# A scrape configuration containing exactly one endpoint to scrape: # A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself. # Here it's Prometheus itself.
scrape_configs: scrape_configs:
# The job name is added as a label `job=<job_name>`. # The job name is added as a label `job=<job_name>`.
- job_name: 'prometheus' - job_name: 'prometheus'
# Override the global default and scrape targets from this job. # Override the global default and scrape targets from this job.
scrape_interval: 5s scrape_interval: 5s
scrape_timeout: 5s scrape_timeout: 5s
# metrics_path defaults to '/metrics' # metrics_path defaults to '/metrics'
# scheme defaults to 'http'. # scheme defaults to 'http'.
static_configs: static_configs:
- targets: ['localhost:9090'] - targets: ['localhost:9090']
- job_name: node - job_name: node
# If prometheus-node-exporter is installed, grab stats about the local # If prometheus-node-exporter is installed, grab stats about the local
# machine by default. # machine by default.
static_configs: static_configs:
- targets: ['localhost:9100'] - targets: ['localhost:9100']
alerting_rules:
prometheus_alerting_rules: # groups:
groups: # - name: ExampleRedisGroup
- name: ExampleRedisGroup # rules:
rules: # - alert: ExampleRedisDown
- alert: ExampleRedisDown # expr: redis_up{} == 0
expr: redis_up{} == 0 # for: 2m
for: 2m # labels:
labels: # severity: critical
severity: critical # annotations:
annotations: # summary: "Redis instance down"
summary: "Redis instance down" # description: "Whatever"
description: "Whatever"

View File

@ -1,5 +1,11 @@
--- ---
- name: Combine default and user settings, decrypt vault.
ansible.builtin.set_fact:
prometheus_settings: "{{ prometheus_default_settings |
ansible.builtin.combine(prometheus_settings, recursive=true) }}"
no_log: true
- name: Install prometheus apt package. - name: Install prometheus apt package.
ansible.builtin.apt: ansible.builtin.apt:
name: prometheus name: prometheus

View File

@ -1,4 +1,7 @@
--- ---
# Managed with Ansible # Managed with Ansible
{{ prometheus_alerting_rules | ansible.builtin.to_nice_yaml(indent=2) }} {{
prometheus_settings.alerting_rules |
ansible.builtin.to_nice_yaml(indent=2)
}}

View File

@ -1,4 +1,7 @@
--- ---
# Managed with Ansible # Managed with Ansible
{{ prometheus_options | ansible.builtin.to_nice_yaml(indent=2) }} {{
prometheus_settings.config |
ansible.builtin.to_nice_yaml(indent=2, width=80)
}}