icinga2 performance_data filter from services endpoint

This forum was archived to /woltlab and is now in read-only mode.
  • Hello everybody,


    I am trying to to a GET request on the "/v1/objects/services" endpoint using the CURL command.

    My main objective is to receive the performance_data of each service (which is present inside last_check_result array in the response).


    For ex.

    Code
    1. $ curl -k -s -u root:icinga 'https://localhost:5665/v1/objects/services?attrs=last_check_result' | python -m json.tool



    gives me the following result



    But i am interested only in the performance_data part.


    Code
    1. "performance_data": [
    2.                         "/=16519MB;59519;66959;0;74399"
    3.                     ],


    But queries like

    Code
    1. $ curl -k -s -u root:icinga 'https://localhost:5665/v1/objects/services?attrs=last_check_result.performance_data' | python -m json.tool

    or


    Code
    1. $ curl -k -s -u root:icinga 'https://localhost:5665/v1/objects/services?attrs.last_check_result=performance_data' | python -m json.tool


    DOES NOT WORK.




    Can anybody please help making this query up?


    I would like to receive data ideally in the below format.




    Please help me making a query which would give similar data.


    Thanks in advance

  • The below might narrow the result a bit but is not perfect:

    curl -k -s -u root:password 'https://localhost:5665/v1/objects/services?attrs=last_check_result' | python2.7 -m json.tool

    I would use something like python or perl to get the complete object and drill down in it after it has been aquired.


    why dont you subscribe to the event streams ?

    https://www.icinga.com/docs/ic…cinga2-api/#event-streams


    That would take you out of the burden to poll.

    The post was edited 1 time, last by sru ().

  • Sub-Level filters are not supported by the API, and there are no plans atm to change that. Use it in a programmatic fashion as sru suggested.

  • Thanks sru for the response. The curl command you have mentioned is what i have been using in my code but last_check_result contains a lot of information along with performance_data which are not relevant to me. Thats why i was looking for a way to filter in the sub-level of the last_check_result. But as dnsmichi pointed out it seems like it is not possible.

  • Sub-Level filters are not supported by the API, and there are no plans atm to change that. Use it in a programmatic fashion as sru suggested.

    Thanks dnsmichi for the response. seems like there is no option for sub-level filter as you said. Wil have to process the entire content in last_check_result array.

  • There's a feature request somewhere. The thing is that the code is pretty flexible without sub filtering. Adding such might need larger rewrites, which is mainly the reason no-one has looked into it for now. The API must remain stable at all cost, so changes like this require tests on the long run too after a code patch has been provided.