-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Populate ecs fields by pod and container metricsets #30181
Populate ecs fields by pod and container metricsets #30181
Conversation
This pull request does not have a backport label. Could you fix it @MichaelKatsoulis? 🙏
NOTE: |
// Enrich event with container ECS fields | ||
containerEcsFields := ecsfields(event) | ||
if len(containerEcsFields) != 0 { | ||
e.RootFields = common.MapStr{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will override any existing RootFields
right? event
variable will already have RootFields
coming from
e.RootFields = metaFieldsMapStr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a check in 0a0a543
@ChrsMark I added some units tests as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should wait until elastic/ecs#1747 is settled down before moving on with this. wdyt?
Yes. I will move it as blocked and wait. |
@@ -114,28 +114,28 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common. | |||
} | |||
|
|||
if container.StartTime != "" { | |||
containerEvent.Put("start_time", container.StartTime) | |||
_, _ = containerEvent.Put("start_time", container.StartTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we maybe add proper handling of errors here, as a debug messages?
not in this PR, but at least create a ticket for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments.
containerEcsFields := ecsfields(event) | ||
if len(containerEcsFields) != 0 { | ||
if e.RootFields != nil { | ||
e.RootFields.DeepUpdate(common.MapStr{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RootFields
can already contain container
key here so this is why using DeepUpdate
right? Can you also add a comment about this so as to prevent any unwanted changes in the future if someone oversee the fact of the preexisting container
key?
@@ -114,28 +114,28 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common. | |||
} | |||
|
|||
if container.StartTime != "" { | |||
containerEvent.Put("start_time", container.StartTime) | |||
_, _ = containerEvent.Put("start_time", container.StartTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
} | ||
|
||
if nodeCores > 0 { | ||
containerEvent.Put("cpu.usage.node.pct", float64(container.CPU.UsageNanoCores)/1e9/nodeCores) | ||
_, _ = containerEvent.Put("cpu.usage.node.pct", float64(container.CPU.UsageNanoCores)/1e9/nodeCores) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many unhandled errors. Wondering if we should actually handle them properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to do anything specific here. Just continue to the next fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still don't like this format with unhandled errors but if you feel it's ok you can ship it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't either. It is like this in most of the beats modules. If we want to handle it somehow(log something), let's do it in subsequent pr, so we can make the FF for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see how we can improve the code style in follow-ups.
* Populate ecs fields by pod and container metricsets * Update changelog
* Populate ecs fields by pod and container metricsets * Update changelog
* Populate ecs fields by pod and container metricsets * Update changelog
What does this PR do?
After new container ECS fields get GA (elastic/ecs#1747) kubernetes module need to start populating those fields.
The new fields are
container.cpu.usage
container.memory.usage
container.network.egress.bytes
container.network.ingress.bytes
These fields map to kubernetes fields:
kubernetes.container.cpu.usage.node.pct
by container metricsetkubernetes.container.memory.usage.node.pct
by container metricsetkubernetes.pod.network.tx.bytes
by pod metricsetkubernetes.pod.network.rx.bytes
by pod metricsetrespectively.
Why is it important?
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Related issues
Screenshots