Metrics via Prometheus
Enable metrics endpoint
By default the Prometheus metrics endpoint is disabled. To enable Prometheus metrics, configure the environment variable below:
HASURA_GRAPHQL_ENABLED_APIS=metadata,graphql,config,metrics
Secure the Prometheus metrics endpoint with a secret:
HASURA_GRAPHQL_METRICS_SECRET=<secret>
curl 'http://127.0.0.1:8080/v1/metrics' -H 'Authorization: Bearer <secret>'
The metrics endpoint should be configured with a secret to prevent misuse and should not be exposed over the internet.
Starting in v2.26.0
, Hasura GraphQL Engine exposes metrics with high-cardinality labels by default.
You can disable the cardinality of labels for metrics if you are experiencing high memory usage, which can be due to a large number of labels in the metrics (typically more than 10000).
Metrics exported
The following metrics are exported by Hasura GraphQL Engine:
Hasura Event Triggers Metrics
The following metrics can be used to monitor the performance of Hasura Event Triggers system:
hasura_event_fetch_time_per_batch_seconds
hasura_event_invocations_total
hasura_event_processed_total
hasura_event_processing_time_seconds
hasura_event_queue_time_seconds
hasura_event_trigger_http_workers
hasura_event_webhook_processing_time_seconds
hasura_events_fetched_per_batch
Subscription Metrics
The following metrics can be used to monitor the performance of subscriptions:
hasura_active_subscriptions
hasura_active_subscription_pollers
hasura_active_subscription_pollers_in_error_state
hasura_subscription_db_execution_time_seconds
hasura_subscription_total_time_seconds
Hasura cache request count
Tracks cache hit and miss requests, which helps in monitoring and optimizing cache utilization. You can read more about this here.
Name | hasura_cache_request_count |
Type | Counter |
Labels | status : hit | miss |
Hasura cron events invocation total
Total number of cron events invoked, representing the number of invocations made for cron events.
Name | hasura_cron_events_invocation_total |
Type | Counter |
Labels | status : success | failed |
Hasura cron events processed total
Total number of cron events processed, representing the number of invocations made for cron events. Compare this to
hasura_cron_events_invocation_total
. A high difference between the two metrics indicates high failure rate of the cron
webhook.
Name | hasura_cron_events_processed_total |
Type | Counter |
Labels | status : success | failed |
Hasura GraphQL execution time seconds
Execution time of successful GraphQL requests (excluding subscriptions). If more requests are falling in the higher buckets, you should consider tuning the performance.
Name | hasura_graphql_execution_time_seconds |
Type | Histogram Buckets: 0.01, 0.03, 0.1, 0.3, 1, 3, 10 |
Labels | operation_type : query | mutation |
Hasura GraphQL requests total
Number of GraphQL requests received, representing the GraphQL query/mutation traffic on the server.
Name | hasura_graphql_requests_total |
Type | Counter |
Labels | operation_type : query | mutation | subscription | unknown |
The unknown
operation type will be returned for queries that fail authorization, parsing, or certain validations. The
response_status
label will be success
for successful requests and failed
for failed requests.
Hasura HTTP connections
Current number of active HTTP connections (excluding WebSocket connections), representing the HTTP load on the server.
Name | hasura_http_connections |
Type | Gauge |
Labels | none |
Hasura one-off events invocation total
Total number of one-off events invoked, representing the number of invocations made for one-off events.
Name | hasura_oneoff_events_invocation_total |
Type | Counter |
Labels | status : success | failed |
Hasura one-off events processed total
Total number of one-off events processed, representing the number of invocations made for one-off events. Compare this
to hasura_oneoff_events_invocation_total
. A high difference between the two metrics indicates high failure rate of the
one-off webhook.
Name | hasura_oneoff_events_processed_total |
Type | Counter |
Labels | status : success | failed |
Hasura postgres connections
Current number of active PostgreSQL connections. Compare this to pool settings.
Name | hasura_postgres_connections |
Type | Gauge |
Labels | source_name : name of the databaseconn_info : connection url string (password omitted) or name of the connection url environment variablerole : primary | replica |
Hasura source health
Health check status of a particular data source, corresponding to the output of
/healthz/sources
, with possible values 0 through 3 indicating, respectively:
OK, TIMEOUT, FAILED, ERROR. See the Source Health Check API Reference
for details.
Name | hasura_source_health |
Type | Gauge |
Labels | source_name : name of the database |
Hasura WebSocket connections
Current number of active WebSocket connections, representing the WebSocket load on the server.
Name | hasura_websocket_connections |
Type | Gauge |
Labels | none |
- Uses wall-clock time, so it includes time spent waiting on I/O.
- Includes authorization, parsing, validation, planning, and execution (calls to databases, Remote Schemas).