Skip to content

Latest commit

 

History

History
70 lines (58 loc) · 3.99 KB

k8s_metadata_decorator.md

File metadata and controls

70 lines (58 loc) · 3.99 KB

k8s_metadata_decorator operator

The k8s_metadata_decorator operator adds labels and annotations to the entry using data from the Kubernetes metadata API.

Configuration Fields

Field Default Description
id k8s_metadata_decorator A unique identifier for the operator
output Next in pipeline The connected operator(s) that will receive all outbound entries
namespace_field namespace A field that contains the k8s namespace associated with the log entry
pod_name_field pod_name A field that contains the k8s pod name associated with the log entry
cache_ttl 10m A duration indicating the time it takes for a cached entry to expire
timeout 10s A duration indicating how long to wait for the API to respond before timing out
allow_proxy false Controls whether or not the agent will take into account proxy configuration when communicating with the k8s metadata api
if An expression that, when set, will be evaluated to determine whether this operator should be used for the given entry. This allows you to do easy conditional parsing without branching logic with routers.

Example Configurations

Add labels and annotations to a log entry

Configuration:

- type: k8s_metadata_decorator
Input record Output record
{
  "timestamp": "",
  "record": {
    "namespace": "my-namespace",
    "pod_name": "samplepod-6cdcf6bf9d-f4f9n"
  }
}
{
  "timestamp": "",
  "labels": {
    "k8s_ns_annotation/addonmanager.kubernetes.io/mode": "Reconcile",
    "k8s_ns_annotation/control-plane": "true",
    "k8s_ns_annotation/kubernetes.io/cluster-service": "true",
    "k8s_ns_label/addonmanager.kubernetes.io/mode": "Reconcile",
    "k8s_ns_label/control-plane": "true",
    "k8s_ns_label/kubernetes.io/cluster-service": "true",
    "k8s_pod_annotation/k8s-app": "dashboard-metrics-scraper",
    "k8s_pod_annotation/pod-template-hash": "5f44bbb8b5",
    "k8s_pod_label/k8s-app": "dashboard-metrics-scraper",
    "k8s_pod_label/pod-template-hash": "5f44bbb8b5"
  },
  "record": {
    "namespace": "my-namespace",
    "pod_name": "samplepod-6cdcf6bf9d-f4f9n"
  }
}