Skip to content
This repository has been archived by the owner on Feb 5, 2021. It is now read-only.

Support deployment as a variable for sourceName and sourceCategory #60

Open
darend opened this issue Apr 30, 2018 · 1 comment
Open

Comments

@darend
Copy link
Contributor

darend commented Apr 30, 2018

what

Support deployment as a variable for sourceName and sourceCategory

why

The following variables are already supported: %{namespace}, %{pod}, %{container}. There are uses for being able to refer to the deployment in the sourceName or category.

@bendrucker
Copy link
Contributor

bendrucker commented Dec 19, 2018

Hey there,

Sorry for the long delay in responding. This plugin relies on fluent-plugin-kubernetes_metadata_filter to append metadata. It figures out which pod a log line belongs to based on its container name. We can readily get any info associated with a pod.

It's not impossible to go from a pod to a deployment but it might be more api intensive than other metadata requirements:

  1. Find the pod's replicaset (e.g. kubectl get pod <pod> -o 'jsonpath={ .metadata.ownerReferences[?(.kind == "ReplicaSet")].name }')
  2. Find the replicaset's deployment (kubectl get rs <rs> -o 'jsonpath={ .metadata.ownerReferences[?(.kind == "Deployment")].name }')

I suspect the fluent-plugin-kubernetes_metadata_filter will not be too keen on watching replicasets in addition to pods/namespaces so the PR there to make this optional but off by default might be fairly large/time-consuming.

If you're willing to standardize across your deployments, you can write a label out to your template and refer to it via %{label:<key>}:

https://github.com/SumoLogic/fluentd-kubernetes-sumologic#templating-kubernetes-metadata

The labels have the additional benefit of creating conventions of passing down other things you might find useful for inclusion in metadata tags, like the tag portion of the image.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants