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.
The Assistant can query the following data sources:
- Metrics - Prometheus, (Grafana Cloud and on-premise endpoints), InfluxDB
- Logs - Loki data sources
- Traces - Tempo for distributed tracing
- Profiles - Pyroscope (via Grafana Cloud Profiles)
- Load Testing - k6 Cloud results
- SQL Databases - PostgreSQL, MySQL, ClickHouse, BigQuery, Athena
- External APIs - Infinity datasource for querying web APIs with JSON endpoints
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.
External APIs using Infinity data source
Query data from external web APIs and JSON endpoints. The Infinity data source turns any JSON API into a Grafana data source, opening up endless visualization possibilities.
Control which APIs can be queried
The Infinity data source has an allowedHosts setting that controls which URLs the Assistant can query and whether user approval is required.
- With
allowedHostsconfigured: The Assistant can only query URLs that match the allowed hosts list, but does so automatically without requiring approval for each request. - Without
allowedHostsconfigured: The Assistant can query any URL, but will prompt you to approve each request before executing it.
To configure allowed hosts, edit your Infinity data source settings and add the URLs or domains you want to allow. For example, adding https://api.example.com restricts the Assistant to querying endpoints under that domain. For more information, refer to the Infinity data source documentation.
Query a JSON endpoint
Describe the URL and what data you want to retrieve.
Query the API at https://api.example.com/metrics and show me the results.
Transform with jq
Use jq expressions to filter or reshape the response data.
Query https://api.example.com/data and extract only the items where status is “active”.
Visualize as time series
Request time-based visualization for data with timestamps.
Query the API and show the values over time as a graph.
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.



