# How can convert string value to number in grafana alerting (PromQl)

**URL:** <https://community.grafana.com/t/how-can-convert-string-value-to-number-in-grafana-alerting-promql/163053>\
**Category:** Grafana\
**Tags:** alerting\
**Created:** [May 28, 2026, 12:40pm UTC](https://community.grafana.com/t/how-can-convert-string-value-to-number-in-grafana-alerting-promql/163053 "2026-05-28T12:40:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![infofcc3](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/infofcc3/32/51248_2.png) [@infofcc3](https://community.grafana.com/u/infofcc3)\
**Post date:** [May 28, 2026, 12:40pm UTC](https://community.grafana.com/t/how-can-convert-string-value-to-number-in-grafana-alerting-promql/163053/1 "2026-05-28T12:40:54Z")

</div>

Hello,  
I am using SNMP Exporter with Prometheus and Grafana.  
My switch only exposes fault information as a string label, not as a numeric value.  
Example metric:

```auto
siemens_fault_text{fault_id="106", siemens_fault_text="Topology change detected."} 1

```

Problem:

- `fault_id` is a string label
- Metric value is always `1`
- In Grafana alerts, I want to compare the maximum `fault_id`
- PromQL functions like `max()` and `topk()` only work on metric values, not labels  
I want to know:

1. Is there any way in PromQL or Grafana Alerting to convert a label string like `"106"` into a number?
2. Is there any workaround without modifying the SNMP exporter?
