9 Replies Latest reply on Oct 3, 2019 6:02 AM by DiegoVirt

    Python Rest Nsx API Call with invalid values

    DiegoVirt Novice

      Hi,

       

      I'm trying to get the values displayed on Interface throughput statistics dashboard through Monitor tab of the Edge..Specifically for regarding vnic0 and vnic2 (my case) .

      Thereby, as per https://docs.vmware.com/en/VMware-NSX-Data-Center-for-vSphere/6.3/nsx_63_api.pdf  -  

      I have tried:

      - /api/4.0/edges/edge-1/statistics/dashboard/interface  - It returns some values, However, when I compared it with values informed in the dashboard, there are differences. For example: Max value informed in the dashboard is greater then gathered by API.

       

      Also, i tried different combinations like:

       

      - /api/4.0/edges/edge-1/statistics/interfaces/uplink'

       

      -/api/4.0/edges/edge-1/statistics/interfaces/internal'

       

      -api/4.0/edges/edge-1/statistics/interfaces' -Huge array - even filtering with last values (1H) . It does not match. .

       

       

      Wondering if someone know how to get the the values informed\displayed on Interface throughput statistics dashboard  of the edge. ..or even, it exists thourgh API.

       

      thanks in advance!

        • 1. Re: Python Rest Nsx API Call with invalid values
          Nick_Andreev Expert

          Can you provide an example where statistics provided in the dashboard don't match to ones received from API?

          • 2. Re: Python Rest Nsx API Call with invalid values
            DiegoVirt Novice

            for example:

            Using the dashboard for vnic0 - Index 0, we see Max vale =  188,628.30 - represents: around 188 MB .

             

            Through API, using 'vNic__0__in__pkt' as per (GET /api/4.0/edges/{edgeId}/statistics/dashboard/interface) to get all pkt related to last 1H,

            I got max value =

            'vNic__0__in__pkt' =  '9894.958849145773'

             

            Also:

             

            'vNic__0__out__pkt' = '9980.6441621'

            'vNic__0__in__byte' = '9912.4170773'

            'vNic__0__out__byte' = '9873.1224019'

             

             

            Same for vNic 2 .

             

             

            vnic2 (index 2) through Dashborad informing = 172,164.95 - around 172MB.  

            Through API:

             

            'vNic__2__in__pkt' = '7416.6593215600005'

             

            'vNic__2__out__pkt' = '8942.5383788'

             

             

            and so on.

             

             

            any enlightenment about how to get the value informed on the dashboard woul be very appreciated.

             

             

            thanks in advance1

            • 3. Re: Python Rest Nsx API Call with invalid values
              Nick_Andreev Expert

              Why are you comparing megabytes to number of packets? *_pkt is the number of packets or am I wrong?

              • 4. Re: Python Rest Nsx API Call with invalid values
                DiegoVirt Novice

                Thanks for your response..and sorry, I have provided a wrong example. Likewise, I have described below in byte:

                 

                Getting with API = r = https://ip/api/4.0/edges/edge-1/statistics/dashboard/interface

                 

                vNic 1 value =  425,962.93  - tthrough VCenter's Dashboard .

                 

                netnsx['dashboardStatistics']['data']['interfaces']['vNic__0__in__byte']['dashboardStatistic'])['value']

                 

                value = 403718.3086

                 

                netnsx['dashboardStatistics']['data']['interfaces']['vvNic__0__out__byte']['dashboardStatistic'])['value']

                 

                 

                value = 72050.54403

                --------------------------------------------------------------------------------------------

                 

                vNic 2 value = 406,522.87 - tthrough VCenter's Dashboard .

                 

                 

                netnsx['dashboardStatistics']['data']['interfaces']['vNic__2__in__byte']['dashboardStatistic'])['value']

                 

                value = 391431.8537

                 

                netnsx['dashboardStatistics']['data']['interfaces']['vNic__2__out__byte']['dashboardStatistic'])['value']

                 

                value =  66496.4344

                 

                Thanks in advance1

                • 5. Re: Python Rest Nsx API Call with invalid values
                  DiegoVirt Novice

                  If I do the following:

                   

                  vNic 0

                  ((valueIn + valueOut) /1000) - we will get a seemed value informed in Dashboard - ((403718.3086+72050.54403)/1000)-50  - 425,962.93 - 425.76885262999997

                   

                  vNic2 =  ((391431.8537+66496.4344)/1000)-50 - 407.92828810000003

                   

                  However, using another edge as example. We do not need -50 .. only ((valueIn + valueOut) /1000 - works. maybe, due to decimals value.

                   

                  edge-2

                  vNic0 = Dashbrad value = 3,591.13

                  in = 175.0944496

                  out = 3416.038312

                  ((175.0944496+3416.038312)/1000) = 3.5911327616000004

                   

                  vNic2 =  6,625.01

                  in = 6554.967277

                  out = 70.04566977

                  ((6554.967277+70.04566977)/1000) - 6.62501294677

                   

                  Wondering if the "formula" to convert was described in somewhere ? Thanks!

                  • 6. Re: Python Rest Nsx API Call with invalid values
                    Nick_Andreev Expert

                    Couple of questions:

                    1. When you say "Using the dashboard for vnic0 - Index 0, we see Max vale =  188,628.30". How do you find the max value on the dashboard? Just visually?
                    2. Then, as I understand, you search for max values for bytes in and out in the REST API response. How do you define "max" in this case? Are you searching for a max value for in bytes and out bytes for an interface independently of each other? Or a sum of in bytes and out bytes at a particular time interval?
                    • 7. Re: Python Rest Nsx API Call with invalid values
                      DiegoVirt Novice

                      1 - Yes, by pointing the mouse over the highest curve of the graph., it gives me the value.

                       

                      2 - I'm using the default interval which gives me last 1H of DATA like we have on graph (VCenter's dashboard). Likewise, in order to find out the max value of the "array"; I pick up the highest value of the |  ("vNic__0__in__byte" array and  sum with "vNic__0__out_byte"  array ) After, we / by 1000 . . It means, each value; i'm not summing all values of the array, I'm comparing each one and finding the highest value of the array.

                      • 8. Re: Python Rest Nsx API Call with invalid values
                        Nick_Andreev Expert

                        OK, I just wanted to make sure that you're comparing the value from the dashboard with the max of sums, not sum of maxes.

                        Wondering if the "formula" to convert was described in somewhere ? Thanks!

                        There's no formula. You just sum in and out and that's your value. If you get correct figures for edge-2 it means that your calculations are correct. The issue is most likely in the way you find the max value from the dashboard.

                         

                        Maybe the max value you find visually is close, but not the actual max. Or maybe by the time you make a REST call, max value has changed. Is that a possibility?

                        • 9. Re: Python Rest Nsx API Call with invalid values
                          DiegoVirt Novice

                          Yes, I would agree with you once we do not have, at least, I did not find, more information about how it works; because, if we have a value with 2 decimals like 15MB , we can proceed with summing in + out / 1000 .. If we have 3 decimals, it does not work, though.

                           

                          Anyway, thanks for your response, we will keep the values as they were gathered even if we have it approximate instead.

                           

                          thanks man1