Data Sources Overview
Grafana supports querying and visualizing data from a wide range of data sources. Each data source plugin provides a query editor and configuration interface tailored to that specific database or service.What is a Data Source?
A data source is an external service that Grafana queries to retrieve time series data, logs, traces, or other metrics. Grafana acts as a visualization layer on top of your existing data infrastructure.Data sources are configured per organization in Grafana. Each data source configuration includes connection details, authentication, and query settings.
Built-in Data Sources
Grafana includes support for many popular data sources out of the box:Prometheus
Time series database with powerful query language (PromQL)
Loki
Log aggregation system with LogQL query language
Elasticsearch
Search and analytics engine for logs and metrics
InfluxDB
Time series database with SQL, InfluxQL, and Flux support
MySQL / PostgreSQL
Relational databases for structured data queries
Common Features
All data sources share common functionality:Connection Settings
- URL: The HTTP endpoint for the data source API
- Access Mode: Proxy (server-side) or direct (browser)
- Authentication: Basic auth, API keys, OAuth, etc.
Query Editor
Each data source provides a custom query editor in the dashboard panel editor:- Visual query builder (for supported data sources)
- Code/raw query editor
- Query syntax validation and auto-completion
- Query history and saved queries
Variables
Data sources support template variables for dynamic dashboards:- Label values from the data source
- Custom query results
- Time ranges and intervals
Adding a Data Source
- Navigate to Configuration > Data Sources
- Click Add data source
- Select your data source type
- Configure connection settings
- Click Save & Test to verify connectivity
Connection Testing
Connection Testing
The “Save & Test” button performs a basic query to verify:
- Network connectivity to the data source
- Authentication credentials are valid
- Required permissions are granted
Query Performance
Time Range
All time series queries are scoped to the dashboard’s time range. Use appropriate time ranges to balance detail and performance.Resolution and Step
Grafana calculates query resolution based on:- Panel width in pixels
- Selected time range
- Data source-specific step/interval settings
Max Data Points
Limit the number of data points returned to prevent browser performance issues:Authentication Methods
- Basic Auth
- API Key
- OAuth
Username and password authentication. Credentials are encrypted in Grafana’s database.
Data Source Provisioning
You can provision data sources via YAML configuration files:<GRAFANA_HOME>/conf/provisioning/datasources/
Provisioned data sources cannot be edited through the UI. Update the YAML file and restart Grafana to apply changes.
Next Steps
Prometheus
Learn about PromQL queries and metric collection
Loki
Query logs with LogQL expressions
Elasticsearch
Build aggregation queries for logs and metrics
InfluxDB
Use Flux, InfluxQL, or SQL to query time series data