-
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
Populate container.id field in container metricset #29560
Populate container.id field in container metricset #29560
Conversation
This pull request does not have a backport label. Could you fix it @MichaelKatsoulis? 🙏
NOTE: |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
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.
Really useful addition! Left some comments.
@@ -134,3 +136,6 @@ type Summary struct { | |||
} `json:"volume"` | |||
} `json:"pods"` | |||
} | |||
|
|||
// PodContainerStatus data | |||
type PodContainerStatus = v1.ContainerStatus |
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.
Why we need to declare it again? Can't we re-use the already existent https://github.com/elastic/beats/blob/cf1c78c85dda1fd0c3d2e072efd52b903da2cdb0/libbeat/common/kubernetes/types.go#L62-L61 ?
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.
You are right. It is not needed
// copy to ECS fields the kubernetes.container.image, kubernetes.container.name | ||
containerFields := common.MapStr{} | ||
if containerID, ok := event["id"]; ok { | ||
cID := (containerID).(string) |
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.
nit: This block could be a helper function.
@@ -215,7 +223,11 @@ func NewContainerMetadataEnricher( | |||
|
|||
id := join(pod.GetObjectMeta().GetNamespace(), pod.GetObjectMeta().GetName(), container.Name) | |||
m[id] = meta | |||
if s, ok := statuses[container.Name]; ok { | |||
PerfMetrics.ContainerID.SetStringVal(cuid, s.ContainerID) | |||
} |
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.
Wondering if we could avoid using the cache for this and use meta
directly.
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.
Yes I will do this! Good catch
@ChrsMark I added the container.id and container.runtime in the meta 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.
🚀
if s, ok := statuses[container.Name]; ok { | ||
split := strings.Index(s.ContainerID, "://") | ||
if split != -1 { | ||
meta.Put("container.id", s.ContainerID[split+3:]) |
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.
could you please add a comment with an example of statuses[container.Name]
value, that could explain why those offset is used
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 comment in 755b1f2
Pinging @elastic/integrations (Team:Integrations) |
This pull request is now in conflicts. Could you fix it? 🙏
|
…field-container-metricset
What does this PR do?
This PR adds
container.id
andcontainer.runtime
fields in events generated by kubernetescontainer
Metricset.Why is it important?
Container.id
is a unique identifier for a Kubernetes container and is very important to be part in all kubernetes events.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs