mirror of
https://github.com/grafana/grafana.git
synced 2025-01-24 15:27:01 -06:00
Tempo: Trace to metrics docs (#81548)
* Trace to metrics docs and share variables that can be used in query section * Update text * Add span start/end * Update docs/sources/shared/datasources/tempo-traces-to-profiles.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/datasources/tempo/configure-tempo-data-source.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update docs/sources/datasources/tempo/configure-tempo-data-source.md Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com> * Update text * Update docs/sources/datasources/tempo/configure-tempo-data-source.md --------- Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com>
This commit is contained in:
parent
c8ccc4649c
commit
96301ce533
@ -69,27 +69,11 @@ There are two ways to configure the trace to logs feature:
|
|||||||
You can also click **Open advanced data source picker** to see more options, including adding a data source.
|
You can also click **Open advanced data source picker** to see more options, including adding a data source.
|
||||||
|
|
||||||
1. Set start and end time shift. As the logs timestamps may not exactly match the timestamps of the spans in the trace it may be necessary to widen or shift the time range to find the desired logs.
|
1. Set start and end time shift. As the logs timestamps may not exactly match the timestamps of the spans in the trace it may be necessary to widen or shift the time range to find the desired logs.
|
||||||
1. Optionally select tags to map. These tags can be used in the custom query with `${__tags}` variable. This variable will interpolate the mapped tags as list in an appropriate syntax for the data source and will only include the tags that were present in the span omitting those that weren't present. You can optionally configure a new name for the tag. This is useful in cases where the tag has dots in the name and the target data source does not allow using dots in labels. For example, you can remap `http.status` to `http_status` in such a case. If you don't map any tags here, you can still use any tag in the query like this `method="${__span.tags.method}"`.
|
1. Optional: Select tags to map. These tags can be used in the custom query with `${__tags}` variable. This variable interpolates the mapped tags as list in an appropriate syntax for the data source. Only the tags that were present in the span are included; tags that aren't present are omitted You can also configure a new name for the tag. This is useful in cases where the tag has dots in the name and the target data source doesn't allow dots in labels. For example, you can remap `http.status` to `http_status`. If you don't map any tags here, you can still use any tag in the query, for example, `method="${__span.tags.method}"`. You can learn more about custom query variables [here](/docs/grafana/latest/datasources/tempo/configure-tempo-data-source/#custom-query-variables).
|
||||||
1. Skip **Filter by trace ID** and **Filter by span ID** settings as these cannot be used with a custom query.
|
1. Skip **Filter by trace ID** and **Filter by span ID** settings as these cannot be used with a custom query.
|
||||||
1. Switch on **Use custom query**.
|
1. Switch on **Use custom query**.
|
||||||
1. Specify a custom query to be used to query the logs. You can use various variables to make that query relevant for current span. The link will only be shown only if all the variables are interpolated with non-empty values to prevent creating an invalid query.
|
1. Specify a custom query to be used to query the logs. You can use various variables to make that query relevant for current span. The link will only be shown only if all the variables are interpolated with non-empty values to prevent creating an invalid query.
|
||||||
|
|
||||||
### Variables that can be used in a custom query
|
|
||||||
|
|
||||||
To use a variable you need to wrap it in `${}`. For example `${__span.name}`.
|
|
||||||
|
|
||||||
| Variable name | Description |
|
|
||||||
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| **\_\_tags** | This variable uses the tag mapping from the UI to create a label matcher string in the specific data source syntax. The variable only uses tags that are present in the span. The link is still created even if only one of those tags is present in the span. You can use this if all tags are not required for the query to be useful. |
|
|
||||||
| **\_\_span.spanId** | The ID of the span. |
|
|
||||||
| **\_\_span.traceId** | The ID of the trace. |
|
|
||||||
| **\_\_span.duration** | The duration of the span. |
|
|
||||||
| **\_\_span.name** | Name of the span. |
|
|
||||||
| **\_\_span.tags** | Namespace for the tags in the span. To access a specific tag named `version`, you would use `${__span.tags.version}`. In case the tag contains dot, you have to access it as `${__span.tags["http.status"]}`. |
|
|
||||||
| **\_\_trace.traceId** | The ID of the trace. |
|
|
||||||
| **\_\_trace.duration** | The duration of the trace. |
|
|
||||||
| **\_\_trace.name** | The name of the trace. |
|
|
||||||
|
|
||||||
### Configure trace to logs
|
### Configure trace to logs
|
||||||
|
|
||||||
The following table describes the ways in which you can configure your trace to logs settings:
|
The following table describes the ways in which you can configure your trace to logs settings:
|
||||||
@ -116,25 +100,54 @@ The **Trace to metrics** setting configures the [trace to metrics feature](/blog
|
|||||||
|
|
||||||
{{< youtube id="TkapvLeMMpc" >}}
|
{{< youtube id="TkapvLeMMpc" >}}
|
||||||
|
|
||||||
To configure trace to metrics:
|
There are two ways to configure the trace to metrics feature:
|
||||||
|
|
||||||
1. Select the target data source from the drop-down list.
|
- Use a basic configuration with a default query, or
|
||||||
|
- Configure one or more custom queries where you can use a [template language][variable-syntax] to interpolate variables from the trace or span.
|
||||||
|
|
||||||
You can also click **Open advanced data source picker** to see more options, including adding a data source.
|
### Simple config
|
||||||
|
|
||||||
1. Create any desired linked queries.
|
To use a simple configuration, follow these steps:
|
||||||
|
|
||||||
| Setting name | Description |
|
1. Select a metrics data source from the **Data source** drop-down.
|
||||||
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
1. Optional: Choose any tags to use in the query. If left blank, the default values of `cluster`, `hostname`, `namespace`, `pod`, `service.name` and `service.namespace` are used.
|
||||||
| **Data source** | Defines the target data source. |
|
|
||||||
| **Tags** | Defines the tags used in linked queries. The key sets the span attribute name, and the optional value sets the corresponding metric label name. For example, you can map `k8s.pod` to `pod`. To interpolate these tags into queries, use the `$__tags` keyword. |
|
|
||||||
|
|
||||||
Each linked query consists of:
|
The tags you configure must be present in the spans attributes or resources for a trace to metrics span link to appear. You can optionally configure a new name for the tag. This is useful for example if the tag has dots in the name and the target data source doesn't allow using dots in labels. In that case you can for example remap `service.name` to `service_name`.
|
||||||
|
|
||||||
- **Link Label:** _(Optional)_ Descriptive label for the linked query.
|
1. Do not select **Add query**.
|
||||||
- **Query:** The query ran when navigating from a trace to the metrics data source.
|
1. Select **Save and Test**.
|
||||||
Interpolate tags using the `$__tags` keyword.
|
|
||||||
For example, when you configure the query `requests_total{$__tags}`with the tags `k8s.pod=pod` and `cluster`, the result looks like `requests_total{pod="nginx-554b9", cluster="us-east-1"}`.
|
### Custom queries
|
||||||
|
|
||||||
|
To use custom queriess with the configuration, follow these steps:
|
||||||
|
|
||||||
|
1. Select a metrics data source from the **Data source** drop-down.
|
||||||
|
1. Optional: Choose any tags to use in the query. If left blank, the default values of `cluster`, `hostname`, `namespace`, `pod`, `service.name` and `service.namespace` are used.
|
||||||
|
|
||||||
|
These tags can be used in the custom query with `${__tags}` variable. This variable interpolates the mapped tags as list in an appropriate syntax for the data source and will only include the tags that were present in the span omitting those that weren’t present. You can optionally configure a new name for the tag. This is useful in cases where the tag has dots in the name and the target data source doesn't allow using dots in labels. For example, you can remap `service.name` to `service_name` in such a case. If you don’t map any tags here, you can still use any tag in the query like this `method="${__span.tags.method}"`. You can learn more about custom query variables [here](/docs/grafana/latest/datasources/tempo/configure-tempo-data-source/#custom-query-variables).
|
||||||
|
|
||||||
|
1. Click **Add query** to add a custom query.
|
||||||
|
1. Specify a custom query to be used to query metrics data.
|
||||||
|
|
||||||
|
Each linked query consists of:
|
||||||
|
|
||||||
|
- **Link Label:** _(Optional)_ Descriptive label for the linked query.
|
||||||
|
- **Query:** The query ran when navigating from a trace to the metrics data source.
|
||||||
|
Interpolate tags using the `$__tags` keyword.
|
||||||
|
For example, when you configure the query `requests_total{$__tags}`with the tags `k8s.pod=pod` and `cluster`, the result looks like `requests_total{pod="nginx-554b9", cluster="us-east-1"}`.
|
||||||
|
|
||||||
|
1. Select **Save and Test**.
|
||||||
|
|
||||||
|
### Configure trace to metrics
|
||||||
|
|
||||||
|
| Setting name | Description |
|
||||||
|
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| **Data source** | Defines the target data source. |
|
||||||
|
| **Span start time shift** | Shifts the start time for the metrics query, based on the span's start time. You can use time units, such as `5s`, `1m`, `3h`. To extend the time to the past, use a negative value. Default: `0`. |
|
||||||
|
| **Span end time shift** | Shifts the end time for the metrics query, based on the span's end time. You can use time units. Default: `0`. |
|
||||||
|
| **Tags** | Defines the tags used in linked queries. The key sets the span attribute name, and the optional value sets the corresponding metric label name. For example, you can map `k8s.pod` to `pod`. To interpolate these tags into queries, use the `$__tags` keyword. |
|
||||||
|
| **Link Label** | _(Optional)_ Descriptive label for the linked query. |
|
||||||
|
| **Query** | Input to write a custom query. Use variable interpolation to customize it with variables from span. |
|
||||||
|
|
||||||
## Trace to profiles
|
## Trace to profiles
|
||||||
|
|
||||||
@ -142,6 +155,22 @@ Each linked query consists of:
|
|||||||
|
|
||||||
{{< docs/shared source="grafana" lookup="datasources/tempo-traces-to-profiles.md" leveloffset="+1" version="<GRAFANA VERSION>" >}}
|
{{< docs/shared source="grafana" lookup="datasources/tempo-traces-to-profiles.md" leveloffset="+1" version="<GRAFANA VERSION>" >}}
|
||||||
|
|
||||||
|
## Custom query variables
|
||||||
|
|
||||||
|
To use a variable in your trace to logs, metrics or profiles you need to wrap it in `${}`. For example, `${__span.name}`.
|
||||||
|
|
||||||
|
| Variable name | Description |
|
||||||
|
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| **\_\_tags** | This variable uses the tag mapping from the UI to create a label matcher string in the specific data source syntax. The variable only uses tags that are present in the span. The link is still created even if only one of those tags is present in the span. You can use this if all tags are not required for the query to be useful. |
|
||||||
|
| **\_\_span.spanId** | The ID of the span. |
|
||||||
|
| **\_\_span.traceId** | The ID of the trace. |
|
||||||
|
| **\_\_span.duration** | The duration of the span. |
|
||||||
|
| **\_\_span.name** | Name of the span. |
|
||||||
|
| **\_\_span.tags** | Namespace for the tags in the span. To access a specific tag named `version`, you would use `${__span.tags.version}`. In case the tag contains dot, you have to access it as `${__span.tags["http.status"]}`. |
|
||||||
|
| **\_\_trace.traceId** | The ID of the trace. |
|
||||||
|
| **\_\_trace.duration** | The duration of the trace. |
|
||||||
|
| **\_\_trace.name** | The name of the trace. |
|
||||||
|
|
||||||
## Service Graph
|
## Service Graph
|
||||||
|
|
||||||
The **Service Graph** setting configures the [Service Graph](/docs/tempo/latest/metrics-generator/service_graphs/enable-service-graphs/) feature.
|
The **Service Graph** setting configures the [Service Graph](/docs/tempo/latest/metrics-generator/service_graphs/enable-service-graphs/) feature.
|
||||||
|
@ -66,29 +66,13 @@ To use a custom query with the configuration, follow these steps:
|
|||||||
1. Select a Pyroscope data source from the **Data source** drop-down.
|
1. Select a Pyroscope data source from the **Data source** drop-down.
|
||||||
1. Optional: Choose any tags to use in the query. If left blank, the default values of `service.name` and `service.namespace` are used.
|
1. Optional: Choose any tags to use in the query. If left blank, the default values of `service.name` and `service.namespace` are used.
|
||||||
|
|
||||||
These tags can be used in the custom query with `${__tags}` variable. This variable interpolates the mapped tags as list in an appropriate syntax for the data source. Only the tags that were present in the span are included; tags that aren't present are omitted. You can also configure a new name for the tag. This is useful in cases where the tag has dots in the name and the target data source doesn't allow using dots in labels. For example, you can remap `service.name` to `service_name`. If you don’t map any tags here, you can still use any tag in the query, for example: `method="${__span.tags.method}"`.
|
These tags can be used in the custom query with `${__tags}` variable. This variable interpolates the mapped tags as list in an appropriate syntax for the data source. Only the tags that were present in the span are included; tags that aren't present are omitted. You can also configure a new name for the tag. This is useful in cases where the tag has dots in the name and the target data source doesn't allow using dots in labels. For example, you can remap `service.name` to `service_name`. If you don’t map any tags here, you can still use any tag in the query, for example: `method="${__span.tags.method}"`. You can learn more about custom query variables [here](/docs/grafana/latest/datasources/tempo/configure-tempo-data-source/#custom-query-variables).
|
||||||
|
|
||||||
1. Select one or more profile types to use in the query. Select the drop-down and choose options from the menu.
|
1. Select one or more profile types to use in the query. Select the drop-down and choose options from the menu.
|
||||||
1. Switch on **Use custom query** to enter a custom query.
|
1. Switch on **Use custom query** to enter a custom query.
|
||||||
1. Specify a custom query to be used to query profile data. You can use various variables to make that query relevant for current span. The link is shown only if all the variables are interpolated with non-empty values to prevent creating an invalid query. You can interpolate the configured tags using the `$__tags` keyword.
|
1. Specify a custom query to be used to query profile data. You can use various variables to make that query relevant for current span. The link is shown only if all the variables are interpolated with non-empty values to prevent creating an invalid query. You can interpolate the configured tags using the `$__tags` keyword.
|
||||||
1. Select **Save and Test**.
|
1. Select **Save and Test**.
|
||||||
|
|
||||||
## Custom query variables
|
|
||||||
|
|
||||||
To use a variable you need to wrap it in `${}`. For example, `${__span.name}`.
|
|
||||||
|
|
||||||
| Variable name | Description |
|
|
||||||
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| **\_\_tags** | This variable uses the tag mapping from the UI to create a label matcher string in the specific data source syntax. The variable only uses tags that are present in the span. The link is still created even if only one of those tags is present in the span. You can use this if all tags are not required for the query to be useful. |
|
|
||||||
| **\_\_span.spanId** | The ID of the span. |
|
|
||||||
| **\_\_span.traceId** | The ID of the trace. |
|
|
||||||
| **\_\_span.duration** | The duration of the span. |
|
|
||||||
| **\_\_span.name** | Name of the span. |
|
|
||||||
| **\_\_span.tags** | Namespace for the tags in the span. To access a specific tag named `version`, you would use `${__span.tags.version}`. In case the tag contains dot, you have to access it as `${__span.tags["http.status"]}`. |
|
|
||||||
| **\_\_trace.traceId** | The ID of the trace. |
|
|
||||||
| **\_\_trace.duration** | The duration of the trace. |
|
|
||||||
| **\_\_trace.name** | The name of the trace. |
|
|
||||||
|
|
||||||
## Configure trace to profiles
|
## Configure trace to profiles
|
||||||
|
|
||||||
The following table describes options for configuring your trace to profiles settings:
|
The following table describes options for configuring your trace to profiles settings:
|
||||||
|
Loading…
Reference in New Issue
Block a user