Hi! I'm trying to monitor Traefik HTTP Services using it's API ( https://doc.traefik.io/traefik/operations/api/). Accessing "http://traefik-host:8080/api/http/services/API-NAME" I receive the following JSON:
My idea is:
Any hints? What I'm trying is possible with JSONPath?
Code:
{
"loadBalancer": {
"servers": [
{
"url": "http://10.0.1.102:8080"
},
{
"url": "http://10.0.1.104:8080"
}
],
"passHostHeader": true
},
"status": "enabled",
"usedBy": [
"API-NAME"
],
"serverStatus": {
"http://10.0.1.102:8080": "UP",
"http://10.0.1.104:8080": "UP"
},
"name": "API-NAME",
"provider": "docker",
"type": "loadbalancer"
}
- Create a HTTP Agent Item to grab this JSON (done)
- Create a "Dependent Item" (pointing to previous item) to get the size of "servers" array (JSONPath -> $.loadBalancer.servers.length() ) (done)
- Create another "Dependent Item" (also from the first one), filtering by all attributes on "serverStatus" with "UP" value (and get its count), so I can create a trigger when the value of Item 3 is lower than of Item 2.
- $.serverStatus
- .length() - brings the total of lines, but no filtering at all.
- $.serverStatus[?(
- == 'UP')].length()
- $.serverStatus[?($.serverStatus
- == 'UP')].length()
- many other combinations
Code:
cannot extract value from json by path "$.serverStatus[?([*] == 'UP')]": unsupported construct in jsonpath starting with: "[*] == 'UP')]"
Comment