Skip to main content

Core Concepts

This guide covers the essential concepts you need to understand to work effectively with Grafana.

Dashboards

Dashboards are the primary organizational unit in Grafana. A dashboard is a collection of panels arranged in a grid layout that provides a unified view of your data.

Dashboard Structure

Dashboards are stored as JSON and include:

Key Dashboard Features

Grid Layout

Panels are positioned on a 24-column grid with configurable height. Drag and drop to rearrange, resize by dragging corners.

Version Control

Every save creates a new version. Access dashboard history to view changes, compare versions, and restore previous states.

Folders

Organize dashboards into folders for better structure and access control via the folder service (pkg/services/folder).

Variables

Template variables create dynamic, reusable dashboards. Variables appear as dropdowns in the dashboard header.

Panels

Panels are the building blocks of dashboards. Each panel displays data from one or more queries using a specific visualization type.

Panel Types

Grafana includes many built-in panel types:
  • Time Series: Line, bar, and area charts for time-series data
  • Stat: Single value with optional graph sparkline
  • Gauge: Radial or linear gauge for showing values against thresholds
  • Bar Chart: Categorical data visualization
  • Table: Tabular data with sorting and filtering
  • Logs: Log line visualization with filtering and highlighting
  • Heatmap: Density visualization for histogram data

Panel Data Flow

Field Configuration

Field configuration controls how data values are displayed:

Data Sources

Data sources are the connection between Grafana and your data. Each data source represents a database, API, or service that Grafana can query.

Data Source Types

Grafana supports numerous data sources: Time Series Databases:
  • Prometheus
  • InfluxDB
  • Graphite
  • TimescaleDB
Logging Systems:
  • Loki
  • Elasticsearch
Relational Databases:
  • PostgreSQL
  • MySQL
  • Microsoft SQL Server
Cloud Services:
  • AWS CloudWatch
  • Azure Monitor
  • Google Cloud Monitoring

Data Source Plugin Architecture

Data Source Configuration

Data sources are configured via the API:

Queries

Queries define what data to retrieve from data sources. Each panel can have multiple queries that are executed and combined.

Query Model

Query Execution Flow

1

Query Request

Panel creates a DataQueryRequest with queries, time range, and other parameters.
2

Data Source Query

Data source plugin executes the query against the backend database or API.
3

Data Frames

Results are returned as DataFrame objects - a columnar data structure.
4

Transformations

Optional data transformations are applied (merge, filter, calculate fields, etc.).
5

Field Config

Field configuration (units, thresholds, colors) is applied to the data.
6

Rendering

The panel plugin renders the processed data according to its visualization type.

Time Ranges

Time ranges control what data is displayed. Grafana supports both relative and absolute time ranges.

Time Range Types

Common Time Range Examples

  • now-5m to now: Last 5 minutes
  • now-1h to now: Last hour
  • now-24h to now: Last 24 hours
  • now/d to now/d: Today so far
  • now-7d/d to now-1d/d: Previous week

Variables

Variables enable dynamic dashboards by allowing users to change query parameters through dropdown menus.

Variable Types

Query Variables: Populated by running a query against a data source
Custom Variables: Manually defined list of values
Interval Variables: Time interval for grouping
Data Source Variables: List of data sources

Using Variables in Queries

Reference variables using $variable or ${variable} syntax:
Variables are interpolated by Grafana before sending queries to data sources.

Alerts

Grafana Alerting allows you to define alert rules that continuously evaluate queries and send notifications when conditions are met.

Alert Rule Structure

Alert rules are defined in the unified alerting system (pkg/services/ngalert):

Alert States

  • Normal: Condition is not met
  • Pending: Condition is met but waiting for “For” duration
  • Alerting: Condition has been met for longer than “For” duration
  • NoData: Query returned no data
  • Error: Error evaluating the alert rule

Notification Channels

Alerts are routed to notification channels based on labels and routing rules:
  • Slack
  • Email
  • PagerDuty
  • Webhook
  • Microsoft Teams
  • OpsGenie
  • VictorOps
  • And many more via contact points
Grafana uses a unified alerting system that evaluates alert rules independently of dashboards, providing more reliable alerting.

Plugins

Grafana’s plugin system enables extending functionality with custom panels, data sources, and applications.

Plugin Types

Panel Plugins: Custom visualizations
  • Located in public/app/plugins/panel/
  • Built with @grafana/data and @grafana/ui packages
Data Source Plugins: Connect to custom data sources
  • Backend in pkg/tsdb/ (Go)
  • Frontend in public/app/plugins/datasource/ (TypeScript)
  • Use @grafana/plugin-sdk-go for backend
App Plugins: Full applications within Grafana
  • Can include custom pages, panels, and data sources
  • Examples in apps/ directory

Plugin Development

Plugins are built using the Grafana plugin SDK:

Next Steps

Dashboard Best Practices

Learn how to design effective dashboards with proper layout, naming conventions, and variable usage.

Query Optimization

Optimize your queries for better performance with proper time ranges, aggregation, and caching.

Advanced Alerting

Set up sophisticated alert routing, silencing, and escalation policies.

Plugin Development

Build custom panels and data sources to extend Grafana’s capabilities.

Additional Resources

  • API Documentation: Backend API routes in pkg/api/
  • Type Definitions: packages/grafana-data/src/types/
  • Frontend Architecture: Redux Toolkit slices in feature directories
  • Schema Definitions: CUE schemas in kinds/ for dashboard structure
Understanding these core concepts provides a solid foundation for working with Grafana effectively, whether you’re creating dashboards, developing plugins, or contributing to the project.