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

logging: container_name is not set when using STACKDRIVER appender #1067

Open
stellirin opened this issue Apr 12, 2022 · 4 comments
Open

logging: container_name is not set when using STACKDRIVER appender #1067

stellirin opened this issue Apr 12, 2022 · 4 comments

Comments

@stellirin
Copy link

We want to use spring-cloud-gcp-logging with the STACKDRIVER appender from a service that runs in GKE. Our logs go to projects/my-project-id/logs/spring.log as expected, including trace and span. However in the resource.labels section the container_name is not set. All other fields in this section (cluster_name, location, namespace_name, pod_name, project_id) are all set to the expected values.

Is this potentially a bug in the logging library or simply a quirk of how Stackdriver works when not logging to STDOUT? If not a bug, is it possible to manually set this field via some logger configuration? Our intention was to use the container_name in our log search filters.

  • Spring Boot: 2.6.6
  • Spring Cloud 2021.0.1
  • Spring Cloud GCP: 3.2.1

I'm aware of the CONSOLE_JSON appender, which works great, but we have an unusual business case where we need unfiltered 'standard' logs as well as structured logs.

@elefeint
Copy link
Contributor

It's a GKE-specific enhancement that's not currently part of our autoconfiguration. You can get this metadata with a workaround described here spring-attic/spring-cloud-gcp#2479.

@stellirin
Copy link
Author

Thanks for confirming, we can at least use the pod_name field with a bit of regex matching.

I found the MetadataConfig.getContainerName() method but on GKE it returns null. I was also not able to find a configuration class for logging, the class in the linked issue seems to be only for metrics. At least it had no effect on logging when I tried it.

@ddixit14
Copy link
Contributor

Hi @stellirin, finding the container name in GKE is not supported yet.

@elefeint
Copy link
Contributor

You can track the GKE feature request here: http://issuetracker.google.com/145137070

@emmileaf emmileaf added the type: enhancement New feature or request label Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants