Explore: Metrics & Logs
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
Explore is a specialized interface within Grafana designed for ad-hoc data analysis and troubleshooting. It allows users to interactively query metrics and logs from various data sources without the need to create or modify persistent dashboards. This system provides a split-view capability to compare different time ranges, queries, or data sources side-by-side, facilitating rapid root-cause analysis and data exploration.
Sources: README.md:12-16
The Explore feature emphasizes the synergy between different telemetry types. It enables users to switch seamlessly from metrics to logs while preserving label filters, ensuring that the context of a specific investigation is maintained across different views. This is particularly effective for workflows that involve identifying an anomaly in a metric graph and immediately drilling down into the corresponding logs.
Sources: README.md:15-16, contribute/create-pull-request.md:118
Core Components and User Interface
Explore consists of several key UI components that manage the lifecycle of a query and its visualization. These include the Data Source Picker, the Query Editor (which often supports multiple modes like "Code" and "Builder"), and specialized visualization components for metrics and logs.
Query Editors
For data sources like Prometheus, the Explore interface provides two distinct editor types to accommodate different user expertise levels:
- Builder Mode: A visual interface where users can select metrics, apply label filters using dropdowns, and add operations through a structured UI.
- Code Mode: A text-based editor (often utilizing Monaco or similar) for writing raw queries (e.g., PromQL), featuring a "Metrics Browser" for discovering available telemetry.
Sources: e2e-playwright/various-suite/prometheus-editor.spec.ts:18-24, e2e-playwright/various-suite/prometheus-editor.spec.ts:181-185
Explore UI Workflow
The following diagram illustrates the typical flow of a user interacting with the Explore interface to query and visualize data.
Backend Instrumentation and Data Flow
The performance and health of the Explore system are monitored using internal instrumentation. Grafana utilizes the RED method (Requests, Errors, Duration) to measure the effectiveness of the data source queries initiated within Explore.
Telemetry Integration
Explore leverages three pillars of observability:
- Metrics: Quantifiable measurements (counters, gauges, histograms) prefixed with
grafana_to track system state and performance. - Logs: Structured records of events, warnings, and errors, often including a
traceIDfor correlation. - Traces: Distributed data tracking the flow of requests through the backend using OpenTelemetry.
Sources: contribute/backend/instrumentation.md:7-14, contribute/backend/instrumentation.md:90-95, contribute/backend/instrumentation.md:162-168
Correlation Sequence
This diagram shows how Explore correlates logs and traces during a debugging session.
Configuration and Management
The behavior of Explore and its associated data sources is managed through configuration pages. For Prometheus-based exploration, several settings directly impact the Explore experience.
| Feature | Description | File Context |
|---|---|---|
| Default Editor | Sets whether Explore opens in 'Code' or 'Builder' mode by default. | prometheus-config.spec.ts:36 |
| Metric Lookup | Can be disabled to improve performance in high-cardinality environments. | prometheus-config.spec.ts:43 |
| Incremental Querying | Enables querying only new data to optimize large time-range explorations. | prometheus-config.spec.ts:58 |
| Query Overlap | Defines the window for overlapping data in incremental queries. | prometheus-config.spec.ts:168 |
Sources: e2e-playwright/various-suite/prometheus-config.spec.ts:18-70, e2e-playwright/various-suite/prometheus-config.spec.ts:165-175
Development Standards for Explore
Contributors working on the Explore feature must adhere to specific frontend and state management guidelines to ensure consistency across the complex analysis UI.
- Component Structure: Large components must be split into smaller, focused sub-components. Functional components using function declarations are preferred over arrow functions.
- Styling: Use Emotion for styling; SASS is deprecated for new development.
- State Management: Direct state mutation is prohibited. Redux actions and selectors must be used instead of direct backend calls from components.
- Testing: End-to-end testing for Explore features is conducted using Playwright, focusing on interactions like editor toggling, metrics browser usage, and option configuration.
Sources: contribute/style-guides/frontend.md:7-12, contribute/style-guides/frontend.md:213-219, contribute/create-pull-request.md:52-58, e2e-playwright/various-suite/prometheus-editor.spec.ts:74-82
Summary
Explore: Metrics & Logs serves as the primary investigative environment in Grafana, combining ad-hoc querying capabilities with deep telemetry integration. By supporting multiple editor modes and providing seamless transitions between metrics and logs, it enables developers and operators to diagnose issues quickly. The system is built on a foundation of strict frontend standards and robust backend instrumentation, ensuring that the exploration process itself is performant and observable.