Says that I already had a Hasura container running on cloud, so I want to monitor the Hasura container performance with Prometheus and Grafana.
From the Hasura official docs here, it says I need to set these env variables :
- HASURA_GRAPHQL_ENABLED_APIS=metadata,graphql,config,metrics
- HASURA_GRAPHQL_METRICS_SECRET=SOME_SECRET_KEY
I did set both of these in the docker-compose file :
graphql-engine:
image: hasura/graphql-engine:v2.18.0.cli-migrations-v3
restart: on-failure:1
ports:
- "8080:8080"
environment:
HASURA_GRAPHQL_METADATA_DATABASE_URL: MY_DB_URL
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set "false" to disable console
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "anonymous"
HASURA_GRAPHQL_ADMIN_SECRET: SOME_SECRET
## For Monitoring uses, with Prometheus and Grafana
HASURA_GRAPHQL_ENABLED_APIS: "metadata,graphql,config,metrics"
HASURA_GRAPHQL_METRICS_SECRET: "PROMETHEUSSECRET"
command:
- graphql-engine
- serve
Then I use this command to try to get the metrics value :
curl 'http://localhost:8080/v1/metrics' -H 'Authorization: Bearer PROMETHEUSSECRET'
But I received this error instead : {"code":"not-found","error":"resource does not exist","path":"$"}
Also this is my Prometheus config file :
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'hasura'
static_configs:
- targets: ['localhost:8080']