Ad Widget

Collapse

API - How to get Grap Values? History and Trend already trieg - Help please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iphcarlos
    Junior Member
    • Jan 2023
    • 2

    #1

    API - How to get Grap Values? History and Trend already trieg - Help please

    Hi everyone, hope you're fine

    I'm using the Zabbix API (https://www.zabbix.com/documentation.../en/manual/api) and I'm facing a thing, I am not able to retrieve data from graphs, and I don't know how to do it...

    I would like to get, i.e. the average value for this graph:
    Click image for larger version

Name:	GraphAvg.png
Views:	1105
Size:	371.2 KB
ID:	457629



    I have been looking for this, and seen some answers telling to use history items or trends

    This is for a report automation, so, this is why I'm trying to get it via API

    I have tried with trends, going for each one and saving all its values
    Max and Min values are always possible to get (the Max of the maxs, and the Min of the mins)
    But average is another thing, I have tried sum all of them and then divide by the number of trends, and it gives an approach but is not exact

    So, that's why I'm looking for help

    Using hsitory.get, I don't know how to interpret each item value, and haven't been able to calculate any proper result

    If someone could give me a hand with this, I would really appreciate it

    Thank you so much for your time​
  • LenR
    Senior Member
    • Sep 2009
    • 1005

    #2
    The graph covered a month, so Zabbix probably pulled data from trends, not history. It will pull data for short intervals from history, longer from trends. Trends has one observation per item per hour, so for each line in the graph, it got about 720 data points (24 hours x 30 days). Trends records consist of 3 data items, min, max and avg. Note the "avg" in the legend, this graph only looked at the trend average field. The 720 data points were graphed and the legend was programmatically constructed for the 720 items, last item, min max and avg.

    If you got the trend data in python, for example, put each "avg" field in a list, then just mean(the_list) to get the average.

    If you graph an item with "all" instead of min, max or avg, you will get a "fuzzy line" graph showing all 3.
    Last edited by LenR; 17-01-2023, 00:21.

    Comment

    • WirelessGuru
      Junior Member
      • Feb 2022
      • 9

      #3
      I think I'm looking for the same thing.

      I simply need to great a monthly report of uptime for specific hosts. Is there a way to run an API against a list of hosts to retrieve the previous months uptime? The AVG value in the ICMP Graph is exactly the data point I need and I can get it by going to the node, selecting previous month, and looking at the graph. Trying to do this via API since I can't do it in the availability report. The API would run on a cronjob on the first of every month by using this range FROM=now-1M/M and TO=now-1M/M.

      Appreciate any help from folks.

      Comment


      • iphcarlos
        iphcarlos commented
        Editing a comment
        I have achieved to get Graph Data, but there is a variation of 0.1 - 0.35 (up or down) in average values (min and max are corrects), will that work for you?

      • WirelessGuru
        WirelessGuru commented
        Editing a comment
        I think that variation might skew the results were looking for. The value AVG in the ICMP graph I believe shows the count of successful pings divided by total count. This in turn I believe would mean the uptime % for a device and the value changes based on the time range in the filter tab. If were off by .1 for instance that would imply 10% which would be problematic.

        I appreciate the info though. Glad to know other folks are seeking this one out as well.
    • mikk
      Junior Member
      • Apr 2023
      • 4

      #4
      You can create a calculated item with trendavg function like trendavg(//vm.memory.util,1M:now/M). this this will give you the avg value of previous month.
      simillarly you can do it for other components as well.

      and setup a api which will fetch the item with the key you setup for the calcualted iteam and collect the lastvlaue output for your reporting.

      hope this will work for you.

      Comment

      Working...