Skip to content

Commit

Permalink
Transform Example: Change context to datapoint (open-telemetry#27041
Browse files Browse the repository at this point in the history
)

**Description:** 
- Fixing documentation for incorrect transform context.
- Correcting `resource.attributes["k8s_namespace_name"` to be correct
`.` separated name.
- Removing `resource.attributes["k8s.cluster.name"]` as it's not an
available attribute.  

**Link to tracking Issue:**

open-telemetry#27012 (comment)

**Testing:** 
Works in my own otel-collector.

**Documentation:** 
All documentation updates here.
  • Loading branch information
nickv2002 authored and harishbohara11 committed Sep 21, 2023
1 parent c2075cc commit 282efff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions exporter/prometheusexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@ This is not a common pattern, and we recommend copying the most common resource
processor:
transform:
metric_statements:
- context: metric
- context: datapoint
statements:
- set(attributes["namespace"], resource.attributes["k8s_namespace_name"])
- set(attributes["namespace"], resource.attributes["k8s.namespace.name"])
- set(attributes["container"], resource.attributes["k8s.container.name"])
- set(attributes["pod"], resource.attributes["k8s.pod.name"])
- set(attributes["cluster"], resource.attributes["k8s.cluster.name"])
```

After this, grouping or selecting becomes as simple as:
Expand Down
5 changes: 2 additions & 3 deletions exporter/prometheusremotewriteexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ This is not a common pattern, and we recommend copying the most common resource
processor:
transform:
metric_statements:
- context: metric
- context: datapoint
statements:
- set(attributes["namespace"], resource.attributes["k8s_namespace_name"])
- set(attributes["namespace"], resource.attributes["k8s.namespace.name"])
- set(attributes["container"], resource.attributes["k8s.container.name"])
- set(attributes["pod"], resource.attributes["k8s.pod.name"])
- set(attributes["cluster"], resource.attributes["k8s.cluster.name"])
```

After this, grouping or selecting becomes as simple as:
Expand Down

0 comments on commit 282efff

Please sign in to comment.