Format metricbeat field value in watcher alert

Hello,

I am using a number of watcher with various conditions and alert to be sent via email and slack.

I am receiving some values in the alert which are not easily readable e.g. disk free space which is sent by metricbeat in bytes.
But in Kibana, we see that Kibana applies some formatting to those values before displaying in 'Discover', in Discover, I see those fields like 5.6GB, 2.1GB etc.
The field type is 'Number' and format is set as 'Bytes'.

I am looking for same to be applied to the watcher result object {{ctx}} so that the alert email or slack message gets more comprehensible.

Thanks

Did you try dividing the value?
From Bytes to GB -->
value/1024/1024/1024

I did. The math operators are not recognised in the email text.

The alert text can contain the variables as is like {{ctx.metadata.payload.result.value}} but no calculations.

I Did not try it before.
But have you tried scripts?

Not sure how to embed {script} in the alert body.
The watcher I am talking about is created through the UI.

I created a scripted field in the same metricbeat-* index, that contains calculated value in GB from bytes.

But that field is not accessible in watcher UI to set threshold on it. how would a new field appear in there?

AFAIK, scripted fields are not supported in watcher.
You'll have to use scripting as mentioned before.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.