[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 |
tetianakravchenko
left a comment
There was a problem hiding this comment.
could you please also add a changelog recorf?
| "inodes": 473560, | ||
| "inodesUsed": 9, | ||
| "name": "default-token-sg8x5" | ||
| "name": "default-token-sg8x5", |
There was a problem hiding this comment.
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. |
| } | ||
| if volume.PvcRef.Name != "" { | ||
| kubernetes2.ShouldPut(volumeEvent, "persistentvolumeclaim.name", volume.PvcRef.Name, logger) | ||
| } |
There was a problem hiding this comment.
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.
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.
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.
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.asciidocorCHANGELOG-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.volumewith 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/statsdoes actually report a pvcReference that allows to bind the pod's volume with a corresponding pvc.Example Response:
Screenshots
Logs