add the ansible playbooks for the monitoring stack
This commit is contained in:
30
ansible/roles/prometheus/templates/prometheus.service.j2
Normal file
30
ansible/roles/prometheus/templates/prometheus.service.j2
Normal file
@@ -0,0 +1,30 @@
|
||||
[Unit]
|
||||
Description=Prometheus Monitoring System
|
||||
Documentation=https://prometheus.io/docs/
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=monitoring
|
||||
Group=monitoring
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
ExecStart=/usr/local/bin/prometheus \
|
||||
--config.file=/etc/prometheus/prometheus.yml \
|
||||
--storage.tsdb.path=/var/lib/prometheus \
|
||||
--storage.tsdb.retention.time=15d \
|
||||
--web.listen-address=0.0.0.0:9090 \
|
||||
--web.enable-lifecycle \
|
||||
--log.level=info
|
||||
|
||||
SyslogIdentifier=prometheus
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
# Hardening
|
||||
NoNewPrivileges=true
|
||||
ProtectSystem=full
|
||||
ProtectHome=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
68
ansible/roles/prometheus/templates/prometheus.yml.j2
Normal file
68
ansible/roles/prometheus/templates/prometheus.yml.j2
Normal file
@@ -0,0 +1,68 @@
|
||||
global:
|
||||
scrape_interval: 30s
|
||||
evaluation_interval: 30s
|
||||
external_labels:
|
||||
monitor: 'home-infra'
|
||||
source: 'rpi'
|
||||
|
||||
scrape_configs:
|
||||
# Self-monitoring
|
||||
- job_name: 'prometheus'
|
||||
static_configs:
|
||||
- targets: ['localhost:9090']
|
||||
labels:
|
||||
instance: 'rpi-prometheus'
|
||||
|
||||
# SNMP targets (network devices)
|
||||
{% if snmp_targets is defined and snmp_targets | length > 0 %}
|
||||
- job_name: 'snmp'
|
||||
scrape_interval: 60s
|
||||
scrape_timeout: 30s
|
||||
static_configs:
|
||||
{% for target in snmp_targets %}
|
||||
- targets: ['{{ target.ip }}']
|
||||
labels:
|
||||
device: '{{ target.name }}'
|
||||
{% endfor %}
|
||||
metrics_path: /snmp
|
||||
relabel_configs:
|
||||
- source_labels: [__address__]
|
||||
target_label: __param_target
|
||||
- source_labels: [__param_target]
|
||||
target_label: instance
|
||||
- target_label: __address__
|
||||
replacement: localhost:9116
|
||||
params:
|
||||
module: [if_mib] # Default module, can be overridden per-target
|
||||
{% endif %}
|
||||
|
||||
# Node exporter targets (VMs with node_exporter)
|
||||
{% if node_exporter_targets is defined and node_exporter_targets | length > 0 %}
|
||||
- job_name: 'node'
|
||||
static_configs:
|
||||
{% for target in node_exporter_targets %}
|
||||
- targets: ['{{ target.ip }}:{{ target.port | default(9100) }}']
|
||||
labels:
|
||||
instance: '{{ target.name }}'
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
# Proxmox PVE exporter
|
||||
{% if proxmox_targets is defined and proxmox_targets | length > 0 %}
|
||||
- job_name: 'proxmox'
|
||||
scrape_interval: 60s
|
||||
static_configs:
|
||||
{% for target in proxmox_targets %}
|
||||
- targets: ['{{ target.ip }}:{{ target.port | default(9221) }}']
|
||||
labels:
|
||||
instance: '{{ target.name }}'
|
||||
{% endfor %}
|
||||
metrics_path: /pve
|
||||
params:
|
||||
module: [default]
|
||||
{% endif %}
|
||||
|
||||
# SNMP exporter self-metrics
|
||||
- job_name: 'snmp-exporter'
|
||||
static_configs:
|
||||
- targets: ['localhost:9116']
|
||||
Reference in New Issue
Block a user