Ad Widget

Collapse

API: the history.get "history" parameter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r-br
    Junior Member
    • Feb 2011
    • 27

    #1

    API: the history.get "history" parameter

    On the API (version 1.8.3), I need to retrieve some history data through history.get, something like this:

    Code:
    {
      'history'   : 3,
      'itemids'   : [ 32755, 32749 ],
      'time_from' : 1299233040,
      'time_till' : 1299236640,
      'output'    : 'extend'
    }
    Is it possible to pass multiple values in the 'history' parameter? The documentation says it receives an array, but I tried an array and it didn't work. These two items have different 'value_type' properties, which are 0 and 3.

    The 'history' parameter works correctly if I pass a single value, like "0" or "3". However, if I pass "0" only the first item is fetched, if I pass "3" only the second item is fetched (and this is correct). But I'd like to retrieve both items on the same request, so I need to pass both "0" and "3". How can I do that?

    Thanks in advance.
  • richlv
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2005
    • 3112

    #2
    seems to work as expected for me in trunk. can you show exact raw json sent to the api for a request with one 'history' value and multiple of them ?
    Zabbix 3.0 Network Monitoring book

    Comment

    • r-br
      Junior Member
      • Feb 2011
      • 27

      #3
      Precisely this (among other different items):

      Code:
      {
        jsonrpc : '2.0',
        id      : 1,
        auth    : '56234204aba448ce62925126454404f4',
        method  : 'history.get',
        params  : {
          itemids   : [ 32755, 32749 ],
          time_from : 1299257280,
          time_to   : 1299260880,
          output    : 'extend',
          history   : [ 3, 0 ]
        }
      }
      As for the items, 32755 has value_type=3, and 32749 has value_type=0.
      If I pass history=3, I get only the data from 32755 (correct).
      If I pass history=0, I get only the data from 32749 (correct).

      However, if I pass any kind of array (like the one shown in the code above), I always get the data from 32749, as if the whole array is always being evaluated to 0.

      Comment

      • nelsonab
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Sep 2006
        • 1233

        #4
        Open a bug in the bug tracker and ask for clarification with regards to the documentation. Also ask for clarification as to what the appropriate values are for history and their meaning. It's hard to say if this is a bug or if it's working as it should as there is nothing to say either way. In one part history is an array, yet in the example it is not.

        Please open a bug so the fix can be tracked.
        RHCE, author of zbxapi
        Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
        Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

        Comment

        • richlv
          Senior Member
          Zabbix Certified Trainer
          Zabbix Certified SpecialistZabbix Certified Professional
          • Oct 2005
          • 3112

          #5
          try enclosing itemids in doublequotes, and potentially enclosing history and itemids arrays in curly braces. error reporting is in a bit sad state, but i think it doesn't like how you have formatted the query.

          and i think all kinds of param names etc also might have to be doublequoted. unfortunately, api is extremely picky about this, and i haven't found such generic rules documented anywhere so far.

          as an example, this seems to work :

          Code:
          {"jsonrpc":"2.0","id":1,"auth":"$auth","method":"history.get","params":{"itemids":["32755","32749"],"time_from":"1299257280","time_to":"1299260880","history":[3,0]}}
          (using zabcon auth and blah )
          Zabbix 3.0 Network Monitoring book

          Comment

          • Aly
            ZABBIX developer
            • May 2007
            • 1126

            #6
            Originally posted by richlv
            try enclosing itemids in doublequotes, and potentially enclosing history and itemids arrays in curly braces. error reporting is in a bit sad state, but i think it doesn't like how you have formatted the query.

            and i think all kinds of param names etc also might have to be doublequoted. unfortunately, api is extremely picky about this, and i haven't found such generic rules documented anywhere so far.

            as an example, this seems to work :

            Code:
            {"jsonrpc":"2.0","id":1,"auth":"$auth","method":"history.get","params":{"itemids":["32755","32749"],"time_from":"1299257280","time_to":"1299260880","history":[3,0]}}
            (using zabcon auth and blah )
            Quoting is needed only for object ids in distributed monitoring and of course strings.

            Originally posted by r-br
            Precisely this (among other different items):

            Code:
            {
              jsonrpc : '2.0',
              id      : 1,
              auth    : '56234204aba448ce62925126454404f4',
              method  : 'history.get',
              params  : {
                itemids   : [ 32755, 32749 ],
                time_from : 1299257280,
                time_to   : 1299260880,
                output    : 'extend',
                history   : [ 3, 0 ]
              }
            }
            As for the items, 32755 has value_type=3, and 32749 has value_type=0.
            If I pass history=3, I get only the data from 32755 (correct).
            If I pass history=0, I get only the data from 32749 (correct).

            However, if I pass any kind of array (like the one shown in the code above), I always get the data from 32749, as if the whole array is always being evaluated to 0.
            Sorry, currently it's not possible, due to pick values for different item value types we have to make 2 queries and then merge thous results, which in fact can consist of different fields..
            Zabbix | ex GUI developer

            Comment

            • richlv
              Senior Member
              Zabbix Certified Trainer
              Zabbix Certified SpecialistZabbix Certified Professional
              • Oct 2005
              • 3112

              #7
              Originally posted by Aly
              Sorry, currently it's not possible, due to pick values for different item value types we have to make 2 queries and then merge thous results, which in fact can consist of different fields..
              that's... good to know =)

              this bit of info is now listed at http://www.zabbix.com/documentation/1.8/api/history/get and http://www.zabbix.com/documentation/...pi/history/get

              maybe such a history.get call should even error out instead of returning partial data ?
              Zabbix 3.0 Network Monitoring book

              Comment

              • r-br
                Junior Member
                • Feb 2011
                • 27

                #8
                Originally posted by Aly
                Sorry, currently it's not possible, due to pick values for different item value types we have to make 2 queries and then merge thous results, which in fact can consist of different fields..
                That's what I was doing so far, I was just trying to save one query bringing all the results within a single call.

                Thanks everyone for the patience.

                Comment

                Working...