Skip to content
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

Resource Labels Pod ID and Namespace ID are using the Name not the ID properties #352

Closed
twistedpair opened this issue Dec 6, 2020 · 4 comments
Assignees
Labels
api: logging Issues related to the googleapis/java-logging API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@twistedpair
Copy link

The following values are incorrectly populated by MonitoredResourceUtil

  • resoure.labels.pod_id
  • resoure.labels.namespace_id

The values being used are the name value of the respective entities, not the ID properties.

This is inconsistent with the Kubernetes API, and with other appenders used within GKE (e.g. the Fluentd appender), which properly populate the pod_name and namespace_name labels with the metadata.name property.

Expected Behavior

  • resoure.labels.pod_id <- pod.metadata.uid
  • resoure.labels.namespace_id <- namespace.metadata.uid
  • resoure.labels.pod_name <- pod.metadata.name
  • resoure.labels.namespace_name <- namespace.metadata.name

Impact
The present bug means that you must search in cloud logging with extra factually incorrect predicates like

resource.labels.pod_name="my-pod-name" OR resource.labels.pod_id="my-pod-name"

and means certain Stackdriver log based metrics and filters are not possible due to this inaccuracy.

Since other GKE tools like the built in Fluentd appender properly set resource.labels.pod_name, example Fluentd output below:

image

Environment details

  1. Specify the API: Cloud Logging, e.g. used with the Google Logback Cloud Appender
  2. OS type and version: all
  3. Java version: all
  4. logging version(s): all

Steps to reproduce

  1. Emit Java log line
  2. View results in Cloud Logging

External references such as API reference guides

Any additional information below

While changing the pod_id value to the correct entity.metadata.uid property would possibly impact library users, adding the pod_name and namespace_name labels, with the correct values, would allow Cloud Logging users to properly search by the name labels across all logging sources.

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/java-logging API. label Dec 6, 2020
@suraj-qlogic suraj-qlogic self-assigned this Dec 7, 2020
@suraj-qlogic suraj-qlogic added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Dec 7, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Dec 7, 2020
@suraj-qlogic suraj-qlogic added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels Dec 7, 2020
@suraj-qlogic
Copy link
Contributor

suraj-qlogic commented Dec 9, 2020

@twistedpair,Thanks for filling issue.For a Kubernetes API container instance k8s_container is used as monitored resource type.
I have already submitted PR for this feature which is under review.Please follow here java-logging-206 for progress/work related to your request.

@twistedpair
Copy link
Author

Thanks, @suraj-qlogic . Glad to see your PR merged.

Looks like namespace_id will still be the wrong value though, but that seems to be a bug in the underlying GCE metadata server. I'll update this issue.

@simonz130 simonz130 assigned simonz130 and unassigned suraj-qlogic Jan 21, 2021
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Apr 21, 2021
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Jun 5, 2021
@minherz minherz removed the 🚨 This issue needs some love. label Sep 5, 2021
@minherz
Copy link
Contributor

minherz commented Sep 5, 2021

@twistedpair should renaming pod_id to pod_name and namespace_id to namespace_name be sufficient to resolve the problem? from the report it looks like the current label naming is misleading and does not match the logging that is captured from STDOUT by Logging agent. however, i would like to confirm it before applying the change.

@minherz
Copy link
Contributor

minherz commented Sep 13, 2021

I see that the code uses pod_id and namespace_id labels with the old resource type name: container. The k8s_container resource type is populated with the expected labels (pod_name and namespace_name). There is PR #641 that handles the change of the resource type name. After the merge, the expected set of label names will be populate.

@minherz minherz closed this as completed Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/java-logging API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants