chronograf icon indicating copy to clipboard operation
chronograf copied to clipboard

Unable to use field value in alert message

Open agrrh opened this issue 9 years ago • 2 comments

Hello!

This is alert I'm building from Chronograf UI v1.1.0~beta:

SELECT "used_percent" FROM "udp"."autogen"."disk" WHERE time > now() - 15m GROUP BY "host", "path"

Note that I'm unable to select two fields by design, they are mutually exclusive and first field marks off when I mark second one.

Then I'm writing alert message like so:

{{ .Level }} Used {{ index .Fields "used_percent" }} of {{ index .Tags "path" }}
{{ index .Tags "host" }}

Supposed to output:

CRIT Used 85% of /

Actually outputs:

CRIT Used <no value> of /

Looks like it can't see value of field which was not selected.

How to send more fields with alert message? Should I create such alerts via console Kapacitor's interface?

agrrh avatar Dec 08 '16 10:12 agrrh

Hey there @agrrh . I looked into this and we are going to update the UI to make it mroe clear what is going on.

Basically, the field that we are passing through the alert is renamed with a kapacitor .as to value.

This allows us to have a single query to look at all the current alerts (select value from ...)

So, the immediate answer to your question is to :

{{ .Level }} Used {{ index .Fields "value" }} of {{ index .Tags "path" }}
{{ index .Tags "host" }}

However, we are going to add information in the UI about this as well.

goller avatar Dec 20 '16 17:12 goller

@121watts Replace {{ .Fields }} with {{ index .Fields "value" }} This should work with all TICK scripts created by the kapacitor UI

nhaugo avatar Jan 04 '17 21:01 nhaugo