Monitor array of objects in JSON response

I've tried monitoring a service with nested JSON using Heartbeat 7.2.0.
Several variants for the check.response.json are not working.

I've tried the following keys for the array check:

data[0].state:
data[0][state]:
data.0.state:
data.[0].state:
"[data][0][state]":

Do you have an idea how to configure the checks for nested json structures?

The json i have is something like that:

{
    "links": {
        "self": "https://example.com/some/url"
    },
    "data": [
        {
            "id": "0",
            "state": "active",
            "hostname": "host1"
        },
        {
            "id": "1",
            "state": "active",
            "hostname": "host2"
        },
        {
            "id": "2",
            "state": "active",
            "hostname": "host3"
        },
        {
            "id": "3",
            "state": "active",
            "hostname": "host4"
        },
        {
            "id": "4",
            "state": "active",
            "hostname": "host5"
        }
    ],
}

My heartbeat config looks like that:

heartbeat.monitors:
- type: http
  name: "Example-check"
  schedule: '@every 10s'
  urls:
    - "https://example.com/some/url"
  tags: ["rancher_env", "qa"]
  check.response:
    status: 200
    json:
    - description: "self link"
      condition:
        equals:
          link.self: "https://example.com/some/url"
    - description: "host 0"
      condition:
        equals:
          data[0].state: "active"

output.console:
  pretty: true

No suggestion????

Unfortunately we don't currently support that, we do have an open issue in beats however here: https://github.com/elastic/beats/issues/12490 . It's something we hope to get to in the medium term.

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