Grafana Cloud

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, SQL for business data, or CloudWatch for AWS monitoring, 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
  • AWS CloudWatch - CloudWatch metrics, logs, alarms, and anomaly detection

Before you begin

  • Connect data sources: Ensure your data sources (Prometheus, Loki, Tempo, SQL, CloudWatch, 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 like PostgreSQL, MySQL, BigQuery, and InfluxDB 3.x (SQL) for business or operational data.

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.

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 allowedHosts configured: The Assistant can only query URLs that match the allowed hosts list, but does so automatically without requiring approval for each request.
  • Without allowedHosts configured: 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.

Visualize on dashboard

Add the visualization to a new or existing dashboard.

Add this graph to the “Production Overview” dashboard.

AWS CloudWatch

Monitor AWS resources and applications using CloudWatch metrics, logs, alarms, and anomaly detection. The Assistant discovers available namespaces, metrics, and dimensions automatically, so you don’t need to memorize AWS resource identifiers.

Before you begin

Ensure your CloudWatch data source is configured with valid AWS credentials and the correct default region. For more information, refer to the CloudWatch data source documentation.

Discover metrics

Explore available CloudWatch namespaces, metrics, and dimensions to understand what data is available.

What CloudWatch namespaces are available in @cloudwatch-ds?

List the metrics available for the AWS/EC2 namespace.

What dimensions are available for CPUUtilization in AWS/EC2?

Query metrics

Ask the Assistant to query CloudWatch metrics using MetricStat or Metric Insights SQL.

MetricStat queries

Describe the metric, statistic, and any dimension filters.

Show the average CPUUtilization for EC2 instances in @cloudwatch-ds over the last hour.

Query the maximum NetworkIn for instance i-abc123 in us-east-1.

Metric Insights SQL

Use SQL syntax for more complex metric queries with aggregation and filtering.

Run a Metric Insights SQL query: SELECT AVG(CPUUtilization) FROM SCHEMA(“AWS/EC2”, InstanceId) GROUP BY InstanceId ORDER BY AVG() DESC LIMIT 10.

Query logs

Search and analyze CloudWatch Logs using Logs Insights queries.

Find error logs in the /aws/lambda/my-function log group from the last 15 minutes.

Run a CloudWatch Logs Insights query to count errors by service in @cloudwatch-ds.

Monitor alarms

Query CloudWatch alarm annotations to check the state of your alarms.

Show recent alarm state changes for alarms with the prefix “prod-high-cpu” in @cloudwatch-ds.

Detect anomalies

Query log anomaly detections to identify unusual patterns in your log data.

Show recent log anomalies detected in @cloudwatch-ds.

Visualize on dashboard

Add CloudWatch metrics and logs to dashboards for ongoing monitoring.

Create a dashboard panel showing EC2 CPU utilization from @cloudwatch-ds grouped by instance.

Add a CloudWatch Logs panel to the “Production Overview” dashboard showing error counts over time.

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