Add Postgres monitoring for Prometheus
This commit is contained in:
parent
653aef8c38
commit
4054f1a02e
4 changed files with 27 additions and 0 deletions
|
|
@ -11,6 +11,9 @@ prometheus_targets:
|
|||
grafana:
|
||||
- targets:
|
||||
- raspberry-pi-1.kleinendorst.info:3000
|
||||
postgres:
|
||||
- targets:
|
||||
- raspberry-pi-1.kleinendorst.info:9187
|
||||
prometheus_web_listen_address: 127.0.0.1:9090
|
||||
prometheus_scrape_configs:
|
||||
- job_name: "prometheus"
|
||||
|
|
@ -25,6 +28,10 @@ prometheus_scrape_configs:
|
|||
file_sd_configs:
|
||||
- files:
|
||||
- "{{ prometheus_config_dir }}/file_sd/grafana.yml"
|
||||
- job_name: "postgres"
|
||||
file_sd_configs:
|
||||
- files:
|
||||
- "{{ prometheus_config_dir }}/file_sd/postgres.yml"
|
||||
prometheus_alertmanager_config:
|
||||
- static_configs:
|
||||
- targets:
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
- name: Register current user in a variable
|
||||
ansible.builtin.set_fact:
|
||||
container_user: "{{ whoami.stdout }}"
|
||||
- name: Set default podman_simple_container_volumes if not provided
|
||||
ansible.builtin.set_fact:
|
||||
podman_simple_container_volumes: "{{ podman_simple_container_volumes | default([]) }}"
|
||||
- name: Create mount directories
|
||||
ansible.builtin.file:
|
||||
path: "/home/{{ container_user }}/{{ item.name }}"
|
||||
|
|
|
|||
|
|
@ -51,3 +51,19 @@
|
|||
- ssl_key_file=/var/lib/postgresql/privkey.pem
|
||||
podman_container_env:
|
||||
POSTGRES_PASSWORD: "{{ postgres_password }}"
|
||||
- name: Create the postgres prometheus exporter container
|
||||
ansible.builtin.include_role:
|
||||
name: podman-container
|
||||
apply:
|
||||
become: true
|
||||
become_user: "{{ postgres_unix_username }}"
|
||||
vars:
|
||||
podman_container_name: postgres-prometheus-exporter
|
||||
podman_container_image: quay.io/prometheuscommunity/postgres-exporter
|
||||
podman_container_tag: "{{ postgres_prometheus_exporter_version }}"
|
||||
podman_container_publish:
|
||||
- 0.0.0.0:9187:9187
|
||||
podman_container_env:
|
||||
DATA_SOURCE_URI: "postgres.kleinendorst.info:5432/postgres"
|
||||
DATA_SOURCE_USER: "postgres"
|
||||
DATA_SOURCE_PASS: "{{ postgres_password }}"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
---
|
||||
postgres_unix_username: postgres
|
||||
postgres_version: 17-alpine
|
||||
postgres_prometheus_exporter_version: v0.15.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue