You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
I'm trying to get kubernetes-event-exporter to output events in a way that is compatible with Elastic Common Schema (ECS). To do this, I'm using layout to remap k8s event fields onto ECS.
I have a straightforward recreate scenario using the bitnami helm chart. Note that this just makes iteration faster, the problem exists in the event exporter itself.
This demonstrates a few problems:
Everything is a string, cannot remap structures. See labels below.
Everything is a string, cannot output numbers. See count below
Using .FirstTimestamp actually gets the value of .LastTimestamp
No way to ignore fields that are not present (like .host.hostname)
I'm wondering if it would be a better approach to take a string layoutYAML and let the document be rendered. Alternatively having an ECS specific output mode (others could be added as well).
Recreate info
Helm values:
replicaCount: 1config:
logFormat: jsonlogLevel: errorthrottlePeriod: 5route:
routes:
- match:
- receiver: "ecs"
- match:
- receiver: "dump"receivers:
- name: "dump"stdout: {}
- name: "ecs"stdout:
layout:
# per https://www.elastic.co/guide/en/ecs/current/ecs-base.html# @timestamp: '{{ .Metadata.CreationTimestamp | date "2006-01-02T15:04:05Z" }}' # BUG? Can't access Metadata# @timestamp: '{{ now | date "2006-01-02T15:04:05Z" }}'labels: '{{ toJson .InvolvedObject.Labels }}'# BUG? How to make this a dict?message: '{{ .Message }}'# tags: []# per https://www.elastic.co/guide/en/ecs/current/ecs-agent.htmlagent:
type: kubernetes-event-exporter# REQUIRED per https://www.elastic.co/guide/en/ecs/current/ecs-ecs.htmlecs:
version: 8.1.0 # The version of ECS governing this mapping# https://www.elastic.co/guide/en/ecs/current/ecs-event.htmlevent:
action: '{{ .Reason | toString }}'created: '{{ .FirstTimestamp | date "2006-01-02T15:04:05Z" }}'# BUG: gets value from LastTimestampend: '{{ .LastTimestamp | date "2006-01-02T15:04:05Z" }}'kind: "event"provider: '{{ .Source.Component | toString }}'reason: '{{ .Reason | toString }}'severity: '{{ eq .Type "Normal" | ternary 6 4 | toString }}'# BUG: should be syslog severity number, not string# not ecs defined.count: '{{ .Count }}'# BUG -- should be a numbertype: '{{ .Type }}'# Mapped into .event.severityreportinginstance: '{{ .ReportingInstance | toString }}'# https://www.elastic.co/guide/en/ecs/current/ecs-host.htmlhost:
hostname: '{{ .Source.Host | toString }}'# How to omit when empty?# https://www.elastic.co/guide/en/ecs/current/ecs-orchestrator.htmlorchestrator:
# apiVersion: '{{ .InvolvedObject.ApiVersion | toString }}'namespace: '{{ .InvolvedObject.Namespace | toString }}'resource:
name: '{{ .InvolvedObject.Name | toString }}'type: '{{ .InvolvedObject.Kind | toString }}'fieldpath: '{{ .InvolvedObject.FieldPath | toString }}'
I'm trying to get kubernetes-event-exporter to output events in a way that is compatible with Elastic Common Schema (ECS). To do this, I'm using
layout
to remap k8s event fields onto ECS.I have a straightforward recreate scenario using the bitnami helm chart. Note that this just makes iteration faster, the problem exists in the event exporter itself.
This demonstrates a few problems:
labels
below.count
below.FirstTimestamp
actually gets the value of.LastTimestamp
.host.hostname
)I'm wondering if it would be a better approach to take a string
layoutYAML
and let the document be rendered. Alternatively having an ECS specific output mode (others could be added as well).Recreate info
Helm values:
Let it run for a while. One of the issues can only be verified when
firstTimestamp != lastTimestamp
, so we need count > 1.Check the results:
The resulting query has the
dump
event first and theecs
event second:The text was updated successfully, but these errors were encountered: