I have a java application that is deployed in a kubernetes cluster and logs to DataDog.We want to add a custom attribute to our logs, which is the server host of the PV/PVCs it's reading data from. Is that possible from inside the java code? Please feel free to ask for any more information you might need. Thank you
Are you able to get this information via the kubernetes API? For example, if you use the kubectl
cli and call kubectl get pvc my-pvc -o yaml
, is the information you need available there? If so, one way of doing it might be to query the API directly inside your application (or even from a sidecar or initContainer on the same pod). See also https://kubernetes.io/docs/tasks/run-application/access-api-from-pod/