Announcement

Collapse
No announcement yet.

JSON API output filter

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    JSON API output filter

    From zabbix API documentation:

    Get methods output parameter

    Output can be “shorten”, “refer”, “extend” and array of db field names.

    -shorten: only ids of elements are returned. (for hosts it's hostid, for items itemid etc)
    -refer: element ids are returned with element ids that were used in query.
    For example request item.get(output: refer, hostids: [1,2,3])) will return items with itemids and hostids.
    -extend: all db fields of element are returned (select *)
    -array of db fields: listed db fields are returned


    What is the correct format to pass an array of db fields? I have tried the following:

    Code:
    {
       "id":"1",
       "method":"item.get",
       "params":
       {
    	"search":{"description":"Comp."},
    	"seachWildcardsEnabled":"1",
    	"output":["lastvalue","lastclock","host"]
       },
       "jsonrpc":"2.0",
       "auth":"045fe742cf405bb83281bff2567b1eef"
    }
    but this only returns the itemids

    Code:
    {
       "jsonrpc":"2.0",
       "result":[
          {"itemid":"22319"},
          {"itemid":"22318"},
          {"itemid":"22328"},
          {"itemid":"22330"},
          {"itemid":"22332"},
          {"itemid":"22334"},
          {"itemid":"22336"},
          {"itemid":"22338"},
          {"itemid":"22324"},
          {"itemid":"22326"},
          {"itemid":"22325"},
          {"itemid":"22327"},
          {"itemid":"22329"},
          {"itemid":"22331"},
          {"itemid":"22333"},
          {"itemid":"22335"},
          {"itemid":"22337"},
          {"itemid":"22339"}],
       "id":"1"
    }
    or is there a different way to filter the returned fields?
    Last edited by akushner; 08-02-2012, 00:03.

    #2
    Not supported for items

    After doing a little more digging, I found an update that states the following

    from http://www.zabbix.com/documentation/...etting_started

    “output”:“extend” means that you want to get all available info about each group. This, in a way, is similar to “SELECT *” in SQL. Possible options of “output” are:

    “extend” - get all info;
    “shorten” - get only ids of an object;
    “refer” - get id of an object and also ids of related objects;
    list of fields, like [“groupid”, “name”] - get only listed fields.

    List of fields is only supported in Alert, DCheck, Host, DService, Screenitem, Template and Trigger get methods.

    Comment

    Working...
    X