Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# FP_PROMETHEUS_PORT=9090
# FP_PUSH_GATEWAY_PORT=8081
# FP_API_PORT=8082
# FP_GRAFANA_PORT=9012
# FP_API_PORT=8082
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

Quickly set up metrics with Prometheus and an Aggregation Gateway, so you can push metrics to Prometheus locally with [Autometrics](https://autometrics.dev/).

Test out Autometrics Grafana dashboards as well.

> TODO!!! Instructions

## Setup

To run, you need docker (and docker compose) installed locally, and a local copy of this repository.
Expand All @@ -19,6 +23,7 @@ docker compose up --build
- Prometheus runs locally on `localhost:9090`, and loads autometrics alerting rules from `prometheus/autometrics.rules.yml`
- Prometheus will try to scrape `localhost:8080/metrics` by default. You can change this under `scrape_configs` in `prometheus/prometheus.yml`
- The aggregation gateway runs on `localhost:8081`
- Grafana runs on `localhost:9011` and does not require a username/password to log in
- An API runs on `localhost:8082` and will proxy requests to `/metrics` to the aggregation gateway, setting proper CORS headers so you can push metrics from the browser

Prometheus will scrape the aggregation gateway every 5 seconds, but you can change this in the `prometheus/prometheus.yml` config file.
Expand All @@ -31,9 +36,14 @@ You can configure the ports on which services are exposed by modifying the `.env

- `FP_PROMETHEUS_PORT` - The port that Prometheus runs on
- `FP_PUSH_GATEWAY_PORT` - The port that the aggregation gateway runs on
- `FP_GRAFANA_PORT` - The port that Grafana runs on
- `FP_API_PORT` - The port that the api proxy to the aggregation gateway port runs on

To configure the scrape interval, modify the `prometheus/prometheus.yml` file
To configure the Prometheus scrape interval, modify the `prometheus/prometheus.yml` file

To load the Grafana Autometrics dashboards, go to Grafana, and import the JSON files located in this repo under `./grafana/dashboards`. These are copy-pasted from the autometrics-shared repo, see [here](https://github.com/autometrics-dev/autometrics-shared#dashboards).

(In a future version, we will try to autoload these dashboards.)

## Test it out

Expand All @@ -43,7 +53,7 @@ Once you've spun up the containers, you can push metrics to the api that's sitti
echo '
http_requests_total{result="ok", function="curl", module=""} 1027
http_errors_total{result="error", function="curl", module=""} 6
' | curl --data-binary @- http://localhost:8063/metrics/
' | curl --data-binary @- http://localhost:8062/metrics/

```

Expand Down
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ services:
env_file:
# NOTE: "Last in wins" if there are duplicate env vars across multiple files
- ./.env

grafana:
image: grafana/grafana
ports:
- "${FP_GRAFANA_PORT:-9011}:9011"
# FIXME - Because the dashboard json require an input to populate "uid": "${DS_PROMETHEUS}" field,
# we cannot autoload dashboard from this path, unfortunately!
# environment:
# GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: "/var/lib/grafana/dashboards/Autometrics Overview.json"
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
# FIXME - This encounters the same error described above re: autoloading dashboards
#
# - ./grafana/dashboards:/var/lib/grafana/dashboards

api:
build: ./api
ports:
Expand All @@ -33,3 +50,4 @@ services:
- DEBUG=http-proxy-middleware*
volumes:
prometheus_data:
grafana_data:
Loading