Re:api to query a specific service

I’m trying to write a query, using a filter, but I can’t seem to get it right. I am able to list all the services using the API on all hosts but not able to list any specific services.I want to find just the ones that match for example ‘check_disk’( which run’s on all nodes and filebeat service which runs on only specific nodes I tried with the below command but didn’t helped and have tried searching, but I don’t seem to find the docs I need.

The below command gives me a 200 but no results.

curl -k -s -u root:a58ad06f650b97a9 -H ‘Accept: application/json’ -H ‘X-HTTP-Method-Override: GET’ -X POST ‘https://localhost:5665/v1/objects/services’ -d ‘{ “filter”: “service.state==state && match(pattern,service.name)”, “filter_vars”: { “state”: 2, “pattern”: “*check_dns” } }’
{“results”:[]}

Tried it myself:

curl -k -s -u 'user:password' -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/services' -d '{ "filter": "service.state==state && match(pattern,service.name)", "filter_vars": { "state": 2, "pattern": "service*" } }'

Worked without a problem. Queried for critical services with names beginning with “service” followed by anything.
What you are currently looking for are services with state 2 (CRITICAL) and their names ending in “check_dns”. Is that what you want?