Transforming email labels in alert

Hello
I set up some basic alerting for a thermostat, if it drops below a certain temp, alert
It works but the data from the api I use to pull the the data into Prometheus shows each room as a numeric id and this comes in the email, I would like to somehow convert that in the email to be a room name, I have the table of ids to names but I’m struggling to work out how it’s done so any pointers or examples would help please


Thanks a lot

I assume you use Grafana-managed alerting. If your room list is static, then you can create an annotation template and map the label room_id to a name.

1 Like

Hi yes i use grafana alerting, i have tried searching for “Annotation Templates” but honestly, i cant find anything, i tried to use chatgpt and it told me to do some annotations in the alert and also a custom variable but they fail as well, Prometheus query outputs the room_id and i know the mapping of that to a name but i still get nothing

room_name

in the end i fixed it by using prometheus metric_relabel_configs
Like this in the Prometheus job

metric_relabel_configs:                                                     
    - source_labels: [room_id]                                                  
      regex: "123456789"                                                       
      target_label: room_id                                                     
      replacement: "Room 1"                                                   
    - source_labels: [room_id]                                                  
      regex: "987654321"                                                       
      target_label: room_id                                                     
      replacement: "Room 2"                                               ```