You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.4 KiB

- name: Set up Prometheus
hosts: lotus-land-story
tasks:
- name: Install host exporters
ansible.builtin.apt:
pkg:
- prometheus-node-exporter
- prometheus-postgres-exporter
state: present
# /usr/share/doc/prometheus-postgres-exporter/README.Debian
- name: Configure postgres-exporter
ansible.builtin.lineinfile:
dest: /etc/default/prometheus-postgres-exporter
regexp: '^DATA_SOURCE_NAME='
line: "DATA_SOURCE_NAME='user=prometheus host=/run/postgresql dbname=postgres'"
state: present
- name: Create Prometheus dir
ansible.builtin.file:
path: /mnt/lotus-land-story/prometheus
state: directory
mode: "0755"
- name: Prometheus config
ansible.builtin.copy:
dest: /mnt/lotus-land-story/prometheus/prometheus.yml
content: |
global:
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: node
static_configs:
- targets: ['host.docker.internal:9100']
- job_name: 'docker'
static_configs:
- targets: ['host.docker.internal:9323']
- job_name: caddy
static_configs:
- targets: ['host.docker.internal:2019']
- job_name: 'grafana'
static_configs:
- targets: ['host.docker.internal:3000']
- job_name: 'postgres'
static_configs:
- targets: ['host.docker.internal:9187']
mode: "0644"
- name: Run Prometheus
community.docker.docker_compose:
project_name: prometheus
remove_orphans: true
definition:
version: "3.3"
services:
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- /mnt/lotus-land-story/prometheus:/etc/prometheus
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
# vim: ft=yaml.ansible