Skip to content

Commit 2df73d7

Browse files
feat: add heartbeat configs (#430)
* feat: add agent heartbeat configs * update helm chart to include heartbeat configs * add podUID env var to pass through for matching * rm unnecessary processors * use new agent version * move configs around a little * CR * add pod name too * remove unnecessary cloud resource detection processor * fix e2e's? * for some reason this is a patch change * update exporter * add helper to check for pod.uid env var * bump to 2.10.1
1 parent 8bd30f9 commit 2df73d7

24 files changed

+443
-105
lines changed

charts/agent/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v2
22
name: agent
33
description: Chart to install K8s collection stack based on Observe Agent
44
type: application
5-
version: 0.74.2
6-
appVersion: "2.9.1"
5+
version: 0.74.3
6+
appVersion: "2.10.1"
77
dependencies:
88
- name: opentelemetry-collector
99
version: 0.136.1

charts/agent/README.md

Lines changed: 125 additions & 94 deletions
Large diffs are not rendered by default.

charts/agent/ci/test-values.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
observe:
22
collectionEndpoint:
3-
collectionEndpoint: "http://test-stack-collector.testing.svc.cluster.local:8080"
3+
value: "http://test-stack-collector.testing.svc.cluster.local:8080"
44
token:
55
create: true
6-
value: "fake-token"
6+
value: "fake-ds:fake-token"
77

88
application:
99
prometheusScrape:
@@ -24,6 +24,14 @@ gatewayDeployment:
2424
traceSampling:
2525
enabled: true
2626

27+
agent:
28+
config:
29+
global:
30+
fleet:
31+
enabled: true
32+
interval: 10s
33+
configInterval: 10m
34+
2735
cluster:
2836
namespaceOverride:
2937
value: "testing"

charts/agent/templates/_cluster-events-config.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ exporters:
44
{{- include "config.exporters.debug" . | nindent 2 }}
55
{{- include "config.exporters.otlphttp.observe.entity" . | nindent 2 }}
66

7+
{{- if .Values.agent.config.global.fleet.enabled }}
8+
{{- include "config.exporters.otlphttp.observe.metrics.agentheartbeat" . | nindent 2 }}
9+
{{- end }}
10+
711
receivers:
812
# this is used to create a cluster resource by pulling namespaces and then dropping all but kube-system with filter processor
913
k8sobjects/cluster:
@@ -64,6 +68,10 @@ receivers:
6468
- {name: serviceaccounts, mode: pull, interval: 15m}
6569
- {name: serviceaccounts, mode: watch}
6670

71+
{{- if .Values.agent.config.global.fleet.enabled }}
72+
{{- include "config.receivers.observe.heartbeat" . | nindent 2 }}
73+
{{- end }}
74+
6775
processors:
6876
{{- include "config.processors.memory_limiter" . | nindent 2 }}
6977

@@ -78,6 +86,13 @@ processors:
7886

7987
{{- include "config.processors.attributes.observek8sattributes" . | nindent 2 }}
8088

89+
{{- if .Values.agent.config.global.fleet.enabled }}
90+
{{- include "config.processors.attributes.k8sattributes" . | nindent 2 }}
91+
{{- include "config.processors.resource_detection" . | nindent 2 }}
92+
{{- include "config.processors.resource.agent_instance" . | nindent 2 }}
93+
{{- include "config.processors.transform.k8sheartbeat" . | nindent 2 }}
94+
{{- end }}
95+
8196
transform/unify:
8297
error_mode: ignore
8398
log_statements:
@@ -451,4 +466,8 @@ service:
451466
processors: [memory_limiter, batch, resource/observe_common, filter/cluster, transform/cluster]
452467
exporters: [{{ join ", " $logsClusterExporters }}]
453468

469+
{{- if .Values.agent.config.global.fleet.enabled }}
470+
{{- include "config.pipelines.heartbeat" . | nindent 6 }}
471+
{{- end }}
472+
454473
{{- end }}

charts/agent/templates/_cluster-metrics-config.tpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ exporters:
66
{{- include "config.exporters.debug" . | nindent 2 }}
77
{{- include "config.exporters.prometheusremotewrite" . | nindent 2 }}
88

9+
{{- if .Values.agent.config.global.fleet.enabled }}
10+
{{- include "config.exporters.otlphttp.observe.metrics.agentheartbeat" . | nindent 2 }}
11+
{{- end }}
12+
913
receivers:
1014
# https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/k8sclusterreceiver/documentation.md
1115
k8s_cluster:
@@ -31,6 +35,10 @@ receivers:
3135
{{- include "config.receivers.prometheus.cadvisor" . | nindent 2 }}
3236
{{- end }}
3337

38+
{{- if .Values.agent.config.global.fleet.enabled }}
39+
{{- include "config.receivers.observe.heartbeat" . | nindent 2 }}
40+
{{- end }}
41+
3442
processors:
3543
{{- include "config.processors.memory_limiter" . | nindent 2 }}
3644
{{- include "config.processors.batch" . | nindent 2 }}
@@ -42,6 +50,12 @@ processors:
4250
{{- if $podMetrics }}
4351
{{- include "config.processors.attributes.pod_metrics" . | nindent 2 }}
4452
{{- include "config.processors.attributes.cadvisor_metrics" . | nindent 2 }}
53+
{{- end }}
54+
55+
{{- if .Values.agent.config.global.fleet.enabled }}
56+
{{- include "config.processors.resource_detection" . | nindent 2 }}
57+
{{- include "config.processors.resource.agent_instance" . | nindent 2 }}
58+
{{- include "config.processors.transform.k8sheartbeat" . | nindent 2 }}
4559
{{- end }}
4660

4761
# attributes to append to objects
@@ -67,4 +81,8 @@ service:
6781
{{- include "config.pipelines.prometheus_scrapers" . | nindent 4 }}
6882
{{- end }}
6983

84+
{{- if .Values.agent.config.global.fleet.enabled }}
85+
{{- include "config.pipelines.heartbeat" . | nindent 4 }}
86+
{{- end }}
87+
7088
{{- end }}

charts/agent/templates/_config-exporters.tpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ otlphttp/observe/forward/trace:
5555
compression: zstd
5656
{{- end -}}
5757

58+
{{- define "config.exporters.otlphttp.observe.metrics.agentheartbeat" -}}
59+
otlphttp/observe/agentheartbeat:
60+
# These environment variables are provided by the observe-agent:
61+
# https://github.com/observeinc/observe-agent/blob/v2.0.1/internal/connections/confighandler.go#L91-L102
62+
logs_endpoint: "${env:OBSERVE_COLLECTOR_URL}/v1/kubernetes/v1/entity"
63+
headers:
64+
authorization: "${env:OBSERVE_AUTHORIZATION_HEADER}"
65+
x-observe-target-package: "Observe Agent"
66+
x-observe-context: {{ mustToJson (dict "version" "${env:OBSERVE_AGENT_VERSION}" "environment" "kubernetes" ) | toYaml }}
67+
x-observe-enable-auth-error-reporting: "true"
68+
sending_queue:
69+
enabled: {{ .Values.agent.config.global.exporters.sendingQueue.enabled }}
70+
retry_on_failure:
71+
enabled: {{ .Values.agent.config.global.exporters.retryOnFailure.enabled }}
72+
initial_interval: {{ .Values.agent.config.global.exporters.retryOnFailure.initialInterval }}
73+
max_interval: {{ .Values.agent.config.global.exporters.retryOnFailure.maxInterval }}
74+
max_elapsed_time: {{ .Values.agent.config.global.exporters.retryOnFailure.maxElapsedTime }}
75+
compression: zstd
76+
{{- end -}}
77+
5878
{{- define "config.exporters.otlphttp.observe.metrics.otel" -}}
5979
otlphttp/observe/otel_metrics:
6080
# These environment variables are provided by the observe-agent:

charts/agent/templates/_config-pipelines.tpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,19 @@ metrics/cadvisor:
6363
{{- end }}
6464

6565
{{- end }}
66+
67+
{{- define "config.pipelines.heartbeat" -}}
68+
logs/heartbeat:
69+
exporters:
70+
- otlphttp/observe/agentheartbeat
71+
{{- if .Values.agent.config.global.debug.enabled }}
72+
- debug/override
73+
{{- end }}
74+
processors:
75+
- resourcedetection
76+
- resource/agent_instance
77+
- k8sattributes
78+
- transform/k8sheartbeat
79+
receivers:
80+
- heartbeat
81+
{{- end }}

charts/agent/templates/_config-processors.tpl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ resourcedetection/cloud:
55
override: false
66
{{- end -}}
77

8+
{{- define "config.processors.resource_detection" -}}
9+
resourcedetection:
10+
detectors: ["env", "system"]
11+
timeout: 2s
12+
override: false
13+
{{- end -}}
14+
815
{{- define "config.processors.batch" -}}
916
batch:
1017
send_batch_size: {{ .Values.agent.config.global.processors.batch.sendBatchSize }}
@@ -84,6 +91,30 @@ resource/observe_common:
8491
{{ end }}
8592
{{- end -}}
8693

94+
{{- define "config.processors.resource.agent_instance" -}}
95+
resource/agent_instance:
96+
attributes:
97+
- key: k8s.pod.uid
98+
value: ${env:OTEL_K8S_POD_UID}
99+
action: upsert
100+
- key: k8s.pod.name
101+
value: ${env:OTEL_K8S_POD_NAME}
102+
action: upsert
103+
{{- end -}}
104+
105+
{{- define "config.processors.transform.k8sheartbeat" -}}
106+
transform/k8sheartbeat:
107+
error_mode: ignore
108+
log_statements:
109+
- context: log
110+
statements:
111+
- set(attributes["observe_transform"]["identifiers"]["host.name"], resource.attributes["k8s.node.name"])
112+
- set(attributes["observe_transform"]["identifiers"]["k8s.pod.uid"], resource.attributes["k8s.pod.uid"])
113+
- set(attributes["observe_transform"]["identifiers"]["k8s.pod.name"], resource.attributes["k8s.pod.name"])
114+
- set(attributes["observe_transform"]["identifiers"]["k8s.deployment.name"], resource.attributes["k8s.deployment.name"])
115+
- set(attributes["observe_transform"]["identifiers"]["k8s.daemonset.name"], resource.attributes["k8s.daemonset.name"])
116+
{{- end -}}
117+
87118
{{- define "config.processors.memory_limiter" -}}
88119
# https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/memorylimiterprocessor/README.md
89120
memory_limiter:

charts/agent/templates/_config-receivers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,14 @@ prometheus/cadvisor:
137137
replacement: /api/v1/nodes/$$1/proxy/metrics/cadvisor
138138
{{ end }}
139139
{{ end }}
140+
141+
{{- define "config.receivers.observe.heartbeat" -}}
142+
heartbeat:
143+
auth_check:
144+
headers:
145+
authorization: "${env:OBSERVE_AUTHORIZATION_HEADER}"
146+
url: "${env:OBSERVE_COLLECTOR_URL}"
147+
environment: kubernetes
148+
interval: {{ .Values.agent.config.global.fleet.interval }}
149+
config_interval: {{ .Values.agent.config.global.fleet.configInterval }}
150+
{{- end }}

charts/agent/templates/_forwarder-config.tpl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ exporters:
3535
{{- include "config.exporters.prometheusremotewrite" . | nindent 2 }}
3636
{{- end }}
3737

38+
{{- if .Values.agent.config.global.fleet.enabled }}
39+
{{- include "config.exporters.otlphttp.observe.metrics.agentheartbeat" . | nindent 2 }}
40+
{{- end }}
41+
3842
receivers:
3943
otlp/app-telemetry:
4044
protocols:
@@ -43,6 +47,10 @@ receivers:
4347
http:
4448
endpoint: ${env:MY_POD_IP}:4318
4549

50+
{{- if .Values.agent.config.global.fleet.enabled }}
51+
{{- include "config.receivers.observe.heartbeat" . | nindent 2 }}
52+
{{- end }}
53+
4654
processors:
4755

4856
{{- include "config.processors.memory_limiter" . | nindent 2 }}
@@ -54,6 +62,10 @@ processors:
5462
# Use passthrough mode to reduce forwarder compute and push the lookup to the gateway whenever it is enabled.
5563
k8sattributes/passthrough:
5664
passthrough: true
65+
{{- if .Values.agent.config.global.fleet.enabled }}
66+
# k8sattributes is needed for the heartbeat pipeline even when gateway is enabled
67+
{{- include "config.processors.attributes.k8sattributes" . | nindent 2 }}
68+
{{- end }}
5769
{{- else }}
5870
{{- include "config.processors.attributes.k8sattributes" . | nindent 2 }}
5971
{{- include "config.processors.resource.observe_common" . | nindent 2 }}
@@ -90,6 +102,12 @@ processors:
90102
{{- include "config.processors.RED_metrics" . | nindent 2 }}
91103
{{- end }}
92104

105+
{{- if .Values.agent.config.global.fleet.enabled }}
106+
{{- include "config.processors.resource_detection" . | nindent 2 }}
107+
{{- include "config.processors.resource.agent_instance" . | nindent 2 }}
108+
{{- include "config.processors.transform.k8sheartbeat" . | nindent 2 }}
109+
{{- end }}
110+
93111
{{- $traceExporters := (list) -}}
94112
{{- $logsExporters := (list) -}}
95113
{{- $metricsExporters := (list) -}}
@@ -185,4 +203,8 @@ service:
185203
{{- include "config.pipelines.RED_metrics" . | nindent 4 }}
186204
{{- end }}
187205

206+
{{- if .Values.agent.config.global.fleet.enabled }}
207+
{{- include "config.pipelines.heartbeat" . | nindent 4 }}
208+
{{- end }}
209+
188210
{{- end }}

0 commit comments

Comments
 (0)