Skip to content

Commit 5ff483e

Browse files
Kinda works...
1 parent 1066784 commit 5ff483e

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,17 @@ data:
479479
metric1: k8s.pod.cpu_limit_utilization
480480
metric2: k8s.pod.cpu_request_utilization
481481
operation: divide
482+
- name: node.cpu.usage.percentage
483+
type: scale
484+
metric1: k8s.node.cpu.usage
485+
scale_by: CPU_PLACEHOLDER
486+
operation: divide
487+
{{/* - name: node.memory.usage.percentage*/}}
488+
{{/* type: scale*/}}
489+
{{/* metric1: k8s.node.memory.working_set*/}}
490+
{{/* scale_by: ${NODE_MEMORY_ALLOCATABLE}*/}}
491+
{{/* operation: divide*/}}
492+
482493

483494
transform/tag_generated_metrics_ldm:
484495
metric_statements:

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@ spec:
3434
dnsConfig:
3535
{{- . | nindent 8 }}
3636
{{- end }}
37+
initContainers:
38+
- name: get-cpu-allocatable
39+
image: bitnami/kubectl:latest
40+
command:
41+
- sh
42+
- -c
43+
- |
44+
NODE_NAME=$(echo $KUBE_NODE_NAME)
45+
echo "Node Name: $KUBE_NODE_NAME"
46+
export NODE_CPU_ALLOCATABLE=$(kubectl get node $NODE_NAME -o jsonpath='{.status.allocatable.cpu}')
47+
echo "NODE_CPU_ALLOCATABLE : $NODE_CPU_ALLOCATABLE"
48+
cp /temp-config/daemonset-config.yaml /final-config
49+
yq -i '.processors.metricsgeneration/calculate_percentage.rules[2].scale_by = env(NODE_CPU_ALLOCATABLE)' /final-config/daemonset-config.yaml
50+
cat /final-config/daemonset-config.yaml
51+
env:
52+
- name: KUBE_NODE_NAME
53+
valueFrom:
54+
fieldRef:
55+
apiVersion: v1
56+
fieldPath: spec.nodeName
57+
volumeMounts:
58+
- name: daemonset-config
59+
mountPath: /temp-config
60+
- name: final-daemonset-config
61+
mountPath: /final-config
3762
containers:
3863
- name: otel-collector-daemonset
3964
{{- with include "nrKubernetesOtel.daemonset.securityContext.container" . }}
@@ -101,7 +126,7 @@ spec:
101126
- name: varlogpods
102127
mountPath: /var/log/pods
103128
readOnly: true
104-
- name: daemonset-config
129+
- name: final-daemonset-config
105130
mountPath: /config
106131
{{- with .Values.daemonset.extraVolumeMounts }}
107132
{{- toYaml . | nindent 12 }}
@@ -115,6 +140,8 @@ spec:
115140
- name: varlogpods
116141
hostPath:
117142
path: /var/log/pods
143+
- name: final-daemonset-config
144+
emptyDir: {}
118145
- name: daemonset-config
119146
configMap:
120147
name: {{ include "nrKubernetesOtel.daemonset.configMap.fullname" . }}

0 commit comments

Comments
 (0)