Frequently Asked Questions¶
Why don't I see any metrics after installing the app?¶
Metrics are only recorded when GraphQL queries are executed against the /api/graphql/ endpoint. Send a test query and then check the metrics at Nautobot's default /metrics/ endpoint.
If metrics still don't appear, verify that:
- The app is listed in
PLUGINSin yournautobot_config.py. - Nautobot was restarted after installation.
- The
graphql_metrics_enabledsetting isTrue(the default).
How do I configure Prometheus to scrape this endpoint?¶
Add the following to your prometheus.yml:
scrape_configs:
- job_name: "nautobot-graphql"
metrics_path: "/metrics/"
static_configs:
- targets: ["nautobot-host:8080"]
No authentication is required — Nautobot's /metrics/ endpoint bypasses DRF.
What is the performance impact of this app?¶
The basic metrics (request count, duration, errors) add negligible overhead since they only instrument the root resolver.
Enabling track_query_depth and track_query_complexity adds a small amount of overhead to parse the query AST after resolution. This is typically sub-millisecond.
Enabling track_field_resolution instruments every field resolver in every query. This can add measurable overhead for complex queries with hundreds of fields. It is recommended to leave this disabled in production and only enable it for short-term debugging.
How does this work with multiple Nautobot worker processes?¶
Set the PROMETHEUS_MULTIPROC_DIR environment variable to a writable directory before starting Nautobot:
The prometheus_client library will use shared files in this directory to aggregate metrics across all worker processes. Nautobot's /metrics/ endpoint automatically handles multiprocess aggregation.
Why does the app monkey-patch GraphQLDRFAPIView?¶
Nautobot 3.x's GraphQLDRFAPIView.init_graphql() has a bug: when self.middleware is None (the default), it does not load middleware from the GRAPHENE["MIDDLEWARE"] Django setting. The app patches this method during AppConfig.ready() to ensure configured Graphene middleware is properly loaded.
How do I enable GraphQL query logging?¶
Set query_logging_enabled to True in your PLUGINS_CONFIG:
Optionally enable log_query_body and log_query_variables to include the query text and variables in each log entry. See Query Logging for details on routing logs to external systems.
Why aren't my query logs appearing?¶
The logging middleware uses a dedicated logger (nautobot_graphql_observability.graphql_query_log) that writes to stderr by default. If you have a custom Django LOGGING configuration that suppresses loggers not explicitly listed, you may need to add an entry for this logger. See Routing Logs to External Systems.
Can I use metrics and logging independently?¶
Yes. The two middlewares are independent:
- Set
graphql_metrics_enabled: Trueandquery_logging_enabled: Falsefor metrics only. - Set
graphql_metrics_enabled: Falseandquery_logging_enabled: Truefor logging only. - Enable both for full observability.
Can I use this app without Nautobot?¶
The PrometheusMiddleware and GraphQLQueryLoggingMiddleware classes are standard Graphene middlewares. While this Nautobot app handles the automatic setup and configuration, the middlewares themselves could be used in any Graphene-based project by manually adding them to your GRAPHENE["MIDDLEWARE"] setting.