Skip to content

Enum: custom label for state #416

Closed
Closed
@jmsantorum

Description

@jmsantorum

We're using the Enum metric to represent the state of different critical processes in the following way:

registry = CollectorRegistry()

deadline_start = Enum(
  'deadline_start', 'Start of a time-critical process',
  labelnames=['customer'], states=['waiting', 'late', 'started'],
  registry=registry
)

deadline_end = Enum(
  'deadline_end', 'Completion of a time-critical process',
  labelnames=['customer'], states=['waiting', 'late', 'started'],
  registry=registry
)

and the result we obtain is:

# HELP deadline_start Start of a time-critical process
# TYPE deadline_start gauge
deadline_start{customer="customerA",deadline_start="waiting"} 1.0
deadline_start{customer="customerA",deadline_start="late"} 0.0
deadline_start{customer="customerA",deadline_start="started"} 0.0
# HELP deadline_end Completion of a time-critical process
# TYPE deadline_end gauge
deadline_end{customer="customerA",deadline_end="waiting"} 1.0
deadline_end{customer="customerA",deadline_end="late"} 0.0
deadline_end{customer="customerA",deadline_end="started"} 0.0

but we would like to have a custom_label for the state instead of the metric name as we need to have the same label for all the metrics.

# HELP deadline_start Start of a time-critical process
# TYPE deadline_start gauge
deadline_start{customer="customerA",custom_label="waiting"} 1.0
deadline_start{customer="customerA",custom_label="late"} 0.0
deadline_start{customer="customerA",custom_label="started"} 0.0
# HELP deadline_end Completion of a time-critical process
# TYPE deadline_end gauge
deadline_end{customer="customerA",custom_label="waiting"} 1.0
deadline_end{customer="customerA",custom_label="late"} 0.0
deadline_end{customer="customerA",custom_label="started"} 0.0

the same happens with StateSetMetricFamily.

Would be possible to allow to pass a custom label? I can make a PR with the improvement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions