Prometheus
NotesPrometheus is configured with a single YAML file. Keeping in line with the rest of the project, create a directory for it, outside the project:
mkdir -p ~/volumes/prometheusStart with a configuration that only scrapes Prometheus itself:
global:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
environment: dev
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['prometheus:9090']scrape_intervalis how often Prometheus fetches metrics, andevaluation_intervalhow often it checks alerting rules.external_labelsare added to everything this Prometheus sends elsewhere, such as alerts, which helps if you ever have more than one.targetsis a list ofhost:portaddresses to scrape. Prometheus is reached by its container name,prometheus.
For the metrics data itself, use a Podman volume, which avoids file permission problems, since the container runs as a different user:
podman volume create prometheus-volRun the container, attached to the monitoring network, with the configuration directory and data volume mounted, and the web interface on port 9090:
podman run -d --name prometheus --network monitoring-network -p 9090:9090 \
-v ~/volumes/prometheus:/etc/prometheus:Z \
-v prometheus-vol:/prometheus \
docker.io/prom/prometheus:v3.16.0The :Z on the configuration mount tells Podman to relabel the directory for SELinux, which Fedora and RHEL need, so the container is allowed to read it.
Open http://localhost:9090. Under Status, Target health, you’ll see Prometheus scraping itself. You can check the configuration file for mistakes with promtool, which is included in the image:
podman exec prometheus promtool check config /etc/prometheus/prometheus.ymlWhenever you change the configuration, restart Prometheus to load it:
podman restart prometheus