-
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 Volume] Add pvc reference to distinguish ephemeral from persistent volumes #38839
[Metricbeat][Kubernetes Volume] Add pvc reference to distinguish ephemeral from persistent volumes #38839
Conversation
…nt with the kubernetes.namespace)
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
cc @elastic/obs-ds-hosted-services |
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 also add a changelog recorf?
@@ -121,7 +121,11 @@ | |||
"inodesFree": 473551, | |||
"inodes": 473560, | |||
"inodesUsed": 9, | |||
"name": "default-token-sg8x5" | |||
"name": "default-token-sg8x5", |
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.
can you please add a separate sample with the pvcRef
to keep in the test file both examples - one for persistentvolumeclaim and one for the ephemeral volume?
a new field also should be added in the fields file: https://github.com/elastic/beats/blob/main/metricbeat/module/kubernetes/volume/_meta/fields.yml |
Hi, I tried to address the raised point about the tests^^. I also tried specifying the field. What I am not sure about is that in the end I want to "reuse" |
Apparently, adding the field broke the pipeline with the following error:
|
@herrBez in beats, the different kubernetes metricsets share the same index and mappings, so if the field is already declared, you don't need to declare it again. There is a duplicate key. |
This pull request is now in conflicts. Could you fix it? 🙏
|
Hi Michael, I addressed the required changes and the build works fine |
@herrBez Can you add a screenshot showing the new field being populated to Elasticsearch? You can use a view from discovery filtering by the kubernetes.volume metricset and showing the new field. |
@@ -75,6 +75,9 @@ func eventMapping(content []byte, logger *logp.Logger) ([]mapstr.M, error) { | |||
if volume.Inodes > 0 { | |||
kubernetes2.ShouldPut(volumeEvent, "fs.inodes.pct", float64(volume.InodesUsed)/float64(volume.Inodes), logger) | |||
} | |||
if volume.PvcRef.Name != "" { | |||
kubernetes2.ShouldPut(volumeEvent, "persistentvolumeclaim.name", volume.PvcRef.Name, logger) | |||
} |
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 have the feeling that this way the field that will be generated will be kubernetes.volume.persistentvolumeclaim.name
. Is that what you want?
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.
Wow, great static analysis :D.. Indeed, its creating the field you mention. I actually want to reuse the field kubernetes.persistentvolumeclaim.name
to allow correlation, but I am honestly a little bit lost.
After some thinking I tried with:
kubernetes2.ShouldPut(volumeEvent, mb.ModuleDataKey+".persistentvolumeclaim.name", volume.PvcRef.Name, logger)
But it does not seem to work 🤔
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.
Ok, the line I wrote in the comment is correct. For some reasons I were still using the old binary 🤦
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 had the feeling 😂
…es.persistentvolume
Can I go ahead and merge it? Should I open a PR in the integration repository to add the field to the kubernetes.volume datastream? |
I will merge it. About the field in the integration, not yet. We do it after the release of beats. I will add this in our list cause we have some other fields to declare as well. |
Proposed commit message
[Metricbeat][Kubernetes Volume] Add pvc reference to distinguish ephemeral from persistent volumes
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Create a PVC and mount the PVC as a volume in a pod, e.g. (on GKE):
Deploy metricbeat and check that there exist documents in
kubernetes.volume
with the fieldkubernetes.persistentvolumeclaim.name
.Alternatively execute the test.
Related issues
Use cases
The use-case is to being able to monitor persistent volumes and ignoring ephemeral volumes for threshold alerts.
As of now there is no way to distinguish persistent from ephemeral volumes. However, the endpoint called by the module
$NODE_URL/summary/stats
does actually report a pvcReference that allows to bind the pod's volume with a corresponding pvc.Example Response:
Screenshots
Logs