Grafana: Queries, Explore and Drilldown
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
Checked on 2026-11-09 against Grafana 13.3.x.
To do this by hand, follow Explore Metrics and Explore Logs and Traces.
A dashboard is only as good as its queries, and an incident is only as short as the time it takes to ask the next question. Grafana separates the two jobs: the panel query editor is where a question is made permanent (a chart on a dashboard, a condition in an alert rule), and Explore is where a question is asked once, refined and thrown away or promoted. The Drilldown apps go one step further and let you navigate telemetry without writing a query at all. This page covers all three, plus the handful of query options whose defaults silently change the numbers on a chart. The data sources behind the queries are in Data Sources; what happens to the result before it is drawn is in Transformations and Expressions.
The path of a query
A panel holds one or more queries (labelled A, B, C and so on, up to 26 per panel). Each query goes to its data source; the result comes back as data frames (tables of typed fields) and flows through transformations to the visualization. The Dashboard data source can feed the result of one panel into another panel.
The dotted arrows are the two controls that matter when a chart looks wrong: the query options change the request, and the query inspector shows the request and the frames that came back.
Source: Grafana: Query and transform data.
The query editor
Each data source plugin brings its own editor, so features vary: Prometheus and Loki offer a Builder (pick the metric, label filters and operations from lists) and a Code mode (type PromQL or LogQL with completion), SQL data sources offer a builder and a code editor, and TestData offers a scenario picker. Use the builder to learn the language and for simple queries; switch to code for anything the builder cannot show.
In the panel editor, the sidebar lists the queries, expressions and transformations as cards with indicators for errors, hidden and disabled items. Practical operations:
-
Queries are labelled A, B, C; drag the cards to reorder, and use the card actions to duplicate, hide or delete a query. Hide keeps the query from being sent, which is a quick way to find out which of several queries makes a panel slow.
-
Multi-select (Shift-click selects a range) allows changing the data source of several queries at once, handy when a dashboard moves from one Prometheus to another.
-
The buttons Data and Alerts switch between the data pipeline and creating an alert rule from the same query, which is the shortest way from a chart to an alert (see Alerting Fundamentals).
-
Saved queries (store a query and reuse it in dashboards, Explore and annotations) are a Grafana Enterprise and Grafana Cloud feature, with a limit of 1,000 saved queries; they are not validated when saved.
Verify in the lab: create a panel on the Prometheus data source with the query
sum by (status) (rate(http_server_requests_seconds_count{application="bookshelf"}[$__rate_interval]))
then run the load generator and watch the lines move. $__rate_interval is the variable to use inside rate(): it is
at least four scrape intervals (it is max($__interval + scrape_interval, 4 * scrape_interval)), which keeps at least two samples inside
the window. The PromQL itself is in Prometheus Cheat Sheet.
Source: Grafana: Navigate the query editor and
Grafana: Prometheus template variables ($__rate_interval).
Query options
Options in the Query options button of the editor footer apply to the current panel only. They are the answer to the most common support question, "why does the same query give different numbers in two panels?".
| Option | What it does and what goes wrong |
|---|---|
Max data points |
Caps the number of points a series returns; the data source aggregates when the query would return more. The default is the width of the panel in pixels, so resizing a panel, or opening it in view mode, can change the result. Because transformations, reducers and expressions work on the returned points, a different cap can change a calculated number such as a mean. Set a fixed value when a number must be reproducible. |
Min interval |
A floor for the automatic interval, typically set to the scrape interval. A larger value returns coarser data. For Prometheus it corresponds to the minimum step, which can shift the query range. |
Interval |
The time span of one aggregation window, exposed as |
Relative time |
Overrides the dashboard time range for one panel: |
Time shift |
Moves the panel’s range relative to the time picker, for example to compare with last week. |
Cache timeout |
Shown only when the data source supports a query cache (Enterprise and Cloud, see the data sources page); overrides the default timeout in seconds. |
Two monitoring consequences. First, a "last 5 minutes" Stat panel on a dashboard whose range is six hours is the right way to show a current value next to a trend, and it is also a way to confuse a reader if the panel title does not say so: put the override in the title. Second, never compare two panels whose max data points or interval differ without noticing: a latency average over 15-second windows and one over 5-minute windows disagree by design.
Source: Grafana: Query options.
Sharing one query between panels
A dashboard with a Stat, a Time series and a Table of the same data would send three identical queries. The Dashboard data source (selected as the data source of the second and third panel) reuses the complete result of a source panel in the same dashboard, optionally only its annotations, and transformations then reshape it per panel. The cost is a dependency: change or delete the source panel and the dependent panels break. It is available only while editing a dashboard panel and cannot be used with server-side expressions.
Source: Grafana: Special data sources.
The query inspector
Inspect > Query (the button Inspect queries in the editor footer, or the panel menu) opens the inspector, the first tool to use when a panel is empty or suspicious. Its tabs: Stats (query time, processing time, amount of data), Query (the raw request and response), JSON (the data frame, or the panel JSON) and Data (the returned table, sortable, downloadable as CSV), plus an Error tab when the query failed. In Explore the inspector opens at the bottom of the page after a query runs.
A practical routine for "the panel shows no data": inspect the request, copy the query that was really sent (with variables
and $__interval replaced) into Explore, and run it there; if Explore also returns nothing, the problem is the data or the
data source, not the panel.
Explore
Explore is the ad hoc query tool. Open it from Explore in the left-hand menu, or from a panel’s menu to start from that panel’s query; choose a data source, write a query and select Run query. You need the Editor or Admin basic role (or the data sources explore role); with Enterprise, role-based access control can grant it separately. Explore shows graph and table views for data sources that support them, and a Logs or Trace view for the others.
What it offers beyond the panel editor:
-
Split view duplicates the query into two side-by-side panes, each with its own data source, query or filters, with buttons to synchronise the two time pickers. Compare staging and production, or a metric next to its logs, without leaving the page.
-
Query history lists the queries you ran in Explore, which can be added to saved queries (Enterprise and Cloud).
-
Share creates a short link of the form
/goto/<uid>. A drop-down next to it chooses between a relative time range (the recipient sees data from "the last hour" whenever they open it) and an absolute one (the recipient sees exactly your data), which matters when pasting a link in an incident channel. The browser URL of Explore also encodes the panes, so it can be bookmarked; very long URLs may be truncated by chat tools, in which case Explore warns and loads a default state, so prefer the short link. -
Add turns the exploration into a dashboard panel (and offers incident declaration and other actions where the corresponding Grafana Cloud features are available). This is the normal way to build a dashboard panel: find the right query in Explore, then promote it.
The logs and trace integrations are where Explore pays back during an incident:
-
Logs. A volume graph of the log lines over the time range, log context (the lines around a hit, with the label filters and time window adjustable, or opened in a split pane), live tail (new lines stream in; pause, clear or stop), and the log details with fields to filter on. For Loki, fields are grouped as indexed labels, parsed fields and structured metadata. When you switch the data source from Prometheus to Loki, matching labels carry over, so the query retrieves the log streams of the same service.
-
Traces. For Tempo, Jaeger and Zipkin a span has buttons to open the related logs or metrics in a split view (configured on the data source, see Data Sources, Tempo), span filters (service name, span name, duration, tags) with Show matches only, and the service graph with rate, error and duration metrics when its requirements are configured.
-
Exemplars. Prometheus exemplars (a trace ID attached to a sample) appear on a time series as points that link to the trace. They need a Prometheus that stores exemplars, an application that exposes them and an
exemplarTraceIdDestinationsentry on the data source; they are not available for instant queries.
Sources: Grafana: Get started with Explore, Grafana: Logs in Explore, Grafana: Traces in Explore and Grafana: Prometheus query editor (exemplars).
Correlations
Correlations are links Explore adds to results: each maps data from one data source to a query in another data source
(shown in a split view) or to an external URL (opened in a new tab). They are configured under Administration > Plugins and
data > Correlations or directly in Explore, can be provisioned, and the links appear in the Logs and Table visualizations.
Use them where a derived field or exemplar cannot reach: from a Bookshelf log line with a book_id field to a PostgreSQL query for that book,
from a Prometheus series to the Loki stream with the same pod label.
Source: Grafana: Correlations.
Drilldown apps
The Drilldown apps (previously named Explore Metrics, Explore Logs and Explore Traces) let you move through telemetry without writing PromQL, LogQL or TraceQL:
-
Metrics Drilldown browses Prometheus-compatible metrics: it picks a suitable visualization per metric type, splits a metric by its labels to surface the odd one out, shows related metrics and links to related logs.
-
Logs Drilldown shows log volumes per service, lets you filter by labels, fields and patterns, finds related logs and tracks changes over time, with a link to Explore on every panel when you want to write the LogQL.
-
Traces Drilldown uses RED metrics derived from traces to investigate errors and latency, saves filter configurations to return to an investigation, and needs no TraceQL.
-
Profiles Drilldown shows high-level service performance from profiling data, to find the processes to optimise.
The documentation pages do not state a release status or the requirements per app, so check the access and install guide of each app for your instance. The pattern to use them: start in a Drilldown app when you do not know which metric, label or service is the culprit; switch to Explore when you know what to ask; build or edit a dashboard panel when the question will be asked again. Saved queries show a Drilldown button for Loki, Mimir, Tempo and Pyroscope queries in Enterprise and Cloud.
Source: Grafana: Drilldown apps with its Metrics, Logs, Traces and Profiles pages.
Notebooks
Notebooks combine text, queries and visualizations in one document (investigations, handoffs, post-incident reviews). They are
a public preview in Grafana 13.3: limited support, breaking changes possible, enabled with the dashboard.notebooks feature toggle. Viewers read them; Editors and Admins
create and change them; sharing a link does not grant access to the data behind it. Because of the preview status, keep the
post-incident narrative in a place that does not depend on the feature (see
Notifications and Incident Response).
Source: Grafana: Notebooks.
A lab walk-through
-
Start the
grafanaprofile and the load generator (see Hands-on Lab). -
In Explore, with Prometheus, run the 5xx ratio of the Bookshelf, then split the view and run the same time range on Loki for error logs. Use the sync button so both panes share the time.
-
Create a short link with a relative and another with an absolute time range; open both after an hour and note that only the relative one has moved.
-
Open the query inspector and read the Stats tab; change Max data points to 50 and then to 2000 and see how the number of points returned changes.
-
Open Metrics Drilldown, pick
http_server_requests_seconds_count, split bystatusand find the 5xx series without typing PromQL.
In the books
The Grafana books describe the panel query editor and Explore of their time (Grafana 8 to 10). The query options and Explore’s split view and logs views are still there, with a different layout: the panel editor now has a sidebar with queries, expressions and transformations, and the Explore apps were renamed Drilldown. The navigation from a metric to its logs and to a trace, which the stack-oriented books walk through by hand, is available today through exemplars, derived fields, trace-to-logs links and correlations.