0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/.github/scripts/prometheus/prometheus.yml

31 lines
885 B
YAML
Raw Normal View History

Added prometheus and grafana services to docker compose (#21213) ref https://linear.app/tryghost/issue/ENG-1591/add-prometheus-and-grafana-services-to-docker-compose This commit adds 2 new services to the docker compose file to enable monitoring metrics from Ghost locally in real-time: 1. Prometheus - a service that scrapes Ghost's new `/metrics` endpoint introduced in this [commit](https://github.com/TryGhost/Ghost/commit/768336efad067241ca848027f4ac758148ca3e29). 2. Grafana - a service that consumes the metrics from prometheus and exposes them in a dashboard that you can view locally at `localhost:3000`. # Usage Both of these services are selectively enabled using docker compose [profiles](https://docs.docker.com/compose/how-tos/profiles/). This way, if you don't opt-in to using these monitoring tools, they won't start and consume resources on your host machine. To enable these services, enable the `monitoring` profile by either setting the `COMPOSE_PROFILES` environment variable to `monitoring`, or specifying the `--profile monitoring` CLI argument to any `docker compose ...` commands. I've found the easiest way to configure this in an 'always on' fashion is to create a `.env` file in the project's root directory and add `COMPOSE_PROFILES=monitoring` to it. As an added convenience, you can also set `COMPOSE_FILE=.github/scripts/docker-compose.yml`, which will allow you to run `docker compose ...` commands from the root directory without specifying the full path each time. # Intended for development only These services are meant for local development only, and are not configured for a production use-case. For example, the Grafana instance is configured to have _no authorization_ so you won't need a username/password to login at `localhost:3000`. Prometheus is also configured to scrape the metrics once every second, which is likely excessive for production use-cases, but may be useful for getting more granular metrics while e.g. load testing locally. # Dashboards The Grafana instance includes a default dashboard including most of the main default metrics provided by our prometheus client integration. The dashboard is defined in a JSON file at `.github/scripts/docker/grafana/dashboards/main-dashboard.json' and can be modified & committed to add new visualizations that will be available to anyone work on Ghost locally. You can also add other dashboards to the same directory for specific use-cases, which should be picked up and made available in the Grafana UI. [Read more](https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/view-dashboard-json-model/) about Grafana's JSON schema for dashboards.
2024-10-03 16:43:07 -05:00
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'ghost'
scrape_interval: 1s
static_configs:
- targets: ['host.docker.internal:9416']
metrics_path: '/metrics'
remote_write:
- url: http://grafana:3000/api/prom/push