Ad Widget

Collapse

HTTP agent and JSON with multiple data points

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nabberuk
    Member
    • May 2010
    • 82

    #1

    HTTP agent and JSON with multiple data points

    Hi,

    I have an API with the following data that i would like to feed into Zabbix. The idea is to grab data every 24 hours, the data contains
    A secure web app that allows you to create, edit, share and save text files to your device or to Google Drive as an editable Doc


    I have a master host that grabs the json file and I'm just at creating dependants. Now i could use jsonpath to grab individual data but there are multiple rows of data. I'm a little unsure on how to do this.

    I would be expecting each name G, I etc to be its own item and then each row under data to be entered with the data and date.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    ​Lets assume you have a master item...

    Now create a discovery, which is "dependent" on that json LLD macro "{#NAME} -> $.name" (and for unit if you wish, can use it in item prototype unit field.. )

    Click image for larger version

Name:	disco.png
Views:	1290
Size:	15.7 KB
ID:	453955 Click image for larger version

Name:	llds.png
Views:	1255
Size:	8.9 KB
ID:	453956

    now add item prototype to that discovery ... again, dependent on the same master item. key -> data[{#NAME}], name as you need it, "#NAME_data" for example... add preprocessing "JSONPath -> $[?(@.name == '{#NAME}')].data[0].[1].first()"
    Click image for larger version

Name:	item_proto.png
Views:	1256
Size:	7.3 KB
ID:	453957 Click image for larger version

Name:	item_preproc.png
Views:	1260
Size:	12.9 KB
ID:	453958


    This shoudl end up with items like this...
    Click image for larger version

Name:	items.png
Views:	1278
Size:	13.9 KB
ID:	453959
    ​ ​ ​nice and colorful... updates each time your master item updates...

    Comment

    • nabberuk
      Member
      • May 2010
      • 82

      #3
      Would this handle the fact that there is more than a single bit of data for each item when the master item makes the call?

      I'm also just testing and getting a "Cannot send request: wrong discovery rule type." error.

      Comment

      • nabberuk
        Member
        • May 2010
        • 82

        #4
        Ignore the error, i was doing check now on the dependant item and not the master one.

        From the looks of it, it will only grab the last entry and not all of them, beginning to wonder if the only way achieve this is via javascript but even then i'm not sure i can add values with their respective datetime
        Last edited by nabberuk; 04-11-2022, 16:56.

        Comment

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

          #5
          Yes it grabs last data point. but if you run it each day, you don't need previous ones, as they are already present... Dependent items are not working this way, that you feed unknown amount of values to them at once and next time it should somehow understand, which ones are already present??... You can of course change data type to text and grab whole that data[] as one data point... but what will you do with it after that?

          Comment

          • nabberuk
            Member
            • May 2010
            • 82

            #6
            The main reason is the data is only updated every 24 hours, so its always 24 hours out of date.

            I'm now investigating a python script and Zabbix sender as it seems i can specify the time of each value.

            Comment

            Working...