Skip to content

Commit

Permalink
feat: transform k8s event semantic conventions (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
wrn14897 committed Dec 29, 2023
1 parent 5b3b256 commit 58d928c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/metal-jokes-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hyperdx/api': patch
'@hyperdx/app': patch
---

feat: transform k8s event semantic conventions
28 changes: 28 additions & 0 deletions docker/ingestor/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,34 @@ if .hdx_platform == "vector-internal" {
.b = merge(.b, structured, deep: true) ?? .b
}
# extract k8s event metadata
if .b.object.apiVersion == "events.k8s.io/v1" && .b.object.kind == "Event" {
# set severity
if is_nullish(.b.level) && (.b.object.type == "Warning" || .b.object.type == "Normal") {
.b.level = .b.object.type
}
# transform the attributes so that the log events use the k8s.* semantic conventions
# ref: https://docs.honeycomb.io/integrations/kubernetes/kubernetes-events/
if .b.object.regarding.kind == "Pod" {
.b."k8s.pod.name" = .b.object.regarding.name
.b."k8s.pod.uid" = .b.object.regarding.uid
.b."k8s.namespace.name" = .b.object.regarding.namespace
} else if .b.object.regarding.kind == "Node" {
.b."k8s.node.name" = .b.object.regarding.name
.b."k8s.node.uid" = .b.object.regarding.uid
} else if .b.object.regarding.kind == "Job" {
.b."k8s.job.name" = .b.object.regarding.name
.b."k8s.job.uid" = .b.object.regarding.uid
.b."k8s.namespace.name" = .b.object.regarding.namespace
} else if .b.object.regarding.kind == "CronJob" {
.b."k8s.cronjob.name" = .b.object.regarding.name
.b."k8s.cronjob.uid" = .b.object.regarding.uid
.b."k8s.namespace.name" = .b.object.regarding.namespace
}
# set main message
.b._hdx_body = .b.object.note
}
# set severity after merging structured message (to avoid conflict)
.st = downcase(.b.level) ?? null
Expand Down

0 comments on commit 58d928c

Please sign in to comment.