Problem with import - CheckThreshold


I exported CheckThreshold from my Influxdb with CLI,
When I try to import using the command:

influx apply -o HO -f b.yaml

It works, But I get the following message:

Anyone know why?

This is my yaml file:

kind: CheckThreshold
name: trusting-euler-eb301b
every: 30s
name: cpu test
query: |-
from(bucket: “HO”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == “cpu”)
|> filter(fn: (r) => r["_field"] == “usage_system”)
|> filter(fn: (r) => r[“cpu”] == “cpu-total”)
|> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
|> yield(name: “mean”)
status: active
statusMessageTemplate: ‘Check: ${ r._check_name } is: ${ r._level } bla bla cpu
is - ${string(v: r.usage_system)}’
- level: OK
type: greater
value: 0

Hi @eliranm,

It looks like checks exported/imported via the CLI like this do not include the saved state of the query builder. When you first opened the imported check in the UI, did it show the error message? The imported check should work, but when you click in the query builder it essentially re-starts the query building process, and since a field isn’t selected in the screenshot, it is saying you need to select a field. If you import a check with influx apply and open it without clicking anything in the query builder I don’t believe it will show an error like that.


Thanks for the comment.

This happens right after importing, even if I only enter the screen:

Even if the imported threshold works, this situation is problematic, because users want to know on which field the threshold works.

Interesting that it shows the error even if you only just enter the screen - using Influxdb v2.0.4 it does not seem to behave that way for me - although the status of the builder selections is not retained. Which version are you trying this with?

At any rate, I agree that not retaining the status of the builder fields for the check is not ideal when exporting and applying them, so I have opened an issue in the influxdb github repo: Exporting and importing checks does not retain "builder" state · Issue #21508 · influxdata/influxdb · GitHub so that we can keep track of this issue and work on getting it fixed.

I am using in the version 2.0.4.

This fix will be very useful for us.

Thank you!