Skip to content

Add k8sevent transform #1691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 6, 2025
Merged

Add k8sevent transform #1691

merged 5 commits into from
Mar 6, 2025

Conversation

jinja2
Copy link
Collaborator

@jinja2 jinja2 commented Mar 5, 2025

Description:

For the option, clusterReceiver.eventsEnabled, the logs pipeline for k8s_events now adds attributes of the type k8s.<objectkind>.name and k8s.<objectkind>.uid.

Link to Splunk idea: <Link to Splunk idea, see https://ideas.splunk.com>

Testing:

Documentation:

stringValue: kube:events
- key: com.splunk.index
value:
stringValue: index_from_pod
Copy link
Collaborator Author

@jinja2 jinja2 Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Events in the resource before this ( e.g. Successfully assigned k8sevents-test/k8sevents-test-0 to kind-control-plane) do not have their index overridden with the annotation value. I think there'll be some ambiguity about the index with the existing config.

For example, an event create Pod in StatefulSet k8sevents-test successful which is associated with the object.kind = statefulset. It does not have a k8s.node.name value (this is set in the receiver to match the source.host so if event is from kubelet about a local pod activity this is set, but other controllers might not add this.. It has the k8s.namespace.name set which is used as source for one of the association rule, but in our test we have no existing pod at the time this event was generated in the test ns. So I think the processor isn't able to add the index value from the namespace (the namespace has the annotaion splunk.com/sourcetype = index_from_namespace) and it remains main in this test.

- conditions:
- resource.attributes["k8s.object.kind"] == "Pod" and IsMatch(resource.attributes["k8s.object.fieldpath"], "spec\\.containers.*")
statements:
- merge_maps(resource.cache, ExtractPatterns(resource.attributes["k8s.object.fieldpath"], "spec.containers\\{(?P<k8s_container_name>[^\\}]+)\\}"), "insert")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

named capture group errors when . are used, so I am writing to cache and then setting the attribute in next step

@jinja2 jinja2 force-pushed the add-k8sevent-transform branch from 1ec2555 to 9aa840f Compare March 6, 2025 15:37
@jinja2 jinja2 marked this pull request as ready for review March 6, 2025 17:40
@jinja2 jinja2 requested review from a team as code owners March 6, 2025 17:40
Copy link
Contributor

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jinja2 jinja2 merged commit 1f4ed43 into main Mar 6, 2025
76 of 77 checks passed
@jinja2 jinja2 deleted the add-k8sevent-transform branch March 6, 2025 17:58
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants