Configure Discovery of Kubernetes Informer
Block: discovery.informer.k8s
This page documents how to configure Mermin's Kubernetes informers, which watch and cache Kubernetes resources for flow metadata enrichment.
Mermin uses Kubernetes informers to maintain an in-memory cache of cluster resources. This enables enriching network flows with Kubernetes metadata like pod names, labels, services, and owner references without querying the API server for every flow.
Configuration
A full configuration example can be found in the Default Configuration.
discovery.informer.k8s block
kubeconfig_pathattributePath to kubeconfig file for API server connection. When empty, uses in-cluster config. Non-default value may be used for:
Testing locally outside cluster
Using specific service account
Multi-cluster scenarios
Type: String
Default:
""(uses in-cluster config)Example: Use specific kubeconfig
discovery "informer" "k8s" { kubeconfig_path = "/etc/mermin/kubeconfig" }informers_sync_timeoutattributeTimeout for initial informer synchronization. Why it matters:
Maximum time to wait for informers to complete initial sync
Mermin won't be ready until sync completes
Large clusters may need longer timeout
Type: Duration
Default:
"30s"Example: For large clusters (10,000+ pods)
discovery "informer" "k8s" { informers_sync_timeout = "120s" }selectorsattributeFilter which Kubernetes resources are used during IP-to-resource attribution and metadata enrichment. Selectors control which cached objects are considered when resolving flow IPs to Pods, Services, and other resources, affecting which Kubernetes metadata appears on exported flow spans.
Export behavior: When
include = falseis used to exclude Pods, flows whose source or destination resolves to an excluded Pod are dropped before export (zero OTLP spans emitted). Flows with unresolved endpoints are exported by default (safe default).Type: List of selectors
Default:
selectors = [ { kind = "Service" }, { kind = "Endpoint" }, { kind = "EndpointSlice" }, { kind = "Gateway" }, { kind = "Ingress" }, { kind = "Pod" }, { kind = "ReplicaSet" }, { kind = "Deployment" }, { kind = "Daemonset" }, { kind = "StatefulSet" }, { kind = "Job" }, { kind = "CronJob" }, { kind = "NetworkPolicy" }, ]Examples:
Exclude Gateways in the
loggersnamespacenamespaces = ["loggers"] kind = "Gateway" include = falseOnly include pods with label
operated-prometheus = "true"AND labelenvin["dev", "stage"]kind = "Pod" match_labels = { operated-prometheus = "true" } match_expressions = [{ key = "env" operator = "In" values = ["dev", "stage"] }]
Object Types
Selector
Selector is used to match a Kubernetes resource using labels and expressions.
kindattributeDefines a Kubernetes Kind to apply the selector to, such as
Pod,Service,Job, etc. Case insensitive,"Pod","pod", and"POD"are equivalent.Type: String
Default:
""includeattributeDefines an action to perform, e.g. include or exclude matching resources.
When
include = falseis set for Pod selectors, matching pods are excluded from both attribution and export. Flows whose source or destination resolves to an excluded pod will not be exported to OTLP. If a pod cannot be resolved, the flow is exported by default.Type: Boolean
Default:
truenamespacesattributeDefines a filter based on the Kubernetes namespace name.
Type: List of Strings
Default:
[](empty list, match all namespaces)match_labelsattributeKubernetes label selector (ref). Each key represents a label, each value represents a label value. If label and label value is equal to the ones in the Kubernetes resource, the resource is included.
Type: Map of Strings
Default:
{}(empty map, do not apply label matching, e.g. match all)Example: Include resources that belong to production environment (label
env: prodis present in the resource)match_expressionsattributeKubernetes set-based label selector.
Type: List of match expressions
Default:
[](empty list, do not apply label matching, e.g. match all)Example: Include resources that belong to development and production environment (label
env: prodorenv: devis present in the resource)
Match Expression
Kubernetes set-based label selector.
keyattributeLabel key to match against.
Type: String
Default:
""operatorattributeOperator to apply, case insensitive.
Type: String
Default:
"In"Supported Values:
In,NotIn,Exists,DoesNotExistvaluesattributeList of label values to apply the
operatorto.Type: List of Strings
Default:
[]
Supported Resource Kinds
Mermin supports watching these Kubernetes resources:
Pod
Primary source for flow attribution
Service
Service endpoints and selectors
Endpoint
(Deprecated) Service endpoints
EndpointSlice
Modern service endpoints
ReplicaSet
Owner reference walking
Deployment
Owner reference walking
DaemonSet
Owner reference walking
StatefulSet
Owner reference walking
Job
Owner reference walking
CronJob
Owner reference walking
NetworkPolicy
Network policy association
Ingress
Ingress controller flows
Gateway
Gateway API flows
Performance Considerations
Memory Usage
Memory usage scales with number of watched resources:
Estimate: ~1 KB per resource
10,000 pods: ~10 MB
100,000 pods: ~100 MB
API Server Load
Informers use Kubernetes watch API:
Initial LIST operation per resource type
WATCH for ongoing updates
Reduce load:
Use namespace filtering
Use label selectors
Sync Time
Initial sync time depends on:
Cluster size
Number of resource types
API server performance
Network latency
You may need to tweak the informers_sync_timeout attribute.
Troubleshooting
Informer Sync Timeout
Symptoms: e.g. kubernetes cache sync timed out after 30s - increase informers_sync_timeout if needed
Solutions:
Increase
informers_sync_timeoutCheck API server responsiveness
Verify RBAC permissions
Reduce watched resource types
Missing Metadata
Symptoms: Flows missing pod/service names
Solutions:
Verify resource kinds are in selectors
Check namespace filters
Verify label selectors
Review logs for sync errors
High Memory Usage
Symptoms: Mermin using excessive memory
Solutions:
Add namespace filtering
Add label selectors
Remove unnecessary resource types
Check for resource leaks
Best Practices
Watch only needed resources: Reduces memory and API load
Use namespace filtering: For multi-tenant clusters
Monitor sync status: Check logs and metrics
Test selector changes: Validate in non-production first
Document selectors: Comment why specific filters are used
Next Steps
Configure Owner Relations: Walk owner references (Pod → Deployment)
Configure Selector Matching: Match Services and NetworkPolicies
Extract Flow Attributes: Choose which metadata appears on flows
Debug Missing Metadata: Diagnose enrichment issues
Verify RBAC Permissions: Ensure Mermin can read resources
Need Help?
GitHub Discussions: Ask about metadata enrichment
Last updated