Little problem with Cheks in InfuxDB2

I have problem with Checks when I use ${string(v: r._value)} in status message template.
Cheks doesn’t work.
How can I fix that?

Hello @IvAlIv,
What sort of error are you getting?
Can you share a screen shot your query and your check please?

I create Check with cpu usage_system. I need to send value column in Check message.
When I use ‘${string(v: r._value)}’ in tempale, Check signal about error end no more sending.
Same situation with column _field.


I hope I uderstand your question correctly.

Can you click the eye icon to share the log?
Alternatively you can look at your logs in the task bucket. Something like

from(bucket: "_tasks")
  |> range(start: -1m)
  |> filter(fn: (r) => r._measurement == "runs")
  |> filter(fn: (r) => r.status == "failed")
  |> filter(fn: (r) => r.taskID == "yourtaskID")
  |> group(columns: ["task_id", "_measurement"], mode:"by")

and look at your errorMessage

Log of failure task
,,1,2020-10-23T17:05:26.401245228Z,2020-10-23T18:05:26.401245228Z,2020-10-23T18:04:10Z,"[{""runID"":""0681a7c6c0ed8000"",""time"":""2020-10-23T18:04:00.142231337Z"",""message"":""Started task from script: \""package main\\n\\n\\nimport \\\""influxdata/influxdb/monitor\\\""\\nimport \\\""influxdata/influxdb/v1\\\""\\n\\ndata = from(bucket: \\\""ProxyVPS\\\"")\\n\\t|\u003e range(start: -1m)\\n\\t|\u003e filter(fn: (r) =\u003e\\n\\t\\t(r[\\\""_measurement\\\""] == \\\""cpu\\\""))\\n\\t|\u003e filter(fn: (r) =\u003e\\n\\t\\t(r[\\\""_field\\\""] == \\\""usage_system\\\""))\\n\\t|\u003e filter(fn: (r) =\u003e\\n\\t\\t(r[\\\""cpu\\\""] == \\\""cpu-total\\\""))\\n\\t|\u003e filter(fn: (r) =\u003e\\n\\t\\t(r[\\\""host\\\""] == \\\""f1.fbn\\\""))\\n\\t|\u003e aggregateWindow(every: 1m, fn: last, createEmpty: false)\\n\\noption task = {name: \\\""F1_CPU_Usage_System\\\"", every: 1m, offset: 0s}\\n\\ncheck = {\\n\\t_check_id: \\\""067bf7f1453d3000\\\"",\\n\\t_check_name: \\\""F1_CPU_Usage_System\\\"",\\n\\t_type: \\\""threshold\\\"",\\n\\ttags: {type: \\\""metric\\\""},\\n}\\ncrit = (r) =\u003e\\n\\t(r[\\\""usage_system\\\""] \u003e 10.0)\\nok = (r) =\u003e\\n\\t(r[\\\""usage_system\\\""] \u003c 10.0)\\nmessageFn = (r) =\u003e\\n\\t(\\\""Check: ${r._check_name} is: ${r._level}\\nHost: ${}\\n${string(v: r._value)}\\\"")\\n\\ndata\\n\\t|\u003e v1[\\\""fieldsAsCols\\\""]()\\n\\t|\u003e monitor[\\\""check\\\""](\\n\\t\\tdata: check,\\n\\t\\tmessageFn: messageFn,\\n\\t\\tcrit: crit,\\n\\t\\tok: ok,\\n\\t)\""""},{""runID"":""0681a7c6c0ed8000"",""time"":""2020-10-23T18:04:01.402134274Z"",""message"":""Completed(failed)""},{""runID"":""0681a7c6c0ed8000"",""time"":""2020-10-23T18:04:01.521139033Z"",""message"":""could not execute task run

@Anaisdg Big Thanks for your answer.
I found solution of my problem by myself.
I use ${string(v: r.metric_name)} for return of metric’s value in status message template.

1 Like