Convert metric type to Gauge

I have metric collected from a source. the source sets the type of metrics as Info or Stateset.

# HELP capi_cluster_status_phase The clusters current phase.
# TYPE capi_cluster_status_phase stateset
capi_cluster_status_phase{customresource_group="cluster.x-k8s.io",customresource_kind="Cluster",customresource_version="v1beta1",name="somename",namespace="somenamespace",phase="Deleting",uid="50e401fb-9651-47e2-9baf-43d518cea952"} 0

can someone help me understand how we can transform the metric type in telegraf

Hello @rahav_jv,

Telegrafs prom input plugin doesn’t natively support the stateset metric type unfortunately.

However you could try:

  1. Metric filtering to exclude these problematic metrics:
[[inputs.prometheus]]

# Your existing configuration

# ...

metric_version = 2

# Exclude the problematic metrics

metric_name_filter = ["capi_cluster_status_phase"]

metric_name_filter_mode = "exclude"
  1. Use the Enum processor to handle these stateset metrics by mapping them to numeric values similar to how Telegraf handles other enumerated states:
[[processors.enum]]

namepass = ["capi_cluster_status_phase"]

[[processors.enum.mapping]]

field = "phase"

[processors.enum.mapping.value_mappings]

Deleting = 0

Failed = 1

# Add other phases as needed

Some resoures that could help