Help build the future of open source observability software Open positions

Check out the open source projects we support Downloads

The actually useful free plan

Grafana Cloud Free Tier
check

10k series Prometheus metrics

check

50GB logs, 50GB traces, 50GB profiles

check

500VUk k6 testing

check

20+ Enterprise data source plugins

check

100+ pre-built solutions

Featured webinar

Getting started with grafana LGTM stack

Getting started with managing your metrics, logs, and traces using Grafana

Learn how to unify, correlate, and visualize data with dashboards using Grafana.

SQL expressions in Grafana: Combine and manipulate data from multiple sources

SQL expressions in Grafana: Combine and manipulate data from multiple sources

2025-10-30 5 min

One of Grafana’s greatest strengths is its ability to provide a consistent monitoring experience for all your data sources. But not everyone wants to go through the process of transforming that data and setting up a data warehouse to make that happen, especially for complex analyses. 

That’s why we developed  SQL expressions, a Grafana feature that lets you manipulate and combine data from different data sources—Prometheus, MySQL, BigQuery, Grafana Loki, Google Sheets, and more—as if they were all tables in the same MySQL database. 

This new feature, currently in public preview in Grafana OSS, Grafana Enterprise, and Grafana Cloud, can be used with dashboard panels as well Grafana-managed alerting and recording rules. This makes SQL expressions a versatile and powerful feature that opens up all sorts of creative possibilities.

And with the Grafana LLM plugin (not to be confused with Grafana Assistant), you can even write SQL queries using natural language—so the power of SQL is accessible even if you aren’t fluent in it.

The possibilities are wide open, but here are a few ways to start imagining what’s possible.

Enhance a single data source

The simplest use case is to take data from a single source—whether it’s tabular data (like MySQL) or time series data (like Prometheus)—and treat it as a table.

Once you have that, you can:

  • Aggregate, filter, and perform math operations
  • Smooth noisy time series
  • Generate regression or trend lines
  • Compute projections (like “time to threshold”)
  • Build alerts on top of derived values

For example, with just one expression you can smooth a metric, fit a trend line, calculate the predicted time to reach a threshold, visualize it, and alert when that time is below a limit.

Combine data source responses

SQL expressions can join different data source types at the same time. So you can connect completely different systems in a single query. This opens the door to combining data that’s spread across many systems, which widens the possibilities of Grafana’s “big tent” philosophy.

That means you can correlate Prometheus metrics with MySQL tables, and/or join Microsoft Azure data with Google Sheets—directly in Grafana, no data warehouse required.

This is especially powerful when some of your data lives in systems you can’t or don’t want to centralize. Many organizations have 80%–90% of their data in a warehouse but still rely on other operational systems. SQL expressions let you bridge that last gap, ad hoc, without waiting on ETL pipelines.

Using natural language

And since not everyone is an expert in SQL, we’re integrating SQL expressions with the Grafana LLM plugin to provide AI-powered assistance in your workflow. Once you’ve installed the plugin, which is currently in public preview, you can use it to get a detailed explanation of your query. You can also receive suggestions for performance and reliability enhancements, column naming best practices, and guidance on panel optimization. 

SQL expresions query interface in Grafana with the Explain query and Improve query buttons highlighted
The suggestions will be saved (from newest to oldest) for quick access and to create a history of improvements. And if your query has a parsing error, such as a syntax issue, the LLM can automatically identify errors and help you rewrite the query correctly.

More ideas to explore

Looking for more ways to use SQL expressions? Here are just a few other options to help you get started: 

  • GitHub + Sheets + Prometheus: Join PR and issue data from GitHub with team ownership data in Google Sheets and service reliability metrics from Prometheus, then build dashboards that show engineering throughput and service health side-by-side.
  • Threshold tables for alerting: Define custom thresholds per cluster or service in a SQL data source, then join that with live metrics from Loki or Prometheus. Your alerting logic stays flexible and data-driven—not hard-coded in expressions.
  • SQL inception: Create recording rules, then query those metrics in Prometheus, and if you like, run SQL expressions on the metrics that were created by SQL expressions.

What’s next?

We’re excited for the community to start exploring SQL expressions, but we aren’t done yet. We’re exploring future capabilities like:

  • Support for more data source types
  • A better UI for knowing what the virtual SQL schema is
  • Chaining SQL expressions together so you can build dashboards the reference different parts of a data processing pipeline
  • Extending SQL expressions with custom functions

We can’t wait to see all the ways the community puts this new feature to use. If you have any questions or want to share feedback, please share it in this Google Form

Thank you to Dolthub

The central component of SQL expressions is go-mysql-server from Dolthub. Since the project is written in Go, we can use it without having to insert the data into another database first. It also helps us operationally, since we use Go in our stack and it aligns with general engineering expertise at Grafana Labs. Plus, the Dolthub community has also been very quick to respond and fix any issues we’ve reported.

 You can learn more about this on their blog.

Grafana Cloud is the easiest way to get started with metrics, logs, traces, dashboards, and more. We have a generous forever-free tier and plans for every use case. Sign up for free now!