-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Metricbeat][Kubernetes] Add container.name field to state_container #37515
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
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 think this issue needs more clarifications
When I checked this PR I found few relevant PRs/discussions:
-
container.name
was added in Add container image and container name ECS fields for state_container #23802 and removed later Use alias to report container image in k8s parts #24380 in favor of usingalias
-
Also here is this discussion - Verify ECS alignment in container fields reported by kubernetes module and meta processor #23585, see this comment Verify ECS alignment in container fields reported by kubernetes module and meta processor #23585 (comment)
seems that it is not correct just to copykubernetes.container.name
metricbeat/module/kubernetes/state_container/state_container.go
Outdated
Show resolved
Hide resolved
kubernetes.ShouldPut(containerFields, "name", cName, m.Logger()) | ||
} | ||
} | ||
|
||
// applying ECS to kubernetes.container.id in the form <container.runtime>://<container.id> | ||
// copy to ECS fields the kubernetes.container.image, kubernetes.container.name |
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 think this comment is also applicable to the container.name
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 checked, but the value of the field is just <container.name>
, it does not have the same format as <container.runtime>://<container.id>
.
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.
Thanks for the PR @constanca-m ! I have tested this locally and works fine.
(I am posting the example from my local setup:)
metricset: container -> container.name: nginx
metricset: state_container: -> container.name: nginx
Even works for mutiple containers inside same pod
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 think what @tetianakravchenko meant is that the comment copy to ECS fields the kubernetes.container.image, kubernetes.container.name
applies also for the addition you did. So it would be better to move your code under this comment.
Co-authored-by: Tetiana Kravchenko <tanya.kravchenko.v@gmail.com>
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsExpand to view the GitHub comments
To re-run your PR in the CI, just comment with:
|
@constanca-m have we addressed @tetianakravchenko concerns above about Just to summarise this is the comment from Christos #24380 (comment) about those fields having different values. If they have the same value, we should either use a alias or just keep only one of those like suggested at #23585 (comment). If they differ, we shouldn't copy so the code changes are not correct either. Have we verified that those two fields are exactly the same in different runtimes (eg. cloud with all the providers, docker, ...) |
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.
verify first that those two fields should have the same values
I had only tested with docker, but I tested now with GCP, and they are the exact same: Regarding the comment #23585 (comment),
I don't exactly understand this. @MichaelKatsoulis this comment is 2 years old, but any chance you can give some insight into why |
💔 Build Failed
Expand to view the summary
Build stats
Test stats 🧪
Steps errorsExpand to view the steps failures
|
❕ Build Aborted
Expand to view the summary
Build stats
🤖 GitHub commentsExpand to view the GitHub comments
To re-run your PR in the CI, just comment with:
|
They are the same because in your code you get the container.name value from the event, which is the one added by ksm. So they cannot be different. I think that the problem is that the concepts of those two fields is a bit different and shouldn't be aliased. Now regarding setting it explicitly in the state_container as we do in container metricset I am not sure. |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsExpand to view the GitHub comments
To re-run your PR in the CI, just comment with:
|
SemConv of OTel for
(The same, conceptually, defines ECS as well) So the point here is that OTel also specifies the This implies that these 2 can be different in principle. There might be cases that runtimes's names match what we see in the spec but we should not overload Example: Let's say that we have Metricbeat collecting these data and we do I haven't done any extensive research on this recently so I might miss sth here but I think that's how we should approach this one here. |
So after @ChrsMark comment, I understand that is wrong to assume that container.name equals to kubernetes.container.name and if we are not sure of the runtime container name, we should not populate this field. I believe the best approach is to not populate this field at all and also remove it from the container metricset. |
Ok, seeing this implementation is wrong, I will close this PR and the issue. |
Proposed commit message
Please explain:
container.name
field tostate_container
data stream.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Related issues
Screenshots
Proof that it works: