Ad Widget

Collapse

Monitoring Proxmox Backup Server via JSON API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ohmer
    Junior Member
    • Oct 2013
    • 20

    #1

    Monitoring Proxmox Backup Server via JSON API

    Hello,

    I'm trying to monitor verify tasks on Proxmox Backup Server using their json API with Zabbix 5.0.35. I think I have to use the "http agent" and discovery rule.

    The url https://server-hostname:8007/api2/json/admin/verify returns this json data:

    Code:
    {"data":[{"id":"v-feca4620-6ba7","ignore-verified":true,"last-run-endtime":1687868864,"last-run-state":"OK","last-run-upid":"UPID:backup-pbs-qc:00101FA3:13132DD1:00001C14:649ABA32:verificationjob:sur\\x2dsite\\x3av\\x2dfeca4620\\x2d6ba7:root@pam:","next-run":1687948200,"ns":"","outdated-after":30,"schedule":"06:30","store":"sur-site"},{"id":"v-91292f7d-c68a","ignore-verified":true,"last-run-endtime":1687865400,"last-run-state":"OK","last-run-upid":"UPID:backup-pbs-qc:00101FA3:13132DD1:00001C1C:649AC838:verificationjob:hors\\x2dsite\\x3av\\x2d91292f7d\\x2dc68a:root@pam:","next-run":1687951800,"ns":"","outdated-after":30,"schedule":"7:30","store":"hors-site"}],"digest":"cffeedd294865525dcd18d42d3c0f06eccd4bcf2b7913db1221cbcdca024ffa1"}
    I want to discover all existing verify job and for each of them, extract the last run date (last-run-endtime field) and the last run state (last-run-state field) as items. I will use theses values to configure triggers if last run date is too old or if the last state is not ok.

    This is what I done so far. This doesn't work and I'm lost. Somebody can help me please?

    I created an item with the HTTP agent type. It seem to work, I can get the json reply when I hit the test button.

    Click image for larger version  Name:	1-PBS-Item.png Views:	0 Size:	67.2 KB ID:	466667

    Then I created a discovery rule. I think this is where I'm starting to be lost.

    Click image for larger version  Name:	2-PBS-Disco.png Views:	0 Size:	50.7 KB ID:	466668

    Click image for larger version  Name:	3-PBS-Disco-LLDMacro.png Views:	0 Size:	36.6 KB ID:	466669

    ​Then an item prototype.

    Click image for larger version  Name:	4-PBS-Disco-ItemPrototype.png Views:	0 Size:	72.3 KB ID:	466670

    Thanks.​
    Last edited by ohmer; 28-06-2023, 18:16.
  • ohmer
    Junior Member
    • Oct 2013
    • 20

    #2
    Sorry to bump, I'm still stuck with this issue.

    Comment

    • ISiroshtan
      Senior Member
      • Nov 2019
      • 324

      #3
      Hey there.

      Could you add details what exactly is not working?

      Based on what I see I would expect you to have master item (HTTP Agent one) working and collecting full JSON at set intervals, right?

      Aslo I would expect discovery to create dependent items for each job returned in JSON. Or does it not?
      If it does creates dependent items for each job, what state Zabbix shows them in? Just enabled with no errors? Unsuported with wrong data type? Something else?

      Also, for item prototypes, did you add a preprocessing to extract only the field you want?

      Comment

      • ohmer
        Junior Member
        • Oct 2013
        • 20

        #4
        Hello,

        Based on what I see I would expect you to have master item (HTTP Agent one) working and collecting full JSON at set intervals, right?
        Correct, I see the json data for the key pbs.verify_jobs ​when viewing the host's latest data.

        Aslo I would expect discovery to create dependent items for each job returned in JSON. Or does it not?
        If it does creates dependent items for each job, what state Zabbix shows them in? Just enabled with no errors? Unsuported with wrong data type? Something else?​
        No. I think this is where I start to be lost. I just noticed the discovery item is marked as unsupported.

        Click image for larger version

Name:	image.png
Views:	3535
Size:	46.5 KB
ID:	467207

        Not sure if I added this preprocessing step after or before my post, but seem like this screenshot is missing on my original post :

        Click image for larger version

Name:	image.png
Views:	3528
Size:	35.3 KB
ID:	467208

        Thanks for the help!

        Comment

        • ISiroshtan
          Senior Member
          • Nov 2019
          • 324

          #5
          Ok, now that error is someting to work with

          While the syntax of JsonPath is technically correct as far as I can say, doing test in my Zabbix I also have the same error. Seems like PHP or Zabbix is not able to chew through dash symbol as is. So could you modify preprocessing on item to
          Code:
          $.["last-run-endtime"]
          and try again.

          Please do tell if still not working.

          Comment

          • ohmer
            Junior Member
            • Oct 2013
            • 20

            #6
            Hello,

            Oh, there is progress! My items are now created but they are in error.

            Click image for larger version  Name:	image.png Views:	0 Size:	56.0 KB ID:	467369

            Seem like this return an array, not sure if this is expected or not ?

            Click image for larger version  Name:	image.png Views:	0 Size:	39.8 KB ID:	467370


            Thank you!​
            Last edited by ohmer; 18-07-2023, 17:03.

            Comment

            • ISiroshtan
              Senior Member
              • Nov 2019
              • 324

              #7
              Ah, right right, makes sesne.

              When you do discovery the discovery process strips parets of the JSON and only works with "data" section of json. But when you referencing Master item from dependent item it takes a full JSON.
              Please do try for dependent items pre-processing to use the
              Code:
              $.data.["last-run-endtime"]

              Comment

              • ISiroshtan
                Senior Member
                • Nov 2019
                • 324

                #8
                Also, for your end goal you'd need to add the filter criteria to select only data of the specific job. So in the end you likely have to use something like below for item prototype preporcessing:
                Code:
                $.data.[?(@.id == "{#JOBID}")].["last-run-endtime"].first()
                (when testing with JSON path tester mind that you need to substitue zabbix Macro {#JOBID} with real value, like v-feca4620-6ba7. And the final part .first() is Zabbix specific implementation of JSONPath, online testers will not be able to parse it. It's used to transform JSON array returned by JSONPath into single Value that is suitable for Zabbix item)

                Comment

                • ohmer
                  Junior Member
                  • Oct 2013
                  • 20

                  #9
                  Unfortunately, I still get the same error

                  Click image for larger version

Name:	image.png
Views:	3524
Size:	70.8 KB
ID:	467376

                  I just noticed the error message is the same for both items (they both starts with "data":[{"id":"v-feca4620-6ba7",). Seem like it works on the full original json data without any field extraction. I guess this is unexpected?

                  Comment

                  • ohmer
                    Junior Member
                    • Oct 2013
                    • 20

                    #10
                    I didn't see your additional post before answering. It works!!

                    Many thanks for your help

                    Comment

                    • flavio.lopes
                      Junior Member
                      • Nov 2023
                      • 1

                      #11
                      Originally posted by ohmer
                      Hello,

                      I'm trying to monitor verify tasks on Proxmox Backup Server using their json API with Zabbix 5.0.35. I think I have to use the "http agent" and discovery rule.

                      The url https://server-hostname:8007/api2/json/admin/verify returns this json data:

                      Code:
                      {"data":[{"id":"v-feca4620-6ba7","ignore-verified":true,"last-run-endtime":1687868864,"last-run-state":"OK","last-run-upid":"UPID:backup-pbs-qc:00101FA3:13132DD1:00001C14:649ABA32:verificationjob:sur\\x2dsite\\x3av\\x2dfeca4620\\x2d6ba7:root@pam:","next-run":1687948200,"ns":"","outdated-after":30,"schedule":"06:30","store":"sur-site"},{"id":"v-91292f7d-c68a","ignore-verified":true,"last-run-endtime":1687865400,"last-run-state":"OK","last-run-upid":"UPID:backup-pbs-qc:00101FA3:13132DD1:00001C1C:649AC838:verificationjob:hors\\x2dsite\\x3av\\x2d91292f7d\\x2dc68a:root@pam:","next-run":1687951800,"ns":"","outdated-after":30,"schedule":"7:30","store":"hors-site"}],"digest":"cffeedd294865525dcd18d42d3c0f06eccd4bcf2b7913db1221cbcdca024ffa1"}
                      I want to discover all existing verify job and for each of them, extract the last run date (last-run-endtime field) and the last run state (last-run-state field) as items. I will use theses values to configure triggers if last run date is too old or if the last state is not ok.

                      This is what I done so far. This doesn't work and I'm lost. Somebody can help me please?

                      I created an item with the HTTP agent type. It seem to work, I can get the json reply when I hit the test button.

                      Click image for larger version Name:	1-PBS-Item.png Views:	0 Size:	67.2 KB ID:	466667

                      Then I created a discovery rule. I think this is where I'm starting to be lost.

                      Click image for larger version Name:	2-PBS-Disco.png Views:	0 Size:	50.7 KB ID:	466668

                      Click image for larger version Name:	3-PBS-Disco-LLDMacro.png Views:	0 Size:	36.6 KB ID:	466669

                      ​Then an item prototype.

                      Click image for larger version Name:	4-PBS-Disco-ItemPrototype.png Views:	0 Size:	72.3 KB ID:	466670

                      Thanks.​
                      Hi Ohmer!
                      Could you help to monitor my Proxmox Backip Server?
                      I have no idea how to do this setup do access the API e integrate it with Zabbix

                      Comment

                      Working...