You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[chore] [processor/k8sattributes] improve documentation for the k8sattributes processor (#33800)
**Description:** This PR attempts to improve the documentation of the
k8sattributes processor. Being relatively new to this component I tried
to make the documentation a bit easier to understand for new users, and
highlight some limitations I found while going through the
implementation.
**Link to tracking Issue:** #32104
**Testing:** Trying out different configurations and association rules
to get a better understanding
**Documentation:** Extended the readme of this component
---------
Signed-off-by: Florian Bacher <[email protected]>
Co-authored-by: Tiffany Hrabusa <[email protected]>
Copy file name to clipboardExpand all lines: processor/k8sattributesprocessor/README.md
+121-4Lines changed: 121 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,8 @@ The processor stores the list of running pods and the associated metadata. When
26
26
to the pod from where the datapoint originated, so we can add the relevant pod metadata to the datapoint. By default, it associates the incoming connection IP
27
27
to the Pod IP. But for cases where this approach doesn't work (sending through a proxy, etc.), a custom association rule can be specified.
28
28
29
-
Each association is specified as a list of sources of associations. A source is a rule that matches metadata from the datapoint to pod metadata.
29
+
Each association is specified as a list of sources of associations. The maximum number of sources within an association is 4.
30
+
A source is a rule that matches metadata from the datapoint to pod metadata.
30
31
In order to get an association applied, all the sources specified need to match.
31
32
32
33
Each sources rule is specified as a pair of `from` (representing the rule type) and `name` (representing the attribute name if `from` is set to `resource_attribute`).
@@ -35,7 +36,7 @@ The following rule types are available:
35
36
-`connection`: Takes the IP attribute from connection context (if available). In this case the processor must appear before any batching or tail sampling, which remove this information.
36
37
-`resource_attribute`: Allows specifying the attribute name to lookup in the list of attributes of the received Resource. Semantic convention should be used for naming.
37
38
38
-
Pod association configuration.
39
+
Example for a pod association configuration:
39
40
40
41
```yaml
41
42
pod_association:
@@ -64,7 +65,31 @@ The following attributes are added by default:
64
65
- k8s.deployment.name
65
66
- k8s.node.name
66
67
67
-
You can change this list with `metadata` configuration.
68
+
These attributes are also available for the use within association rules by default.
69
+
The `metadata` section can also be extended with additional attributes which, if present in the `metadata` section,
70
+
are then also available for the use within association rules. Available attributes are:
71
+
- k8s.namespace.name
72
+
- k8s.pod.name
73
+
- k8s.pod.hostname
74
+
- k8s.pod.ip
75
+
- k8s.pod.start_time
76
+
- k8s.pod.uid
77
+
- k8s.replicaset.uid
78
+
- k8s.replicaset.name
79
+
- k8s.deployment.uid
80
+
- k8s.deployment.name
81
+
- k8s.daemonset.uid
82
+
- k8s.daemonset.name
83
+
- k8s.statefulset.uid
84
+
- k8s.statefulset.name
85
+
- k8s.cronjob.uid
86
+
- k8s.cronjob.name
87
+
- k8s.job.uid
88
+
- k8s.job.name
89
+
- k8s.node.name
90
+
- k8s.cluster.uid
91
+
- Any tags extracted from the pod labels and annotations, as described in [extracting attributes from metadata](#extracting-attributes-from-metadata)
92
+
68
93
69
94
Not all the attributes are guaranteed to be added. Only attribute names from `metadata` should be used for
70
95
pod_association's `resource_attribute`, because empty or non-existing values will be ignored.
@@ -84,6 +109,92 @@ Additional container level attributes can be extracted provided that certain res
84
109
instance. If it's not set, the latest container instance will be used:
85
110
- container.id (not added by default, has to be specified in `metadata`)
86
111
112
+
Please note, however, that container level attributes can't be used for source rules in the pod_association.
113
+
114
+
Example for extracting container level attributes:
115
+
116
+
```yaml
117
+
pod_association:
118
+
- sources:
119
+
- from: connection
120
+
extract:
121
+
metadata:
122
+
- k8s.pod.name
123
+
- k8s.pod.uid
124
+
- container.image.name
125
+
- container.image.tag
126
+
- k8s.container.name
127
+
```
128
+
129
+
The previous configuration attaches the attributes listed in the `metadata` section to all resources received by a matching pod with the `k8s.container.name` attribute being present. For example, when the following trace
## Extracting attributes from pod labels and annotations
197
+
87
198
The k8sattributesprocessor can also set resource attributes from k8s labels and annotations of pods, namespaces and nodes.
88
199
The config for associating the data passing through the processor (spans, metrics and logs) with specific Pod/Namespace/Node annotations/labels is configured via "annotations" and "labels" keys.
89
200
This config represents a list of annotations/labels that are extracted from pods/namespaces/nodes and added to spans, metrics and logs.
@@ -128,27 +239,33 @@ k8sattributes/2:
128
239
auth_type: "serviceAccount"
129
240
passthrough: false
130
241
filter:
242
+
# only retrieve pods running on the same node as the collector
131
243
node_from_env_var: KUBE_NODE_NAME
132
244
extract:
245
+
# The attributes provided in 'metadata' will be added to associated resources
133
246
metadata:
134
247
- k8s.pod.name
135
248
- k8s.pod.uid
136
249
- k8s.deployment.name
137
250
- k8s.namespace.name
138
251
- k8s.node.name
139
252
- k8s.pod.start_time
140
-
labels:
253
+
labels:
254
+
# This label extraction rule takes the value 'app.kubernetes.io/component' label and maps it to the 'app.label.component' attribute which will be added to the associated resources
141
255
- tag_name: app.label.component
142
256
key: app.kubernetes.io/component
143
257
from: pod
144
258
pod_association:
145
259
- sources:
260
+
# This rule associates all resources containing the 'k8s.pod.ip' attribute with the matching pods. If this attribute is not present in the resource, this rule will not be able to find the matching pod.
146
261
- from: resource_attribute
147
262
name: k8s.pod.ip
148
263
- sources:
264
+
# This rule associates all resources containing the 'k8s.pod.uid' attribute with the matching pods. If this attribute is not present in the resource, this rule will not be able to find the matching pod.
149
265
- from: resource_attribute
150
266
name: k8s.pod.uid
151
267
- sources:
268
+
# This rule will use the IP from the incoming connection from which the resource is received, and find the matching pod, based on the 'pod.status.podIP' of the observed pods
0 commit comments