RestAPI - service downtime via query

Hey folks,
I want to schedule a downtime via restAPI via query.
I do not fully understand how the query should look like.
Doc says: An query expression of the Livestatus ‘services’ table in nested dictionary form. If you want to use multiple expressions, nest them with the AND/OR operators.
example:

example: {"op": "and", "exprs": [{"op": "=", "left": "name", "right": "example.com"}, {"op": "!=", "left": "state", "right": "0"}]}

what is meant with left and right here?

lq query works like this:

lq "GET services\nColumns: host_name description\nFilter: description ~~ svsko42"
SWFCKO5;Port 02 SVSKO42_S2U
SWFCKO5;SFP Temperature 02 SVSKO42_S2U
SWFCKO5;SFP 02 SVSKO42_S2U
SVSKO42;HostSystem SVSKO42
SWFCKO6;SFP Temperature 02 SVSKO42_S2L
SWFCKO6;Port 02 SVSKO42_S2L
SWFCKO6;SFP 02 SVSKO42_S2L

How do I need to transform that to the RestAPI query?

Thanks a lot for your help!

Hi,

here is an example when you want to use the regular expression “svsko42” for the description.

{'op': '~', 'left': 'description', 'right': 'svsko42'}

left means parameter like host_name and description, and right means the value for it.

This will search for the host_name myhost and a regular expression (svsko42) for the service description:

{"op": "and", "expr": [{"op": "=", "left": "host_name", "right": "myhost"} ,{"op": "~", "left": "description", "right": "svsko42"}]}

Best Regards
Thomas

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.