Ad Widget

Collapse

Zabbix API | Power BI | item.get | Date range for getting item details

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • debayanbanerjee
    Junior Member
    • Mar 2023
    • 5

    #1

    Zabbix API | Power BI | item.get | Date range for getting item details

    Hello.

    I am not able to find a way how to pass a date range parameter ( from (date) and to (date) into the item.get API query.

    The parameters time_till and time_from are not working (The API query is running though). This is the query I am using.

    let
    token = *hidden*
    ZabbixURL = *hidden*
    Body =
    "{
    ""jsonrpc"": ""2.0"",
    ""method"": ""item.get"",
    ""params"": {
    ""output"": """output"": [""name"", ""hostid"", ""lastvalue"", ""prevvalue"", ""lastclock""]
    },
    ""auth"": """ & token & """,
    ""id"": 1
    }",
    Source = Json.Document(
    Web.Contents(
    ZabbixURL,
    [
    Headers=[
    [HASHTAG="t3950"]content-type[/HASHTAG]="application/json"
    ],
    Content = Text.ToBinary(Body)
    ]
    )
    )
    in
    Source
    Any help?​
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Are you sure you are supposed to be able to do that? What would from and to give to item.get query, which gives you item configuration? There is really nothing to do with date range...

    Comment

    • debayanbanerjee
      Junior Member
      • Mar 2023
      • 5

      #3
      I need a date range to fold the query and set up incremental refresh on the generated dataset.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        Originally posted by debayanbanerjee
        I need a date range to fold the query and set up incremental refresh on the generated dataset.
        Whatever that means.. but you do not have any date range selection in item.get method...

        Comment

        • debayanbanerjee
          Junior Member
          • Mar 2023
          • 5

          #5
          Ok. Let me rephrase.

          In power bi the 'last value' and 'prev value' is updated everytime the data is refreshed. I need to store the previous values as well, that is done using incremental refresh. In order for incremental refresh to work we need to pass a date or a date range so that it does not retrieve all the data all over again. So if I define a start date then the API ideally should not fetch anything before that date (limits the size of the dataset).

          Now, as you are saying that there is not date range selection in item.get method, what can be a work around? is there a data range selection in host.get method? I can then make a relationship between the hostid and itemid.

          Hope it is clearer now. :-)

          Can't I set up something using 'lastclock' in item.get? Say I don't need any more items before lastclock value is so and so? will mathematical operators like less than or greater than work with lastclock value ?
          Last edited by debayanbanerjee; 22-03-2023, 10:06.

          Comment

          • mcflurry
            Member
            • Jun 2022
            • 32

            #6
            You have to retrieve data from api in trends and history, not in items.

            Comment

            • debayanbanerjee
              Junior Member
              • Mar 2023
              • 5

              #7
              I am getting parsing error on using the trend.get api as mentioned in the documentation. The 'itemids' is from my own data. Is there anything that I am doing wrong?


              ​let
              token = hidden,
              ZabbixURL = hidden,
              Body =
              "{
              ""jsonrpc"": ""2.0"",
              ""method"": ""trend.get"",
              ""params"": {
              ""output"":
              [
              ""itemid"",
              ""clock"",
              ""num"",
              ""value_min"",
              ""value_avg"",
              ""value_max"",
              ]​
              ""itemids"": [
              ""87322""
              ],
              ""limit"": ""1""
              },
              ""id"": 1
              }",
              Source = Json.Document(
              Web.Contents(
              ZabbixURL,
              [
              Headers=[
              [HASHTAG="t3950"]content-type[/HASHTAG]="application/json"
              ],
              Content = Text.ToBinary(Body)
              ]
              )
              )
              In
              Source

              Comment

              • mcflurry
                Member
                • Jun 2022
                • 32

                #8
                Originally posted by debayanbanerjee
                I am getting parsing error on using the trend.get api as mentioned in the documentation. The 'itemids' is from my own data. Is there anything that I am doing wrong?


                Follow this:

                https://blog.zabbix.com/zabbix-api-c...postman/12198/

                With postman you can fine-tune the API queries, it was quite useful for me.

                Comment

                • debayanbanerjee
                  Junior Member
                  • Mar 2023
                  • 5

                  #9
                  I am sorry. It was my mistake. In a hurry to copy paste I was overwriting the auth token. Now the history and trend apis are working.

                  Comment

                  Working...