diff --git a/plugins/filter_kubernetes/kube_conf.h b/plugins/filter_kubernetes/kube_conf.h index 2aa18da5973..77ae62de931 100644 --- a/plugins/filter_kubernetes/kube_conf.h +++ b/plugins/filter_kubernetes/kube_conf.h @@ -76,6 +76,7 @@ struct flb_kube { int annotations; int namespace_labels; int namespace_annotations; + int namespace_metadata_only; int dummy_meta; int tls_debug; int tls_verify; diff --git a/plugins/filter_kubernetes/kube_meta.c b/plugins/filter_kubernetes/kube_meta.c index 45d9c445b34..13be9d26ae4 100644 --- a/plugins/filter_kubernetes/kube_meta.c +++ b/plugins/filter_kubernetes/kube_meta.c @@ -2053,7 +2053,7 @@ int flb_kube_meta_get(struct flb_kube *ctx, data_size, namespace_out_buf, namespace_out_size, namespace_meta); } - if(ctx->labels == FLB_TRUE || ctx->annotations == FLB_TRUE) { + if(ctx->namespace_metadata_only == FLB_FALSE) { ret_pod_meta = flb_kube_pod_meta_get(ctx, tag, tag_len, data, data_size, out_buf, out_size, meta, props); } diff --git a/plugins/filter_kubernetes/kubernetes.c b/plugins/filter_kubernetes/kubernetes.c index 877c1f7ac1d..76a06573fd0 100644 --- a/plugins/filter_kubernetes/kubernetes.c +++ b/plugins/filter_kubernetes/kubernetes.c @@ -914,6 +914,12 @@ static struct flb_config_map config_map[] = { 0, FLB_TRUE, offsetof(struct flb_kube, namespace_annotations), "include Kubernetes namespace annotations on every record" }, + /* Ignore pod metadata entirely, useful for fetching only namespace meta */ + { + FLB_CONFIG_MAP_BOOL, "namespace_metadata_only", "false", + 0, FLB_TRUE, offsetof(struct flb_kube, namespace_metadata_only), + "ignore pod metadata entirely and only fetch namespace metadata" + }, /* * The Application may 'propose' special configuration keys