prometheus.yml configuration used in this stack and how to extend it.
Full configuration
Configuration fields
How often Prometheus polls each target for metrics. A value of
15s means Prometheus sends an HTTP request to every configured target every 15 seconds and stores the returned time-series data.A list of scrape jobs. Each entry defines a named job and the targets Prometheus should poll.
A unique name for the scrape job. Prometheus attaches this value as the
job label on every metric it collects from the targets in this job. In this stack the job is named node-exporter.A list of static target groups. Each group specifies one or more host:port addresses that Prometheus will scrape.
The addresses Prometheus scrapes. The single target here is
node-exporter:9100.The hostname node-exporter resolves because Docker Compose creates an internal DNS entry for every service using its service name. Prometheus and node-exporter share the same Docker network, so node-exporter:9100 reaches the exporter without exposing anything on the host network.Docker Compose service
Theprometheus service in docker-compose.yml is defined as follows:
- image — uses the official
prom/prometheus:latestimage. - ports — maps host port
9090to container port9090, making the Prometheus web UI available athttp://localhost:9090. - volumes — mounts your local
prometheus/prometheus.ymlinto the container at the path Prometheus reads on startup. Editing the local file and restarting the container applies the new configuration.
Prometheus web UI
Once the stack is running, openhttp://localhost:9090 in your browser. From the UI you can:
- Run PromQL queries against collected metrics.
- Check the status of configured scrape targets under Status → Targets.
- Inspect loaded configuration under Status → Configuration.
Adding scrape targets
To scrape an additional service, append a new entry underscrape_configs. For example, to also scrape a service called my-app that exposes metrics on port 8080:
prometheus.yml, restart the Prometheus container for the change to take effect: