Skip to content

Commit fbceec2

Browse files
fix: Standardize several naming conventions and fix incorrect host.* attributes
1 parent 3123cf1 commit fbceec2

File tree

4 files changed

+183
-62
lines changed

4 files changed

+183
-62
lines changed

charts/nr-k8s-otel-collector/templates/daemonset-configmap.yaml

+80-21
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ data:
227227
228228
metricstransform/kubeletstats:
229229
transforms:
230-
- include: container\.(cpu\.utilization|filesystem\.(capacity|usage)|memory\.usage)
230+
- include: container\.(cpu\.utilization|cpu\.usage|filesystem\.(capacity|usage)|memory\.usage)
231231
action: update
232232
match_type: regexp
233233
operations:
@@ -236,7 +236,7 @@ data:
236236
value_actions:
237237
- value: 'false'
238238
new_value: 'true'
239-
- include: k8s\.node\.(cpu\.(time|utilization)|filesystem\.(capacity|usage)|memory\.(available|working_set))
239+
- include: k8s\.node\.(cpu\.(time|utilization|usage)|filesystem\.(capacity|usage)|memory\.(available|working_set))
240240
action: update
241241
match_type: regexp
242242
operations:
@@ -460,7 +460,7 @@ data:
460460
461461
resource:
462462
attributes:
463-
# TODO (chris): Upsert only when cluster name not found (resource detection override: true)
463+
# We set the cluster name to what the customer specified in the helm chart
464464
- key: k8s.cluster.name
465465
action: upsert
466466
value: {{ include "newrelic.common.cluster" . }}
@@ -488,6 +488,82 @@ data:
488488
- key: net.host.port
489489
action: delete
490490
491+
resource/remove_duplicate_attributes:
492+
attributes:
493+
- key: node
494+
action: delete
495+
- key: namespace
496+
action: delete
497+
- key: pod
498+
action: delete
499+
- key: container
500+
action: delete
501+
- key: replicaset
502+
action: delete
503+
- key: deployment
504+
action: delete
505+
- key: statefulset
506+
action: delete
507+
- key: daemonset
508+
action: delete
509+
- key: job_name
510+
action: delete
511+
- key: cronjob
512+
action: delete
513+
- key: replicationcontroller
514+
action: delete
515+
- key: horizontalpodautoscaler
516+
action: delete
517+
- key: resourcequota
518+
action: delete
519+
- key: volumename
520+
action: delete
521+
522+
attributes/self:
523+
actions:
524+
- key: k8s.node.name
525+
action: upsert
526+
from_attribute: node
527+
- key: k8s.namespace.name
528+
action: upsert
529+
from_attribute: namespace
530+
- key: k8s.pod.name
531+
action: upsert
532+
from_attribute: pod
533+
- key: k8s.container.name
534+
action: upsert
535+
from_attribute: container
536+
- key: k8s.replicaset.name
537+
action: upsert
538+
from_attribute: replicaset
539+
- key: k8s.deployment.name
540+
action: upsert
541+
from_attribute: deployment
542+
- key: k8s.statefulset.name
543+
action: upsert
544+
from_attribute: statefulset
545+
- key: k8s.daemonset.name
546+
action: upsert
547+
from_attribute: daemonset
548+
- key: k8s.job.name
549+
action: upsert
550+
from_attribute: job_name
551+
- key: k8s.cronjob.name
552+
action: upsert
553+
from_attribute: cronjob
554+
- key: k8s.replicationcontroller.name
555+
action: upsert
556+
from_attribute: replicationcontroller
557+
- key: k8s.hpa.name
558+
action: upsert
559+
from_attribute: horizontalpodautoscaler
560+
- key: k8s.resourcequota.name
561+
action: upsert
562+
from_attribute: resourcequota
563+
- key: k8s.volume.name
564+
action: upsert
565+
from_attribute: volumename
566+
491567
k8sattributes:
492568
auth_type: "serviceAccount"
493569
passthrough: false
@@ -507,24 +583,6 @@ data:
507583
- from: resource_attribute
508584
name: k8s.pod.uid
509585
510-
attributes/self:
511-
actions:
512-
- key: k8s.pod.name
513-
action: upsert
514-
from_attribute: pod
515-
- key: k8s.deployment.name
516-
action: update
517-
from_attribute: deployment
518-
- key: k8s.daemonset.name
519-
action: update
520-
from_attribute: daemonset
521-
- key: k8s.node.name
522-
action: update
523-
from_attribute: node
524-
- key: k8s.namespace.name
525-
action: upsert
526-
from_attribute: namespace
527-
528586
memory_limiter:
529587
check_interval: 1s
530588
limit_percentage: 80
@@ -596,6 +654,7 @@ data:
596654
{{- end }}
597655
- attributes/self
598656
- k8sattributes
657+
- resource/remove_duplicate_attributes
599658
- memory_limiter
600659
- cumulativetodelta
601660
- batch

charts/nr-k8s-otel-collector/templates/daemonset.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
{{- end }}
4242
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
4343
imagePullPolicy: {{ .Values.image.pullPolicy }}
44-
args: ["--config", "/config/daemonset-config.yaml"]
44+
args: ["--config", "/config/daemonset-config.yaml", "--feature-gates","receiver.kubeletstats.enableCPUUsageMetrics"]
4545
resources:
4646
{{- toYaml .Values.daemonset.resources | nindent 12 }}
4747
{{- with .Values.daemonset.envsFrom }}

charts/nr-k8s-otel-collector/templates/deployment-configmap.yaml

+100-38
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ data:
3232
target_label: job_label
3333
replacement: kube-state-metrics
3434
35-
prometheus:
35+
prometheus/controlplane:
3636
config:
3737
scrape_configs:
3838
- job_name: apiserver
@@ -97,21 +97,36 @@ data:
9797
metric_statements:
9898
- context: resource
9999
statements:
100-
- delete_key(attributes, "k8s.pod.name")
100+
- delete_key(attributes, "k8s.node.name")
101+
- delete_key(attributes, "k8s.namespace.name")
101102
- delete_key(attributes, "k8s.pod.uid")
103+
- delete_key(attributes, "k8s.pod.name")
102104
- delete_key(attributes, "k8s.container.name")
103-
- delete_key(attributes, "k8s.namespace.name")
104-
- delete_key(attributes, "k8s.node.name")
105105
- delete_key(attributes, "k8s.replicaset.name")
106-
- set(attributes["k8s.pod.name"], attributes["pod"])
107-
- set(attributes["k8s.daemonset.name"], attributes["daemonset"])
108-
- set(attributes["k8s.replicaset.name"], attributes["replicaset"])
109-
- set(attributes["k8s.statefulset.name"], attributes["statefulset"])
110-
- set(attributes["k8s.deployment.name"], attributes["deployment"])
106+
- delete_key(attributes, "k8s.deployment.name")
107+
- delete_key(attributes, "k8s.statefulset.name")
108+
- delete_key(attributes, "k8s.daemonset.name")
109+
- delete_key(attributes, "k8s.job.name")
110+
- delete_key(attributes, "k8s.cronjob.name")
111+
- delete_key(attributes, "k8s.replicationcontroller.name")
112+
- delete_key(attributes, "k8s.hpa.name")
113+
- delete_key(attributes, "k8s.resourcequota.name")
114+
- delete_key(attributes, "k8s.volume.name")
115+
- set(attributes["k8s.uid.uid"], attributes["uid"])
111116
- set(attributes["k8s.node.name"], attributes["node"])
112117
- set(attributes["k8s.namespace.name"], attributes["namespace"])
118+
- set(attributes["k8s.pod.name"], attributes["pod"])
113119
- set(attributes["k8s.container.name"], attributes["container"])
114-
- set(attributes["k8s.uid.uid"], attributes["uid"])
120+
- set(attributes["k8s.replicaset.name"], attributes["replicaset"])
121+
- set(attributes["k8s.deployment.name"], attributes["deployment"])
122+
- set(attributes["k8s.statefulset.name"], attributes["statefulset"])
123+
- set(attributes["k8s.daemonset.name"], attributes["daemonset"])
124+
- set(attributes["k8s.job.name"], attributes["job_name"])
125+
- set(attributes["k8s.cronjob.name"], attributes["cronjob"])
126+
- set(attributes["k8s.replicationcontroller.name"], attributes["replicationcontroller"])
127+
- set(attributes["k8s.hpa.name"], attributes["horizontalpodautoscaler"])
128+
- set(attributes["k8s.resourcequota.name"], attributes["resourcequota"])
129+
- set(attributes["k8s.volume.name"], attributes["volumename"])
115130
116131
metricstransform/k8s_cluster_info:
117132
transforms:
@@ -241,7 +256,7 @@ data:
241256
value_actions:
242257
- value: 'false'
243258
new_value: 'true'
244-
- include: kube_pod_container_(resource_(limits|requests)|status_(phase|ready|restarts_total|waiting_reason))
259+
- include: kube_pod_container_(info|resource_(limits|requests)|status_(phase|ready|restarts_total|waiting_reason))
245260
action: update
246261
match_type: regexp
247262
operations:
@@ -333,30 +348,14 @@ data:
333348
datapoint:
334349
- metric.name == "kube_pod_container_status" and value_double == 0.0
335350
336-
resourcedetection/env:
337-
detectors: ["env", "system"]
338-
override: false
339-
system:
340-
hostname_sources: ["os"]
341-
resource_attributes:
342-
host.id:
343-
enabled: true
344-
345351
resourcedetection/cloudproviders:
346-
detectors: [gcp, eks, azure, aks, ec2, ecs]
352+
detectors: [gcp, eks, ec2, aks, azure]
347353
timeout: 2s
348354
override: false
349-
ec2:
350-
resource_attributes:
351-
host.name:
352-
enabled: false
353355
354356
resource/metrics:
355357
attributes:
356-
- key: host.id
357-
from_attribute: host.name
358-
action: upsert
359-
# TODO (chris): Upsert only when cluster name not found (resource detection override: true)
358+
# We set the cluster name to what the customer specified in the helm chart
360359
- key: k8s.cluster.name
361360
action: upsert
362361
value: {{ include "newrelic.common.cluster" . }}
@@ -408,6 +407,37 @@ data:
408407
- key: net.host.port
409408
action: delete
410409
410+
resource/remove_duplicate_attributes:
411+
attributes:
412+
- key: node
413+
action: delete
414+
- key: namespace
415+
action: delete
416+
- key: pod
417+
action: delete
418+
- key: container
419+
action: delete
420+
- key: replicaset
421+
action: delete
422+
- key: deployment
423+
action: delete
424+
- key: statefulset
425+
action: delete
426+
- key: daemonset
427+
action: delete
428+
- key: job_name
429+
action: delete
430+
- key: cronjob
431+
action: delete
432+
- key: replicationcontroller
433+
action: delete
434+
- key: horizontalpodautoscaler
435+
action: delete
436+
- key: resourcequota
437+
action: delete
438+
- key: volumename
439+
action: delete
440+
411441
cumulativetodelta:
412442
413443
k8sattributes:
@@ -420,6 +450,7 @@ data:
420450
- k8s.pod.name
421451
- k8s.pod.uid
422452
- k8s.deployment.name
453+
- k8s.daemonset.name
423454
- k8s.namespace.name
424455
- k8s.node.name
425456
- k8s.pod.start_time
@@ -430,18 +461,48 @@ data:
430461
431462
attributes/self:
432463
actions:
464+
- key: k8s.node.name
465+
action: upsert
466+
from_attribute: node
467+
- key: k8s.namespace.name
468+
action: upsert
469+
from_attribute: namespace
433470
- key: k8s.pod.name
434471
action: upsert
435472
from_attribute: pod
473+
- key: k8s.container.name
474+
action: upsert
475+
from_attribute: container
476+
- key: k8s.replicaset.name
477+
action: upsert
478+
from_attribute: replicaset
436479
- key: k8s.deployment.name
437480
action: upsert
438481
from_attribute: deployment
439-
- key: k8s.node.name
482+
- key: k8s.statefulset.name
440483
action: upsert
441-
from_attribute: node
442-
- key: k8s.namespace.name
484+
from_attribute: statefulset
485+
- key: k8s.daemonset.name
443486
action: upsert
444-
from_attribute: namespace
487+
from_attribute: daemonset
488+
- key: k8s.job.name
489+
action: upsert
490+
from_attribute: job_name
491+
- key: k8s.cronjob.name
492+
action: upsert
493+
from_attribute: cronjob
494+
- key: k8s.replicationcontroller.name
495+
action: upsert
496+
from_attribute: replicationcontroller
497+
- key: k8s.hpa.name
498+
action: upsert
499+
from_attribute: horizontalpodautoscaler
500+
- key: k8s.resourcequota.name
501+
action: upsert
502+
from_attribute: resourcequota
503+
- key: k8s.volume.name
504+
action: upsert
505+
from_attribute: volumename
445506
446507
memory_limiter:
447508
check_interval: 1s
@@ -483,19 +544,19 @@ data:
483544
- transform/low_data_mode_inator
484545
- resource/low_data_mode_inator
485546
{{- end }}
547+
# - resourcedetection/cloudproviders
486548
- resource/metrics
487-
- resourcedetection/env
488-
- resourcedetection/cloudproviders
489-
- batch
490549
- groupbyattrs
491550
- transform/ksm
551+
- resource/remove_duplicate_attributes
552+
- batch
492553
exporters:
493554
- otlphttp/newrelic
494555
{{- end }}
495556
{{- if .Values.receivers.prometheus.enabled }}
496557
metrics:
497558
receivers:
498-
- prometheus
559+
- prometheus/controlplane
499560
processors:
500561
- metricstransform/k8s_cluster_info
501562
{{- if include "nrKubernetesOtel.lowDataMode" . }}
@@ -507,8 +568,9 @@ data:
507568
- resource/low_data_mode_inator
508569
{{- end }}
509570
- resource/metrics
510-
- k8sattributes
511571
- attributes/self
572+
- k8sattributes
573+
- resource/remove_duplicate_attributes
512574
- memory_limiter
513575
- cumulativetodelta
514576
- batch

charts/nr-k8s-otel-collector/values.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ kube-state-metrics:
1313

1414
image:
1515
# -- OTel collector image to be deployed. You can use your own collector as long it accomplish the following requirements mentioned below.
16-
repository: newrelic/nr-otel-collector
16+
repository: otel/opentelemetry-collector-contrib
1717
# -- The pull policy is defaulted to IfNotPresent, which skips pulling an image if it already exists. If pullPolicy is defined without a specific value, it is also set to Always.
1818
pullPolicy: IfNotPresent
1919
# -- Overrides the image tag whose default is the chart appVersion.
20-
tag: "0.8.3"
20+
tag: "0.121.0"
2121

2222
# -- Name of the Kubernetes cluster monitored. Mandatory. Can be configured also with `global.cluster`
2323
cluster: ""

0 commit comments

Comments
 (0)