feat: add PostgreSQL infrastructure for App2
- Add PostgreSQL role for installing and configuring PostgreSQL 17 - Add postgres_exporter role for PostgreSQL metrics collection - Add deploy-postgres-app2.yml playbook for deployment - Configure test database 'testdb' with user 'testuser' - Set up postgres_exporter user for monitoring - Include firewall configuration for PostgreSQL (5432) and postgres_exporter (9187) - Follow existing role structure pattern from node_exporter
This commit is contained in:
35
playbooks/add-postgres-to-prometheus.yml
Normal file
35
playbooks/add-postgres-to-prometheus.yml
Normal file
@ -0,0 +1,35 @@
|
||||
---
|
||||
- name: Add PostgreSQL exporter to Prometheus
|
||||
hosts: 192.168.0.105
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
- name: Add postgres_exporter scrape config
|
||||
blockinfile:
|
||||
path: /etc/prometheus/prometheus.yml
|
||||
insertafter: ' # Nginx metrics via nginx-prometheus-exporter'
|
||||
block: |2
|
||||
# PostgreSQL metrics via postgres_exporter
|
||||
- job_name: 'postgres-app2'
|
||||
scrape_interval: 15s
|
||||
scrape_timeout: 10s
|
||||
static_configs:
|
||||
- targets: ['192.168.0.111:9187']
|
||||
labels:
|
||||
instance: 'app2'
|
||||
service: 'postgresql'
|
||||
job: 'postgres'
|
||||
metric_relabel_configs:
|
||||
- source_labels: [__address__]
|
||||
target_label: instance
|
||||
- source_labels: [__address__]
|
||||
regex: '([^:]+):\\d+'
|
||||
replacement: '${1}'
|
||||
target_label: host
|
||||
marker: "# {mark} ANSIBLE MANAGED BLOCK - postgres_exporter"
|
||||
backup: yes
|
||||
|
||||
- name: Reload Prometheus
|
||||
systemd:
|
||||
name: prometheus
|
||||
state: reloaded
|
||||
Reference in New Issue
Block a user