Open stellirin opened 2 years ago
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.
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.
Hi @stellirin, finding the container name in GKE is not supported yet.
You can track the GKE feature request here: http://issuetracker.google.com/145137070
We want to use
spring-cloud-gcp-logging
with theSTACKDRIVER
appender from a service that runs in GKE. Our logs go toprojects/my-project-id/logs/spring.log
as expected, including trace and span. However in theresource.labels
section thecontainer_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.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.