Issues on creating a check via the InfluxDB v2 API

Hello,
I am currently working on my bachelor thesis and for this I am working with InfluxDB.

I am trying to create a Check in InfluxDB with the v2 API via Postman and get this Response:
“unable to detect the check type from json”

This is my request body:

{
    "name": "<name>",
    "ownerID": "<owner id>",
    "orgID": "<org id>",
    "query": {
        "text": "from(bucket: \"<bucket name>\")\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n  |> filter(fn: (r) => r[\"_measurement\"] == \"<measurement name>\")\n  |> filter(fn: (r) => r[\"_field\"] == \"<field name>\"),
        "editMode": "builder",
        "name": "<query name>",
        "builderConfig": {
            "buckets": [
                "<bucket name>"
            ],
            "tags": [
                {
                    "key": "_measurement",
                    "values": [
                        "<measurement name>"
                    ],
                    "aggregateFunctionType": "filter"
                },
                {
                    "key": "_field",
                    "values": [
                        "<field name>"
                    ],
                    "aggregateFunctionType": "filter"
                }
            ],
            "functions": [
                {
                    "name": "mean"
                }
            ],
            "aggregateWindow": {
                "period": "1m",
                "fillValues": false
            }
        }
    },
    "statusMessageTemplate": "Check: ${ r._check_name } is: ${ r._level }",
    "every": "5s",
    "offset": "1s",
    "thresholds": [
        {
            "allValues": false,
            "level": "CRIT",
            "min": 0.2,
            "max": 1.1,
            "within": true,
            "type": "range"
        }
    ],
    "type": "threshold",
    "status": "active"
}

I don’t understand the error response. As written in my request body I set the type to “threshold”.

Did anybody else encountered this problem or could help me in any way?

Best regards,
Vinzenz

Hello @vinnivitz,
This post could be of value to you:

Of course you’ll want to replace it with a threshold check instead.
Like:

{
  "name": "Test Check2",
  "orgID": "0437f6d51b579000",
  "query": {
    "text": "from(bucket:\"telegraf\") |> range(start:-5h) |> filter(fn:(r) => r._measurement == \"cpu\")"},
  "name": "check2",
  "status": "active",
  "description": "this is a check2",
  "type": "threshold",
  "every": "1m",
  "offset": "10s",
  "statusMessageTemplate": "Critical State"
  "thresholds": [
{
"level": "UNKNOWN",
"allValues": true,
"type": "greater",
"value": 0
}
],
}

I hope that helps. I haven’t tested it though so please let me know if you’re still having problems.