Custom Host Attribute not available in notification script

CMK version: CMK Raw Edition 2.1.0p31
OS version: RHEL 8.6
Additional information: CMK Master server with 2 additional CMK instances in slave mode.

Context: I’ve created a new Custom Host Attribute, called environment, that I wanted to use in email notifications’ subject.
I modified one host and added a value to this attribute.
Then I created a custom email rule to use this variable en subject for Host and Services alerts. Like this:
Check_MK: ($HOSTLABEL_environment$) $HOSTNAME$...

I’ve tested it with this host that I modified and it worked fine.

Problem: I modified this variable for all other hosts, but in the emails I don’t see the value, instead I get ($HOSTLABEL_environment$).

I tried to debug, adding the check that shows all the variables defined in the email message. The variable appears in the first host but not in the others.

Is this a bug? Or I’m missing some configuration step?

Thanks in advance four your time and support.
Kind regards
Enzo

I’m adding examples of notifications.
This is a notification on the other hosts that doesn’t work:

This is a notification for the initial host that did worked:

Hi.

Please have a look to this article: Verwendung von Custom Attributes in Notifications - Global Community / Deutsch - Checkmk Community

Rg, Christian

1 Like

It’s a bit ugly. Even though you define the custom attribute as environment (all lower case) the actual variable in the notification context is called HOST_ENVIRONMENT (all upper case):

Definition of the host attribute (remember to check the bottom most option!):

Assign some value to the attribute:

image

Use the variable in the notification rule:

image

Resulting email subject:

image

Thanks for your answers.
I’ve tried lower case, upper case, a different variable name, different topic, but no luck.
I deleted my previous definition of the custom variable and now the new one does not show in any host variables.
I noticed that you use HOST_variable and when I first looked up to it I got HOSTLABEL_variable. But now neither shows up.
I suppose it is a bug of my cmk version?

Ok, it seems to be working now.
The option that worked for me is to add a HOST LABEL:

Then, in the email notification options, I used HOSTLABE_environment variable:

Thanks!
Kind regards