Query data
Grafana Assistant can write, explain, and optimize queries across your observability stack. Describe what you need in natural language, and the Assistant generates valid syntax and visualizes the results.
Before you begin
Ensure the data sources you want to query are configured in your Grafana instance.
Tip
Use the
@symbol to mention a specific data source in your prompt (for example,@prometheus-ds) so the Assistant queries the correct one.
Supported data sources
| Data source | Supported queries |
|---|---|
| Prometheus | PromQL |
| Loki | LogQL |
| Tempo | TraceQL |
| Pyroscope (Grafana Cloud Profiles) | FlameQL |
| Graphite | Graphite render API targets |
| InfluxDB | SQL (InfluxDB 3.x) |
| k6 Cloud | k6 Cloud API |
| PostgreSQL | SQL |
| MySQL | SQL |
| MSSQL | SQL |
| ClickHouse | SQL |
| BigQuery | SQL |
| Athena | SQL |
| Snowflake | SQL |
| Databricks | SQL |
| Cube | Semantic layer (measures, dimensions, filters) |
| Infinity | JSON API using URL, jq transforms |
| CloudWatch | MetricStat, Metric Insights SQL, Logs Insights |
| Elasticsearch | Lucene, aggregations |
| Honeycomb | Aggregation queries, SLOs, breakdowns |
| Synthetic Monitoring | Probes, checks, reachability, latency, error rates |
For every data source the workflow is the same: describe what you want, refine the results, and optionally visualize them on a dashboard.
Example prompts
Prometheus
Create a PromQL query in @prometheus-ds that shows p95 latency for checkout_service over the last hour.
Group by region and sort by highest error rate.
Loki
Find logs from @loki-logs where job=“checkout” and level=“error” in the last 15 minutes.
Parse the JSON payload and show the top five error codes.
Tempo
Query @tempo-traces for traces longer than 2 seconds.
Show the slowest spans and include their service names.
Graphite
Show the metrics tree under
servers.web.*in @graphite-ds.
Query @graphite-ds for the average CPU load across all web servers over the last 6 hours.
SQL databases
Find tables in @orders-database that track checkout failures.
Query for failed checkouts per minute grouped by payment_provider.
Note
SQL Table Discovery is currently in public preview. Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.
Cube
What measures and dimensions are available in @cube-ds?
Query @cube-ds for total revenue by product category over the last 30 days, filtered to the US region.
CloudWatch
What CloudWatch namespaces are available in @cloudwatch-ds?
Show the average CPUUtilization for EC2 instances in @cloudwatch-ds over the last hour.
Find error logs in the /aws/lambda/my-function log group from the last 15 minutes.
Show recent alarm state changes for alarms with the prefix “prod-high-cpu” in @cloudwatch-ds.
Elasticsearch
What fields are available in @search-logs?
Find error logs in @search-logs where
service.nameis checkout in the last 15 minutes.
Show the average
duration_msgrouped byservice.namefrom @search-logs over the last hour.
Honeycomb
What datasets are available in @honeycomb-ds?
Show p99 latency by service and route from the
productiondataset in @honeycomb-ds over the last hour.
Show error counts broken down by status code and service in @honeycomb-ds.
Infinity (external APIs)
Query the API at https://api.example.com/metrics and show me the results.
Query https://api.example.com/data and extract only the items where status is “active”.
The Infinity allowedHosts setting controls which URLs the Assistant can reach. With it configured, matching URLs are queried automatically. Without it, the Assistant prompts you to approve each request. For more information, refer to the Infinity allowed hosts documentation.
Synthetic Monitoring
List all probes available in @synthetic-monitoring.
Show the latency and success rate for the checkout health check over the last hour.
Tips for better results
- Be specific about time ranges. Prompts like “last 15 minutes” or “over the past 24 hours” help the Assistant pick the right window and avoid scanning too much data.
- Mention the data source by name. Use the
@prefix (for example,@prometheus-prod) when you have multiple data sources of the same type so the Assistant targets the correct one. - Start broad, then refine. Ask for a general query first, then follow up with filters, groupings, or aggregations in subsequent messages.
- Ask for explanations. You can paste an existing query and ask “Explain this query” to understand what it does before modifying it.
- Request alternatives. Ask the Assistant to suggest different approaches, for example: “Is there a more efficient way to write this PromQL?”
- Combine signals. You can ask the Assistant to correlate across data sources in a single conversation, for example: “Show me error logs from Loki around the time latency spiked in Prometheus.”
Optimize existing queries
Paste any query and ask the Assistant to review it for performance or correctness.
Review this PromQL query for performance:
sum(rate(http_requests_total[5m]))
Remove high-cardinality labels.
Rewrite this LogQL query to use stream selectors instead of line filters for better performance.
Next steps
- Learn how to navigate Grafana with the Assistant.
- Use your queries to build dashboards.
Was this page helpful?
Related resources from Grafana Labs


