Ad Widget

Collapse

Veeam Manager: There are errors in requests to API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jhonhart@lyell.com
    Junior Member
    • Dec 2022
    • 6

    #1

    Veeam Manager: There are errors in requests to API

    Zabbix 6.2.7
    ​​​​​​Veeam Backup Enterprise Manager by HTTP version 0.42


    I have my three Host macros defined and the template

    {$VEEAM.MANAGER.API.URL} https://xxx-Veeam.xxx.net:9398
    ​​​​​​{$VEEAM.MANAGER.USER} (I have tried using both domain\user and just user)
    ​​​​​​{$VEEAM.PASSWORD}

    When I try running the disco it comes back as not supported instead of enabled

    Click image for larger version

Name:	Screenshot 2023-03-13 at 2.43.46 PM.png
Views:	4850
Size:	53.7 KB
ID:	461016
    ​​​​​​
    2023-03-13 14:02:03 Error: cannot get URL: Timeout was reached.
    2023-03-13 13:57:53 Request failed with status code 404: .

    What and where do I look for to allow Zabbix to monitor the Ent Manager?
  • mmorgan
    Junior Member
    • Sep 2017
    • 26

    #2

    I'm having a similar problem. Did you ever find a resolution? If so, what was it? Thanks.

    Comment

    • StevenBrs
      Junior Member
      • Sep 2015
      • 11

      #3

      I had something similar with Veeam B&R monitoring (port 9419)
      I turned out to be a time-out on getting the backupObjects in "Veeam: Get metrics".
      Commented it out and works correctly now, except for the backup objects that is...

      Veeam B&R by HTTP / items / "Veeam: Get metrics" / Script:
      Code:
          getMetricsData: function() {
              var data = {};
              ms = 86400000;
              start_date = new Date((new Date().getTime()) - ms * Veeam.params.created_after).toISOString().replace(/\.\d+/, '');
              endpoints = {
                  'proxies': 'api/v1/backupInfrastructure/proxies',
                  'repositories': 'api/v1/backupInfrastructure/repositories',
                  'managedServers': 'api/v1/backupInfrastructure/managedServers',
                  'repositories_states': 'api/v1/backupInfrastructure/repositories/states',
                  'services': 'api/v1/services',
                  'jobs_states': 'api/v1/jobs/states',
                  'backups': 'api/v1/backups',
      //            'backupObjects': 'api/v1/backupObjects',
                  'sessions': 'api/v1/sessions?createdAfterFilter=' + encodeURIComponent(start_date)
              };
      
              Object.keys(endpoints).forEach(function (key) {
                  data[key] = Veeam.request(Veeam.params.api_endpoint + endpoints[key]);
              });
      
              return data;
          }

      Comment


      • robson.silva
        robson.silva commented
        Editing a comment
        How did you configure the host?
        Are you using Zabbix Proxy?
    • Ragnarok
      Junior Member
      • Jan 2020
      • 2

      #4
      I running zabbbix 6.x and veeam 12 i cannot pass the login...
      I also saw some other posts that indicate removing some endpoints but I think the problem is due to authentication before the endpoints.
      Other posts also talk about licenses, but it wouldn't be my problem in this case.

      Is there any way to send a message to the server log from these template scripts? something similar like console.log to get more debug?

      Comment

      • lmonasterio
        Member
        • May 2021
        • 34

        #5
        Hello! Im having the same problem using Zabbix 6.0 and Veeam Backup Enterprise Manager 12 template. The error is: {"error":"Error: cannot get URL: Timeout was reached."}
        Im using default port 9398 for Veeam Manager API

        Comment

        • aval
          Junior Member
          • Dec 2023
          • 1

          #6
          Hello!

          I have found kind of a soluttion, this is tested on Zabbix 6.4 with Veeam 11.0.1.1261. You have to modify the template item "Veeam: Get Metrics" and change the script getMetricsData to skip the "services" part, and change the default macro of template timeout {$VEEAM.DATA.TIMEOUT} to 60, this did the trick for me

          getMetricsData: function() {
          var data = {};
          ms = 86400000;
          start_date = new Date((new Date().getTime()) - ms * Veeam.params.created_after).toISOString().replace(/\.\d+/, '');
          endpoints = {
          'proxies': 'api/v1/backupInfrastructure/proxies',
          'repositories': 'api/v1/backupInfrastructure/repositories',
          'managedServers': 'api/v1/backupInfrastructure/managedServers',
          'repositories_states': 'api/v1/backupInfrastructure/repositories/states',
          // 'services': 'api/v1/services',
          'jobs_states': 'api/v1/jobs/states',
          'backups': 'api/v1/backups',
          'backupObjects': 'api/v1/backupObjects',
          'sessions': 'api/v1/sessions?createdAfterFilter=' + encodeURIComponent(start_date)
          };

          Object.keys(endpoints).forEach(function (key) {
          data[key] = Veeam.request(Veeam.params.api_endpoint + endpoints[key]);
          });​

          Comment

          • robson.silva
            Junior Member
            • Feb 2024
            • 7

            #7

            I have a problem with VBR. I'm trying to configure it using the zabbix proxy, but I don't know for sure if it's really possible this way, I didn't find any material on the internet using the zabbix proxy server.​

            Comment

            • robson.silva
              Junior Member
              • Feb 2024
              • 7

              #8
              I have a problem with VBR. I'm trying to configure it using the zabbix proxy, but I don't know for sure if it's really possible this way, I didn't find any material on the internet using the zabbix proxy server.​
              Click image for larger version

Name:	image.png
Views:	3040
Size:	40.7 KB
ID:	478385

              Comment

              • IchiNiSanShi81
                Junior Member
                • Jun 2022
                • 2

                #9
                Hi,
                I solved the timeout error adding "api" at the end of API URL macro.
                But then, I get another error about "Preprocessing" config:

                Click image for larger version

Name:	image.png
Views:	2329
Size:	6.3 KB
ID:	488264

                Comment

                • Joe.T
                  Junior Member
                  • Sep 2024
                  • 1

                  #10
                  Hi,
                  Really hoping someone in this forum solved the issue? Cannot get either of the Veeam Backup Templates to work in Zabbix.

                  Using Zabbix 7.0.3 and have tried both of the supplied Veeam Templates, one at a time configuring as documented in each but neither work.

                  I checked the advice above, and everything else I can find online to disable the services line in the script but that line isn't present in my Templates, maybe because they are more recent?

                  Currently back trying the Veeam Backup Enterprise Manager by HTTP - I have filled in the correct paths and values and have tried adding /api, /api/ and leaving it off in API URL:
                  {$VEEAM.MANAGER.API.URL}
                  {$VEEAM.MANAGER.PASSWORD}
                  {$VEEAM.MANAGER.USER}

                  I get:
                  Preprocessing failed for: {"error":"Request failed with status code 404: ."}
                  1. Failed: cannot extract value from json by path "$.backupFiles.Refs": no data matches the specified path

                  I currently have a Portal Administrator account configured in the Veeam Enterprise Manager and can log in fine to it with the account used. I can also return an API page and a Swagger page from Veeam so everything there looks to be fine.

                  Cannot work out why the Templates do not work, anybody got them working? If so, any ideas how to fix?

                  Thanks in advance.

                  Comment

                  • Zaaappe
                    Junior Member
                    • Oct 2024
                    • 4

                    #11
                    Hi,

                    Same error here. Don'w know where else to look.

                    Preprocessing failed for: {"error":"Request failed with status code 404: ."}
                    1. Failed: cannot extract value from json by path "$.backupFiles.Refs": no data matches the specified path


                    ​If I comment line 40 ('backupFiles': 'api/backupFiles',) on the get metric script I'm able to receive data from ​other items on the template, but kinda useless because its a numeric data (e.g.: Failed job: 98) but nothing else.​

                    Comment

                    • OsvaldoP
                      Junior Member
                      • Jun 2023
                      • 17

                      #12
                      Same problem here.
                      One Veeam ist working fine the other geht only Error "Error: cannot get URL: Timeout was reached"
                      Mybe someone will find an solution

                      kr

                      Comment

                      • huuxnghiax
                        Junior Member
                        • Dec 2022
                        • 1

                        #13
                        For anyone still find the solution for this problem until now
                        Preprocessing failed for: {"error":"Request failed with status code 404: ."}
                        1. Failed: cannot extract value from json by path "$.backupFiles.Refs": no data matches the specified path

                        in my case, I'm using Zabbix server 7.0, Veeam Backup EM version 13.0.1.180.
                        It’s that JSON field names are lowercase, while the Zabbix official template assume TitleCase (Refs, Links, Href, Name…).
                        So you need to modify "Get metrics" item and set the script with this value:
                        var Veeam = {
                        params: {},

                        setParams: function (params) {
                        ['api_endpoint', 'user', 'password'].forEach(function (field) {
                        if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
                        throw 'Required param is not set: ' + field + '.';
                        }
                        });

                        Veeam.params = params;

                        if (typeof Veeam.params.api_endpoint === 'string' && !Veeam.params.api_endpoint.endsWith('/')) {
                        Veeam.params.api_endpoint += '/';
                        }
                        },

                        // --- Normalize Veeam JSON keys to what Zabbix template expects (Refs/Links/Href/Name/Type/Rel) ---
                        normalize: function (obj) {
                        if (obj === null || typeof obj !== 'object') {
                        return obj;
                        }

                        // Collection-level: refs/links
                        if (obj.refs && !obj.Refs) obj.Refs = obj.refs;
                        if (obj.links && !obj.Links) obj.Links = obj.links;

                        // Entity-level: href/name/type/rel
                        if (obj.href && !obj.Href) obj.Href = obj.href;
                        if (obj.name && !obj.Name) obj.Name = obj.name;
                        if (obj.type && !obj.Type) obj.Type = obj.type;
                        if (obj.rel && !obj.Rel) obj.Rel = obj.rel;

                        // Normalize arrays recursively (Refs, Links, refs, links)
                        ['Refs', 'Links', 'refs', 'links'].forEach(function (k) {
                        if (Array.isArray(obj[k])) {
                        obj[k].forEach(function (x) { Veeam.normalize(x); });
                        }
                        });

                        // Normalize nested objects (shallow recursion)
                        Object.keys(obj).forEach(function (k) {
                        if (obj[k] && typeof obj[k] === 'object') {
                        Veeam.normalize(obj[k]);
                        }
                        });

                        return obj;
                        },

                        request: function (url) {
                        var response, request = new HttpRequest();

                        if (typeof Veeam.params.http_proxy !== 'undefined' && Veeam.params.http_proxy !== '') {
                        request.setProxy(Veeam.params.http_proxy);
                        }

                        request.addHeader('Accept: application/json');
                        request.addHeader('Authorization: Basic ' + btoa(Veeam.params.user + ':' + Veeam.params.password));

                        // IMPORTANT: logon first (Veeam requires session-based auth)
                        // Veeam docs: POST /api/sessionMngr/?v=latest with Basic auth creates session token/cookie. [2](https://www.initmax.cz/wp-content/up...mation-7.0.pdf)[3](https://github.com/issuyah/Veeam-Zabbix-Simple)
                        request.post(Veeam.params.api_endpoint + 'api/sessionMngr/?v=latest');

                        // Then query on the SAME HttpRequest object so cookie is reused automatically.
                        // Zabbix HttpRequest preserves cookies per object. [4](https://sbcode.net/zabbix/zabbix-api-examples/)
                        response = request.get(url);

                        if (request.getStatus() !== 200 || response === null) {
                        throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
                        }

                        try {
                        var parsed = JSON.parse(response);
                        return Veeam.normalize(parsed);
                        }
                        catch (error) {
                        throw 'Failed to parse response received from API.';
                        }
                        },

                        getMetricsData: function () {
                        var data = {};
                        var endpoints = {
                        'backupFiles': 'api/backupFiles'
                        };

                        // reports summary (also contains links/Links)
                        var reports_summary = Veeam.request(Veeam.params.api_endpoint + 'api/reports/summary');
                        if (typeof reports_summary !== 'object' || (reports_summary.hasOwnProperty('Links') === false && reports_summary.hasOwnProperty('links') === false)) {
                        throw 'Failed response parse. Check debug log for more information.';
                        }

                        // Use normalized Links
                        (reports_summary.Links || []).forEach(function (link) {
                        data[link.Name] = Veeam.request(link.Href);
                        });

                        Object.keys(endpoints).forEach(function (key) {
                        data[key] = Veeam.request(Veeam.params.api_endpoint + endpoints[key]);

                        // Normalize guarantees Refs exists if refs exists, but keep safe
                        if (typeof data[key] !== 'object') data[key] = {};
                        if (!Array.isArray(data[key].Refs)) data[key].Refs = [];

                        // Expand each Ref using Href
                        data[key].Refs.forEach(function (ref) {
                        data[ref.Name] = Veeam.request(ref.Href);
                        });
                        });

                        return data;
                        }
                        };

                        try {
                        Veeam.setParams(JSON.parse(value));
                        return JSON.stringify(Veeam.getMetricsData());
                        }
                        catch (error) {
                        error += (String(error).endsWith('.')) ? '' : '.';
                        Zabbix.log(3, '[ VEEAM MANAGER ] ERROR: ' + error);
                        return JSON.stringify({ 'error': error });
                        }​​

                        Comment

                        Working...