Query data
Grafana Assistant can help you write, explain, and optimize queries across your observability stack. Whether you need PromQL for metrics, LogQL for logs, TraceQL for traces, or SQL for business data, the Assistant can generate valid syntax and visualize the results.
Before you begin
- Connect data sources: Ensure your data sources (Prometheus, Loki, Tempo, SQL, etc.) are connected.
- Reference data sources: Use the
@symbol to mention specific data sources in your prompt (for example,@prometheus-ds), ensuring the Assistant queries the correct data.
Metrics (PromQL)
Generate PromQL queries to analyze metrics without memorizing functions and operators.
Draft a query
Describe the metric and aggregation you need.
Create a PromQL query in @prometheus-ds that shows p95 latency for checkout_service over the last hour.
Refine
Ask for variations or filters.
Group by region and sort by highest error rate.
Visualize
Request a visualization in the chat or add it to a dashboard.
Show this as a time series graph.
Logs (LogQL)
Find log patterns and extract insights using LogQL.
Warning
Querying Loki with the Assistant contributes to the Assistant fair-usage policy.
During public preview, we recommend not running wide scans on Loki to avoid exhausting your fair-usage limits.
Search logs
Describe the log stream and filters.
Find logs from @loki-logs where job=“checkout” and level=“error” in the last 15 minutes.
Parse and aggregate
Extract fields and count occurrences.
Parse the JSON payload and show the top five error codes.
Traces (TraceQL)
Locate specific traces to debug latency or errors.
Find traces
Specify the service and conditions.
Query @tempo-traces for traces longer than 2 seconds.
Analyze
Ask for summaries of the findings.
Show the slowest spans and include their service names.
SQL Databases
Query relational databases for business or operational data.
Discover tables
Ask the Assistant to find relevant tables.
Find tables in @orders-database that track checkout failures.
Generate SQL
Describe your question in plain English.
Query for failed checkouts per minute grouped by payment_provider.
Optimize queries
The Assistant can review and improve your existing queries for performance and accuracy.
Paste your query
Provide the query you want to optimize and tell the Assistant what to do.
Review this PromQL query for performance:
sum(rate(http_requests_total[5m]))
Ask for improvements
Ask for specific changes.
Remove high-cardinality labels.
Next steps
- Learn how to navigate Grafana with the Assistant.
- Use your queries to build dashboards.



