feat: Add Prometheus installation role and playbook
- Created Prometheus role with automated installation - Version: 2.48.1 - Configured remote_write to VictoriaMetrics (192.168.0.104:8428) - Added scrape configs for monitoring infrastructure - Created systemd service configuration - Successfully tested on 192.168.0.105
This commit is contained in:
80
roles/prometheus/templates/prometheus.yml.j2
Normal file
80
roles/prometheus/templates/prometheus.yml.j2
Normal file
@ -0,0 +1,80 @@
|
||||
# Ansible managed - do not edit manually
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
external_labels:
|
||||
monitor: 'pve-monitoring'
|
||||
environment: 'production'
|
||||
prometheus_replica: '{{ ansible_hostname }}'
|
||||
|
||||
# Alertmanager configuration (optional)
|
||||
alerting:
|
||||
alertmanagers:
|
||||
- static_configs:
|
||||
- targets: []
|
||||
|
||||
# Load rules once and periodically evaluate them
|
||||
rule_files:
|
||||
- "{{ prometheus_config_dir }}/rules/*.yml"
|
||||
|
||||
# Remote write to VictoriaMetrics
|
||||
remote_write:
|
||||
- url: "{{ victoriametrics_url }}"
|
||||
queue_config:
|
||||
max_samples_per_send: 10000
|
||||
capacity: 20000
|
||||
max_shards: 30
|
||||
metadata_config:
|
||||
send: true
|
||||
send_interval: 1m
|
||||
|
||||
# Scrape configurations
|
||||
scrape_configs:
|
||||
# Prometheus self-monitoring
|
||||
- job_name: 'prometheus'
|
||||
static_configs:
|
||||
- targets: ['localhost:{{ prometheus_port }}']
|
||||
labels:
|
||||
instance: 'prometheus'
|
||||
container: 'pvestandt6'
|
||||
|
||||
# VictoriaMetrics monitoring
|
||||
- job_name: 'victoriametrics'
|
||||
static_configs:
|
||||
- targets: ['{{ victoriametrics_host }}:{{ victoriametrics_port }}']
|
||||
labels:
|
||||
instance: 'victoriametrics'
|
||||
container: 'pvestandt5'
|
||||
|
||||
# Vault metrics
|
||||
- job_name: 'vault'
|
||||
metrics_path: '/v1/sys/metrics'
|
||||
params:
|
||||
format: ['prometheus']
|
||||
bearer_token: '{{ vault_token }}'
|
||||
static_configs:
|
||||
- targets: ['{{ vault_host }}:{{ vault_port }}']
|
||||
labels:
|
||||
instance: 'vault'
|
||||
container: 'pvestandt4'
|
||||
|
||||
# Git/Forgejo metrics
|
||||
- job_name: 'gitea'
|
||||
metrics_path: '/metrics'
|
||||
static_configs:
|
||||
- targets: ['{{ git_host }}:{{ git_port }}']
|
||||
labels:
|
||||
instance: 'git'
|
||||
container: 'pvestandt1'
|
||||
|
||||
# Node exporters - будем добавлять динамически
|
||||
- job_name: 'node'
|
||||
static_configs:
|
||||
{% if node_exporter_targets | length > 0 %}
|
||||
- targets:
|
||||
{% for target in node_exporter_targets %}
|
||||
- {{ target }}:9100
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
- targets: [] # Will be populated after installing node_exporter
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user