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

set service_name label for podLogs #1175

Merged
merged 6 commits into from
Jan 31, 2025

Conversation

rlankfo
Copy link
Member

@rlankfo rlankfo commented Jan 28, 2025

This PR sets service_name, service_namespace, deployment_environment, and deployment_environment_name labels on Loki pod logs. This works when sent to loki destinations. I'll follow this PR up with updates for pod logs sent to OTLP destinations.

The labels are set according to the following rules:

  • service_name label set by taking the first non-empty value from these Kubernetes metadata fields (in order): the pod annotation resource.opentelemetry.io/service.name, the pod label app.kubernetes.io/name, the pod’s name, or the container’s name.
  • service_namespace set by resource.opentelemetry.io/service.namespace pod annotation.
  • deployment_environment set by resource.opentelemetry.io/deployment.environment pod annotation.
  • deployment_environment_name set by resource.opentelemetry.io/deployment.environment.name pod annotation.

If not set, Loki will attempt to set a default value according to these rules: https://grafana.com/docs/loki/latest/get-started/labels/#default-labels-for-all-users

@rlankfo rlankfo requested a review from petewall as a code owner January 28, 2025 02:44
Copy link
Collaborator

@petewall petewall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Run make build inside charts/k8s-monitoring to update the generated files.

@rlankfo rlankfo requested a review from a team as a code owner January 29, 2025 01:46
@rlankfo rlankfo changed the title add podLogs to otlp-gateway test set service_name label for podLogs Jan 29, 2025
@rlankfo rlankfo marked this pull request as draft January 29, 2025 01:49
@rlankfo rlankfo changed the title set service_name label for podLogs WIP: set service_name label for podLogs Jan 29, 2025
@rlankfo rlankfo force-pushed the rlankfo/otlp-gateway-logs-service-name branch from 2f134cb to 6dc7369 Compare January 29, 2025 22:08
@rlankfo rlankfo self-assigned this Jan 29, 2025
@rlankfo rlankfo force-pushed the rlankfo/otlp-gateway-logs-service-name branch 3 times, most recently from de5ea21 to f248799 Compare January 30, 2025 23:30
@rlankfo rlankfo marked this pull request as ready for review January 30, 2025 23:32
@rlankfo rlankfo changed the title WIP: set service_name label for podLogs set service_name label for podLogs Jan 30, 2025
Signed-off-by: Robbie Lankford <robert.lankford@grafana.com>
@rlankfo rlankfo force-pushed the rlankfo/otlp-gateway-logs-service-name branch from f248799 to 310a260 Compare January 30, 2025 23:59
@rlankfo rlankfo merged commit ab802bc into main Jan 31, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants