Skip to main content

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.
Direct browser access is deprecated for most data sources due to CORS and security concerns. Use server proxy mode.

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:
rate(http_requests_total{instance="$instance"}[5m])
Variables can be populated from:
  • Label values from the data source
  • Custom query results
  • Time ranges and intervals

Adding a Data Source

  1. Navigate to Configuration > Data Sources
  2. Click Add data source
  3. Select your data source type
  4. Configure connection settings
  5. Click Save & Test to verify connectivity
The “Save & Test” button performs a basic query to verify:
  • Network connectivity to the data source
  • Authentication credentials are valid
  • Required permissions are granted
If the test fails, check your firewall rules, credentials, and data source URL.

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:
// Configured in panel settings
maxDataPoints: 1000

Authentication Methods

Username and password authentication. Credentials are encrypted in Grafana’s database.
basicAuth: true
basicAuthUser: "admin"

Data Source Provisioning

You can provision data sources via YAML configuration files:
apiVersion: 1

datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://prometheus:9090
    isDefault: true
    jsonData:
      timeInterval: "30s"
Place configuration files in:
  • <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

Build docs developers (and LLMs) love