diff --git a/docs/sources/datasources/jaeger.md b/docs/sources/datasources/jaeger.md
index 001574b4c45..fb1c841c8b4 100644
--- a/docs/sources/datasources/jaeger.md
+++ b/docs/sources/datasources/jaeger.md
@@ -47,11 +47,12 @@ This is a configuration for the [trace to logs feature]({{< relref "../explore/t
To configure trace to metrics, select the target Prometheus data source and create any desired linked queries.
-- **Data source -** Target data source.
+-- **Tags -** You can use tags in the linked queries. The key is the span attribute name. The optional value is the corresponding metric label name (for example, map `k8s.pod` to `pod`). You may interpolate these tags into your queries using the `$__tags` keyword.
Each linked query consists of:
-- **Link Label -** (Optional) Descriptive label for the linked query.
--- **Query -** Query that runs when navigating from a trace to the metrics data source.
+-- **Query -** Query that runs 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`, it results in `requests_total{pod="nginx-554b9", cluster="us-east-1"}`.
### Node Graph
@@ -169,6 +170,12 @@ datasources:
spanEndTimeShift: '1h'
filterByTraceID: false
filterBySpanID: false
+ tracesToMetrics:
+ datasourceUid: 'prom'
+ tags: [{ key: 'service.name', value: 'service' }, { key: 'job' }]
+ queries:
+ - name: 'Sample query'
+ query: 'sum(rate(tempo_spanmetrics_latency_bucket{$__tags}[5m]))'
secureJsonData:
basicAuthPassword: my_password
```
diff --git a/docs/sources/datasources/tempo.md b/docs/sources/datasources/tempo.md
index 7993df800f8..7f9d0040d00 100644
--- a/docs/sources/datasources/tempo.md
+++ b/docs/sources/datasources/tempo.md
@@ -46,11 +46,12 @@ This is a configuration for the [trace to logs feature]({{< relref "../explore/t
To configure trace to metrics, select the target Prometheus data source and create any desired linked queries.
-- **Data source -** Target data source.
+-- **Tags -** You can use tags in the linked queries. The key is the span attribute name. The optional value is the corresponding metric label name (for example, map `k8s.pod` to `pod`). You may interpolate these tags into your queries using the `$__tags` keyword.
Each linked query consists of:
-- **Link Label -** (Optional) Descriptive label for the linked query.
--- **Query -** Query that runs when navigating from a trace to the metrics data source.
+-- **Query -** Query that runs 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`, it results in `requests_total{pod="nginx-554b9", cluster="us-east-1"}`.
### Service Graph
@@ -216,6 +217,12 @@ datasources:
spanEndTimeShift: '1h'
filterByTraceID: false
filterBySpanID: false
+ tracesToMetrics:
+ datasourceUid: 'prom'
+ tags: [{ key: 'service.name', value: 'service' }, { key: 'job' }]
+ queries:
+ - name: 'Sample query'
+ query: 'sum(rate(tempo_spanmetrics_latency_bucket{$__tags}[5m]))'
serviceMap:
datasourceUid: 'prometheus'
search:
diff --git a/docs/sources/datasources/zipkin.md b/docs/sources/datasources/zipkin.md
index 88ba196ce12..a4284ad2177 100644
--- a/docs/sources/datasources/zipkin.md
+++ b/docs/sources/datasources/zipkin.md
@@ -47,11 +47,12 @@ This is a configuration for the [trace to logs feature]({{< relref "../explore/t
To configure trace to metrics, select the target Prometheus data source and create any desired linked queries.
-- **Data source -** Target data source.
+-- **Tags -** You can use tags in the linked queries. The key is the span attribute name. The optional value is the corresponding metric label name (for example, map `k8s.pod` to `pod`). You may interpolate these tags into your queries using the `$__tags` keyword.
Each linked query consists of:
-- **Link Label -** (Optional) Descriptive label for the linked query.
--- **Query -** Query that runs when navigating from a trace to the metrics data source.
+-- **Query -** Query that runs 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`, it results in `requests_total{pod="nginx-554b9", cluster="us-east-1"}`.
### Node Graph
diff --git a/public/app/core/components/TraceToLogs/KeyValueInput.tsx b/public/app/core/components/TraceToLogs/KeyValueInput.tsx
index 45934073fdb..7d648c10293 100644
--- a/public/app/core/components/TraceToLogs/KeyValueInput.tsx
+++ b/public/app/core/components/TraceToLogs/KeyValueInput.tsx
@@ -65,6 +65,7 @@ const KeyValueInput = ({
onClick={() => onChange([...values.slice(0, idx), ...values.slice(idx + 1)])}
className="gf-form-label query-part"
aria-label="Remove tag"
+ type="button"
>
@@ -73,6 +74,7 @@ const KeyValueInput = ({
onClick={() => onChange([...values, { key: '', value: '' }])}
className="gf-form-label query-part"
aria-label="Add tag"
+ type="button"
>
@@ -84,6 +86,7 @@ const KeyValueInput = ({
onClick={() => onChange([...values, { key: '', value: '' }])}
className="gf-form-label query-part"
aria-label="Add tag"
+ type="button"
>
diff --git a/public/app/core/components/TraceToMetrics/TraceToMetricsSettings.tsx b/public/app/core/components/TraceToMetrics/TraceToMetricsSettings.tsx
index 4612892f0d8..3bc5c202f05 100644
--- a/public/app/core/components/TraceToMetrics/TraceToMetricsSettings.tsx
+++ b/public/app/core/components/TraceToMetrics/TraceToMetricsSettings.tsx
@@ -5,19 +5,23 @@ import {
DataSourceJsonData,
DataSourcePluginOptionsEditorProps,
GrafanaTheme,
+ KeyValue,
updateDatasourcePluginJsonDataOption,
} from '@grafana/data';
import { DataSourcePicker } from '@grafana/runtime';
import { Button, InlineField, InlineFieldRow, Input, useStyles } from '@grafana/ui';
+import KeyValueInput from '../TraceToLogs/KeyValueInput';
+
export interface TraceToMetricsOptions {
datasourceUid?: string;
+ tags?: Array>;
queries: TraceToMetricQuery[];
}
export interface TraceToMetricQuery {
name?: string;
- query: string;
+ query?: string;
}
export interface TraceToMetricsData extends DataSourceJsonData {
@@ -71,6 +75,21 @@ export function TraceToMetricsSettings({ options, onOptionsChange }: Props) {
) : null}
+
+
+
+ updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'tracesToMetrics', {
+ ...options.jsonData.tracesToMetrics,
+ tags: v,
+ })
+ }
+ />
+
+
+
{options.jsonData.tracesToMetrics?.queries?.map((query, i) => (