0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2024-12-30 22:34:01 -05:00
ghost/.github
Chris Raible 8b26b52513
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](768336efad).
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 14:43:07 -07:00
..
actions/restore-cache Update actions/cache action to v4 2024-04-18 12:36:07 +02:00
hooks Removed pre-push hook 2023-07-17 17:10:58 +02:00
ISSUE_TEMPLATE Switched our old style bug report template to a form 2021-11-12 10:30:08 +00:00
scripts Added prometheus and grafana services to docker compose (#21213) 2024-10-03 14:43:07 -07:00
workflows Configured i18n tests to run for sodo-search (#21199) 2024-10-03 07:56:02 -05:00
CODE_OF_CONDUCT.md Added contributor code of conduct 2023-10-18 12:10:05 +02:00
codecov.yml Updated workflow for code coverage 2023-07-06 09:24:45 +02:00
CONTRIBUTING.md Improved commit message docs in contributing guide 2022-10-13 09:56:14 +07:00
FUNDING.yml Update FUNDING.yml 2020-07-28 13:19:20 +07:00
PULL_REQUEST_TEMPLATE.md Removed GitHub Copilot for PRs templating value 2023-11-20 11:43:58 +01:00
SUPPORT.md