-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DOC] Update metrics query docs with examples, more details #4248
Merged
knylander-grafana
merged 7 commits into
grafana:main
from
zalegrala:rebase-ts-413-metrics-query-doc-update
Oct 30, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e6ed56c
Update metrics query doc with more examples
knylander-grafana 3a5ddde
Update content from doc session
knylander-grafana e8360be
Apply suggestions from code review
knylander-grafana 565512d
Restructure and update metrics queries
knylander-grafana 55371c3
Updates to meet review comments
knylander-grafana 7405b91
fix paragraph
knylander-grafana a709a82
Updates for conflict
knylander-grafana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
title: TraceQL metrics queries | ||
menuTitle: TraceQL metrics queries | ||
description: Learn about TraceQL metrics queries | ||
weight: 600 | ||
keywords: | ||
- metrics query | ||
- TraceQL metrics | ||
--- | ||
|
||
# TraceQL metrics queries | ||
|
||
{{< docs/experimental product="TraceQL metrics" >}} | ||
|
||
TraceQL metrics is an experimental feature in Grafana Tempo that creates metrics from traces. | ||
|
||
Metric queries extend trace queries by applying a function to trace query results. | ||
This powerful feature allows for ad hoc aggregation of any existing TraceQL query by any dimension available in your traces, much in the same way that LogQL metric queries create metrics from logs. | ||
|
||
Traces are a unique observability signal that contain causal relationships between the components in your system. | ||
|
||
TraceQL metrics can help answer questions like this: | ||
|
||
* How many database calls across all systems are downstream of your application? | ||
* What services beneath a given endpoint are currently failing? | ||
* What services beneath an endpoint are currently slow? | ||
|
||
TraceQL metrics can help you answer these questions by parsing your traces in aggregate. | ||
|
||
TraceQL metrics are powered by the [TraceQL metrics API](https://grafana.com/docs/tempo/<TEMPO_VERSION>/api_docs/#traceql-metrics). | ||
|
||
![Metrics visualization in Grafana](/media/docs/tempo/metrics-explore-sample-2.4.png) | ||
|
||
## RED metrics, TraceQL, and PromQL | ||
|
||
RED is an acronym for three types of metrics: | ||
|
||
- Rate, the number of requests per second | ||
- Errors, the number of those requests that are failing | ||
- Duration, the amount of time those requests take | ||
|
||
For more information about the RED method, refer to [The RED Method: how to instrument your services](/blog/2018/08/02/the-red-method-how-to-instrument-your-services/). | ||
|
||
You can write TraceQL metrics queries to compute rate, errors, and durations over different groups of spans. | ||
|
||
For more information on how to use TraceQL metrics to investigate issues, refer to [Solve problems with metrics queries](./solve-problems-metrics-queries). | ||
|
||
## Enable and use TraceQL metrics | ||
|
||
To use TraceQL metrics, you need to enable them on your Tempo database. | ||
Refer to [Configure TraceQL metrics](https://grafana.com/docs/tempo/<TEMPO_VERSION>/operations/traceql-metrics/) for more information. | ||
|
||
From there, you can either query the TraceQL metrics API directly (for example, with `curl`) or using Grafana | ||
(recommended). | ||
To run TraceQL metrics queries in Grafana, you need Grafana Cloud or Grafana 10.4 or later. | ||
No extra configuration is needed. | ||
Use a Tempo data source that points to a Tempo database with TraceQL metrics enabled. | ||
|
||
Refer to [Solve problems using metrics queries](./solve-problems-metrics-queries/) for some real-world examples. | ||
|
||
### Functions | ||
|
||
TraceQL metrics queries currently include the following functions for aggregating over groups of spans: `rate`, `count_over_time`, `quantile_over_time`, `histogram_over_time`, and `compare`. | ||
These functions can be added as an operator at the end of any TraceQL query. | ||
|
||
For detailed information and example queries for each function, refer to [TraceQL metrics functions](./functions). | ||
|
||
### Exemplars | ||
|
||
Exemplars are a powerful feature of TraceQL metrics. | ||
They allow you to see an exact trace that contributed to a given metric value. | ||
This is particularly useful when you want to understand why a given metric is high or low. | ||
|
||
Exemplars are available in TraceQL metrics for all range queries. | ||
To get exemplars, you need to configure it in the query-frontend with the parameter `query_frontend.metrics.max_exemplars`, | ||
or pass a query hint in your query. | ||
|
||
Example: | ||
|
||
``` | ||
{ span:name = "GET /:endpoint" } | quantile_over_time(duration, .99) by (span.http.target) with (exemplars=true) | ||
``` | ||
|
||
{{< admonition type="note" >}} | ||
TraceQL metric queries with exemplars aren't fully supported in Grafana Explore. | ||
They will be supported in a future Grafana release. | ||
{{< /admonition >}} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This admonition is new and needs to be reviewed.