Skip to content

Commit ae7f217

Browse files
feat: Adds k8sObjects event receiver under feature flag (#4127)
By default helm chart uses raw_k8s_events receiver. The feature flag has to be set to false in order to use k8sObjects receiver for fetching events. Signed-off-by: Dhruv Shah <dhruv.shah@sumologic.com>
1 parent e53ce09 commit ae7f217

File tree

6 files changed

+790
-618
lines changed

6 files changed

+790
-618
lines changed

.changelog/4127.added.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: Adds k8sObjects event receiver under feature flag

deploy/helm/sumologic/README.md

Lines changed: 619 additions & 618 deletions
Large diffs are not rendered by default.

deploy/helm/sumologic/conf/events/otelcol/config.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,39 @@ processors:
6060
- set(time, Now()) where time_unix_nano == 0
6161
- set(attributes["timestamp"], Int(time_unix_nano / 1000000))
6262

63+
{{- if not .Values.otelevents.useSumoK8sEventReceiver }}
64+
## Reformat body to align k8sobjects payload format with the older raw_k8s_events format
65+
## so that existing event queries continue to work
66+
transform/reformat_body:
67+
log_statements:
68+
- context: log
69+
statements:
70+
# Copy 'object' from body to attributes
71+
- set(attributes["object"], body["object"])
72+
# Copy 'type' from body to attributes
73+
- set(attributes["type"], body["type"])
74+
# Lift 'message' out of 'object' and put it in 'body'
75+
- set(body, attributes["object"]["message"])
76+
77+
## Drop DELETED and other non-watch events (keep only ADDED and MODIFIED)
78+
filter/watch_types:
79+
logs:
80+
log_record:
81+
- attributes["type"] != "ADDED" and attributes["type"] != "MODIFIED"
82+
83+
## Populate severity_text and severity_number from the event type field
84+
transform/set_severity:
85+
log_statements:
86+
- context: log
87+
statements:
88+
# Warning → WARN (13)
89+
- set(severity_text, "Warning") where attributes["object"]["type"] == "Warning"
90+
- set(severity_number, 13) where attributes["object"]["type"] == "Warning"
91+
# Normal → INFO (9)
92+
- set(severity_text, "Normal") where attributes["object"]["type"] == "Normal"
93+
- set(severity_number, 9) where attributes["object"]["type"] == "Normal"
94+
{{- end }}
95+
6396
{{- if .Values.otelevents.reportConfigMaps }}
6497
## Extract configmap name and chart label from body
6598
transform/extract_configmap_name:
@@ -91,7 +124,15 @@ receivers:
91124
mode: pull
92125
interval: 24h
93126
{{- end }}
127+
{{- if .Values.otelevents.useSumoK8sEventReceiver }}
94128
raw_k8s_events: {}
129+
{{- else }}
130+
k8sobjects/events:
131+
auth_type: serviceAccount
132+
objects:
133+
- name: events
134+
mode: watch
135+
{{- end }}
95136

96137
service:
97138
extensions:
@@ -132,13 +173,22 @@ service:
132173
- sumologic/sumologic-mock
133174
{{- end }}
134175
processors:
176+
{{- if not .Values.otelevents.useSumoK8sEventReceiver }}
177+
- transform/reformat_body
178+
- filter/watch_types
179+
- transform/set_severity
180+
{{- end }}
135181
- resource/add_cluster
136182
- source
137183
- sumologic
138184
- transform/add_timestamp
139185
- batch
140186
receivers:
187+
{{- if .Values.otelevents.useSumoK8sEventReceiver }}
141188
- raw_k8s_events
189+
{{- else }}
190+
- k8sobjects/events
191+
{{- end }}
142192

143193

144194
telemetry:

deploy/helm/sumologic/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,11 @@ otelevents:
20712071
## Metrics Level (basic, normal, detailed)
20722072
metricsLevel: normal
20732073

2074+
## When true (default), use the in-house raw_k8s_events receiver for Kubernetes event collection.
2075+
## When false, use the upstream k8sobjects receiver with additional transform and filter processors.
2076+
## Note: k8sobjects receiver does not de-duplicate events on collector restarts.
2077+
useSumoK8sEventReceiver: true
2078+
20742079
## Enable reporting of ConfigMaps. Only Sumologic collection configmaps are reported for now.
20752080
reportConfigMaps: true
20762081

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
otelevents:
2+
useSumoK8sEventReceiver: false
3+
reportConfigMaps: false
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
# Source: sumologic/templates/events/otelcol/configmap.yaml
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: RELEASE-NAME-sumologic-otelcol-events
7+
namespace: sumologic
8+
labels:
9+
app: RELEASE-NAME-sumologic-otelcol-events
10+
chart: "sumologic-%CURRENT_CHART_VERSION%"
11+
release: "RELEASE-NAME"
12+
heritage: "Helm"
13+
data:
14+
config.yaml: |
15+
exporters:
16+
sumologic:
17+
client: k8s_%CURRENT_CHART_VERSION%
18+
endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_EVENTS_SOURCE}
19+
log_format: otlp
20+
sending_queue:
21+
enabled: true
22+
storage: file_storage
23+
extensions:
24+
file_storage:
25+
directory: /var/lib/storage/events
26+
timeout: 10s
27+
health_check:
28+
endpoint: ${env:MY_POD_IP}:13133
29+
pprof: {}
30+
processors:
31+
batch:
32+
send_batch_max_size: 2048
33+
send_batch_size: 1024
34+
timeout: 1s
35+
filter/watch_types:
36+
logs:
37+
log_record:
38+
- attributes["type"] != "ADDED" and attributes["type"] != "MODIFIED"
39+
resource/add_cluster:
40+
attributes:
41+
- action: upsert
42+
key: cluster
43+
value: kubernetes
44+
source:
45+
collector: kubernetes
46+
source_category: kubernetes/events
47+
source_category_prefix: ""
48+
source_category_replace_dash: /
49+
source_name: events
50+
sumologic:
51+
add_cloud_namespace: false
52+
transform/add_timestamp:
53+
log_statements:
54+
- context: log
55+
statements:
56+
- set(time, Now()) where time_unix_nano == 0
57+
- set(attributes["timestamp"], Int(time_unix_nano / 1000000))
58+
transform/reformat_body:
59+
log_statements:
60+
- context: log
61+
statements:
62+
- set(attributes["object"], body["object"])
63+
- set(attributes["type"], body["type"])
64+
- set(body, attributes["object"]["message"])
65+
transform/set_severity:
66+
log_statements:
67+
- context: log
68+
statements:
69+
- set(severity_text, "Warning") where attributes["object"]["type"] == "Warning"
70+
- set(severity_number, 13) where attributes["object"]["type"] == "Warning"
71+
- set(severity_text, "Normal") where attributes["object"]["type"] == "Normal"
72+
- set(severity_number, 9) where attributes["object"]["type"] == "Normal"
73+
receivers:
74+
k8sobjects/events:
75+
auth_type: serviceAccount
76+
objects:
77+
- mode: watch
78+
name: events
79+
service:
80+
extensions:
81+
- health_check
82+
- file_storage
83+
- pprof
84+
pipelines:
85+
logs/events:
86+
exporters:
87+
- sumologic
88+
processors:
89+
- transform/reformat_body
90+
- filter/watch_types
91+
- transform/set_severity
92+
- resource/add_cluster
93+
- source
94+
- sumologic
95+
- transform/add_timestamp
96+
- batch
97+
receivers:
98+
- k8sobjects/events
99+
telemetry:
100+
logs:
101+
level: info
102+
metrics:
103+
level: normal
104+
readers:
105+
- pull:
106+
exporter:
107+
prometheus:
108+
host: ${env:MY_POD_IP}
109+
port: 8888
110+
without_scope_info: true
111+
without_type_suffix: true
112+
without_units: true

0 commit comments

Comments
 (0)