fluentd-kubernetes-sumologic icon indicating copy to clipboard operation
fluentd-kubernetes-sumologic copied to clipboard

Support `deployment` as a variable for sourceName and sourceCategory

Open darend opened this issue 7 years ago • 1 comments

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.

darend avatar Apr 30 '18 19:04 darend

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.

bendrucker avatar Dec 19 '18 01:12 bendrucker