GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp

logging: container_name is not set when using STACKDRIVER appender

Open
#1,067 4 comments 0 reactions 0 assignees View on GitHub
awaiting logging priority: p3 type: enhancement
Dominant language
Java
Stars
551
Forks
349
Avg merge
1d 13h
Merged PRs (30d)
14

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the STACKDRIVER appender behavior in a service running in GKE and inspect the resulting resource.labels, especially container_name. Compare it with the CONSOLE_JSON appender and determine whether the missing label comes from the logging library or Stackdriver; done means documenting or enabling a supported way to populate the field, if one exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, java, kubernetes, spring, spring-boot
Domain
cloud, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.