Hello, Im simply looking for a working search sample via API (3.3)
I would like make search query via curl (was using old api method), but now, Im unable to get cache value of dashboard/view, and can’t find how may I make a single card(field) on a simple query.
With API Browser, I find search_id, and object in view, but how may I execute query and get back result ?
I found a solution that I post here for anyone need.
I don’t think it’s the best way, but it work for my needs:
How to get value of a widget (single value) from a dashboard:
Get search_id from IDDASHBOARD: curl -s -u login:password -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-By: XMLHttpRequest' -X GET "http://127.0.0.1:9000/api/views/${IDDASHBOARD}" | jq .search_id
Get Widget list from IDSEARCH (first field is id): curl -s -u login:password -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-By: XMLHttpRequest' -X GET "http://127.0.0.1:9000/api/views/search/${IDSEARCH}" | jq '.queries[].search_types[]? | "\(.id) \(.query.query_string) \(.series) \(.timerange.type)"'
Get value of widget from IDSEARCH and IDWIDGET: curl -s -u login:password -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-By: XMLHttpRequest' -X POST "http://127.0.0.1:9000/api/views/search/${IDSEARCH}/execute" --data-binary '{"global_override":{},"parameter_bindings":{}}' --compressed| jq '.results[].search_types."'${IDWIDGET}'".rows[]?.values[].value'