#Is it possible to filter a REST API query?

1 messages · Page 1 of 1 (latest)

open ridge
#

I'm using this command to look up a single metric (say the cpu_busy counter) in FSx:

curl -X GET -u $CREDS -k "https://$IP/api/cluster/counter/tables/system:node/rows/FsxId04b8e68e5356dd70f-01:2cc84561-3469-11ed-b7d8-eb45dba40d9d"

the trouble is that query results in ONTAP giving me the output for ~90 counters when all I want is a single counter.

Is there a way to filter the query to only return one metric? I know I can use something like jq to filter the output, but I'd rather filter the query itself..

twin elbow
#

How about this?
https://CLUSTER_IP/api/cluster/counter/tables/volume/rows?return_records=true&counters.name=bytes_read&fields=properties,counters

open ridge
#

@twin elbow that is a great help, thank you! it looks like I can query two counters at the same time with the | operator:

curl -X GET -u $CREDS -k "https://$IP/api/cluster/counter/tables/system:node/rows?return_ecords=true&counters.name=total_ops|total_latency&fields=properties,counters"

posting that here in case anyone has the same question 🙂 and, of course, you can use wildcards with *

twin elbow
#

Yes you can use some of the wild cards as well.

open crane
#

How come I got the result of "API not found"?, used the same line but different $IP and $CREDS

twin elbow
#

RestPerf API are available from ONTAP 9.12+ onwards

open crane
#

@twin elbow I am on 9.9.1. As you pointed out that's why I coudn't use it. Where in the line is the indication of using RestPerf API, or how it was called in 9.12? What are similar API's (performance counters) can be used for 9.11 or prior. Thanks!

twin elbow