Metrics Relabel Rules
Metrics relabel rules run on every incoming time series before Kloudfuse stores it. Use them to enrich series with new labels, clean up label values, remove labels you do not need, and drop whole series. For the rule fields, actions, and evaluation order, see How Relabel Rules Work.
Configure the rules
Add the rules to ingester.config.aggregator.metric.relabelConfigs in your custom-values.yaml file:
ingester:
config:
aggregator:
metric:
relabelConfigs:
- source_labels: [__name__]
regex: "aws_ec2_.*"
action: drop
Then apply the change:
helm upgrade --install kfuse oci://us-east1-docker.pkg.dev/mvp-demo-301906/kfuse-helm/kfuse \
-n kfuse \
--version <VERSION> \ (1)
-f custom-values.yaml
| 1 | Replace <VERSION> with a valid Kloudfuse release value. See Release Notes for the latest release. |
Labels the rules see
-
All of the series' labels. Label names are normalized before the rules run: characters other than letters, digits, and underscores become underscores, so a label sent as
k8s.cluster.nameis matched ask8s_cluster_name. -
name— the metric name. -
Labels added by an ingestion API key. Rules can match these labels but cannot change them.
Examples
Each example shows a single rule. You can list as many rules as you need; they run in order.
Add a label based on another label’s value
Add an aws_account_name label to every series whose aws_account is 123456:
- source_labels: [aws_account]
regex: "123456"
target_label: aws_account_name
replacement: production
Combine labels into a new label
Create an env_region label, such as prod-us-east-1, from the env and region labels. The values are joined with ; before matching:
- source_labels: [env, region]
regex: "(.*);(.*)"
target_label: env_region
replacement: "${1}-${2}"
Rewrite a label value
Strip the ip- prefix and the domain from host, so ip-10-0-1-5.ec2.internal becomes 10-0-1-5:
- source_labels: [host]
regex: "ip-([^.]+)\\..*"
target_label: host
replacement: "${1}"
Remove labels
Remove every label whose name starts with container_:
- regex: "container_.*"
action: labeldrop
Do not remove a label that distinguishes one series from another: series left with the same labels collide. To aggregate a metric to fewer labels, use Metric Shaping Rules instead.
Drop metrics by name
Stop storing every metric whose name starts with aws_ec2_. To keep only matching metrics instead, use action: keep:
- source_labels: [__name__]
regex: "aws_ec2_.*"
action: drop
Drop series by label value
Stop storing series from the load-test namespace in the staging cluster:
- source_labels: [kube_cluster_name, kube_namespace]
regex: "staging;load-test"
action: drop
Assign a retention policy
Keep series from the prod cluster under the prod retention policy. The policy must be defined in global.retentionPolicy.metrics.custom; see Configure relabel rules:
- source_labels: [kube_cluster_name]
regex: "prod"
action: retention
retention_policy: prod
Check the result
-
Series dropped by a rule appear in the Consumption Tracking dashboard with the drop reason
relabel. -
New and rewritten labels appear on series ingested after the upgrade. Series already stored keep their original labels.