I’m asking for a simple kapacitor example. I want to create alert when disk space is more than 90% for example. This part is fine but I also want to display total disk space and free size in alert message. So, I want to trigger an alert for metric 1 and display information about metric 2 and metric 3 in alert message.
You should be able to achieve that by using multiple streams. you will then use each metric as you wish. See this community post for an example (you won’t need to join the streams if you want just to write a message)
the message can be built in this way using the aliases
|alert()
.id( {...} ) // The alert title
.message('{{.Level}} - Disk Space > Total Disk Space: ' + string('Total_Disk_Space') + '| Occupied Space: ' + string('Disk_Space') + {...})
Some time ago I found this post which has a really nice and complete TICK script example, it might be useful as an example.
It turns free MB in to GB and keeps all three values. You can alert on the percentage value and to use the newly created fields add {{index .Fields “Free_Gigbyte”}} and so on