Generate and refine queries
Start here when you need to read or write queries without memorizing syntax. Each workflow targets a specific query language so you can draft, validate, and optimize expressions in Grafana using natural language prompts.
When to use this hub
- You want the Assistant to generate PromQL, LogQL, TraceQL, SQL, or k6 queries that you can paste into dashboards or Explore.
- You have an existing query that needs validation, optimization, or translation into a different form.
- You need to troubleshoot syntax errors or performance problems in queries the Assistant or humans already built.
Prerequisites
- Data source access: Ensure you connect the relevant data sources (Prometheus, Loki, Tempo, Pyroscope, SQL, or k6) and confirm your user can reach them.
- Goal statement: Articulate the metric, log pattern, trace filter, profile, or business KPI you need so the Assistant selects the right tools.
- Testing environment: Keep Grafana Explore or the dashboard editor open to validate each generated query.
- Prompting etiquette: Use natural language, provide example labels or values, iterate in small steps, and start a new conversation when you switch to a different dataset.
Workflows in this hub
- PromQL workflows
Draft, validate, and refine Prometheus queries with Grafana Assistant. - LogQL workflows
Build and refine Loki queries with Grafana Assistant. - TraceQL workflows
Query Tempo traces with Grafana Assistant. - SQL workflows
Generate and execute SQL queries with Grafana Assistant. - Optimize generated queries
Improve performance and maintainability of Assistant-generated queries.
Next steps
- Start with PromQL workflows for metrics queries.
- Apply queries in Dashboard management to create visualizations.