I’ll be away for a few days, but I’ll come back and help. What are you getting in the email alert? There are a few parts to get message templating working, to summarize:
Create the annotation with your alert labels and values in the alert rule
Create the message template that will print the alert data created by the annotation
Configure your contact point to utilize your message template
Can you share a screenshot of the annotation you’ve created, the message template, and the contact point? It’s possible that if all of the steps are correct, and your email message uses the default format, it needs to be set up to use the template.
As a test, I just changed the contact point for the sample alert I’ve been sending to slack and re-routed it to my email contact point. All of the template data came through with no other changes, so this process should work for you.
Hi @melori.arellano!
Thank you for your reply.
No problem, whenever you can.
I think I have missed the second and third step and will look into that.
However, now I’m curious that even if the default email template is set to send whatever information/annotations are set in the “Add details for your alert” section, should it not process those variables and send them neatly anyways, rather than needing to go through step 2 and step 3?
Also, without step 2 and step 3, should it be expected to see the variable values populated at least when viewing these Summary and Annotations in the alerts UI?
For some reason, I’m not able to upload a screenshot, neither here nor on the GitHub Issues page.
@milinpatel13298 I used the default template for my mail test and it did print the annotations. The difference is that they weren’t customized to use the formatting I specified in the message template.
If there is data from the alert, you should see the same information as preview shows when using {{$value}}.
@melori.arellano Thank you for your response.
Like I mentioned in my earlier response, I did try all of those combinations but now of them work for me.
Could you elaborate what you meant by “Create the message template that will print the alert data created by the annotation”?
Also, I’m still not sure whether I should expect these values to populate in the Alerts UI or just the actual email because either of them is not working for me?
@grant2
Thank you for your answer. I’m clear now that I have the default message set up currently as I get whatever new annotations I add in my alerts.
It’s just that they don’t seem to be populating the variable values like I have described in my earlier comment (neither in the Alerts UI nor in the email body).
Edit: Based on @mleduc 's post/question I do understand now, that maybe, I should not expect the values to be populated in the alerts UI after all. Is that a safe assumption?
Does anyone know how I can alter this to allow me to only iterate through Expression C for example? It is repeating the info three times in my alerts so I am assuming that it is going through each of the variables as it goes through all the values.
{{ with $values }}
{{ range $k, $v := . }}
Location: {{$v.Labels.location}}
Variable: {{$v.Labels.variable}}
Alerting value: {{ $v }}
{{ end }}
{{ end }}
Hello, sorry to insist but I didn’t get any solution for my issue. Could someone please give me a hand with this? I’m still trying to get the “hostname.keyword” and “remoteEmail.keyword” values from my classic condition output inside the labels field, but I can’t make it work.
After being able to fetch these values I think all my problems will be solved.
Hi grant, thanks for the quick answer. I actually got a workaround using the reReplaceAll function. My issue now is that I’m not receiving any data in Slack.
If I use the default message I get the information I’m looking for (leaving Text body empty):
@melori.arellano@grant2 Sorry for the bother again, I still haven’t been able to figure this out.
What should ideally work with the above generated alert labels in my Alerts preview.
Also, I was able to get our contact point configuration from my admin and here is what that looks like:
Message - empty
Subject - {{ template “default.title” . }}
Is any change recommended in this config, specifically the Message field?
@melori.arellano@grant2 Hello, could the templates be used to send the content of a log in json format? I want to notify whenever there is an error type log and send the content of the error to Slack. I have my logs centralized in loki