Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-22350

Vector Graph Aggregations Broken For Datasets

XMLWordPrintable

    • S24-W38/39, S24-W40/41, S24-W42/43, S24-W46/47
    • 2

      Zabbix Team - 

      The vector graph widget aggregations are broken in 6.2 and probably 6.4 (6.0 is fine). For example, plot 2 metrics in the graph widget. Let's just say the values for both items are always "50". Then change the aggregation from 'none' to 'sum'. If you aggregate by each item it's fine and both items will still show "50" no matter what the aggregation interval. If you stack them, you get "100". However, if you change it to aggregate the dataset instead of each item you lose the second item and any others you add to the dataset and the value will always be "50".

      I was able to track this down in CSvgGraphHelper.php. In version 6.0 there was a switch statement to handle the proper aggregation, but it looks like that code was ripped out and wasn't migrated anywhere else starting in version 6.2. I'm guessing this was missed while adding the new graph widget features in version 6.2. 

       

      I was able to patch this on my system by adding the switch statements back. For example:

                                     $new_metric_points = []; 
                                      switch ($metric['options']['aggregate_function']) {
                                              case AGGREGATE_MIN:
                                                      foreach ($metric_points as $tick => $point)
      
      {                                                         $new_metric_points[$tick]['value'][] = min($point['value']);                                                 }
      
                                                      break;
                                              case AGGREGATE_MAX:
                                                      foreach ($metric_points as $tick => $point)
      
      {                                                         $new_metric_points[$tick]['value'][] = max($point['value']);                                                 }
      
                                                      break;
                                              case AGGREGATE_AVG:
                                                      foreach ($metric_points as $tick => $point)
      
      {                                                         $new_metric_points[$tick]['value'][] = CMathHelper::safeAvg($point['value']);                                                 }
      
                                                      break;
                                              case AGGREGATE_COUNT:
                                                      foreach ($metric_points as $tick => $point)
      
      {                                                         $new_metric_points[$tick]['value'][] = array_sum($point['value']);                                                 }
      
                                                      break;
                                             case AGGREGATE_SUM:
                                                     foreach ($metric_points as $tick => $point)
      
      {                                                        $new_metric_points[$tick]['value'][] = array_sum($point['value']);                                                 }
      
                                                     break;
      

      And then just set $metric_points = $new_metric_points before looping through to build the $metric['points'] array with the approximations for avg, min and max.

      Also, I don't really understand the use of 'first' and 'last', so I did not include those case statements above. 'first' and 'last' don't really seem well-defined. Perhaps that is a topic for a different ticket though.

        1. avg-17.5.png
          34 kB
          Alexander Vladishev
        2. image-2024-11-21-12-07-53-932.png
          99 kB
          Larisa Grigorjeva

            lgrigorjeva Larisa Grigorjeva
            GRyan337 Ryan Eberly
            Team A
            Votes:
            4 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - Not Specified
                Not Specified
                Logged:
                Time Spent - 8h
                8h