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

Graph Widget Dataset Aggregation Improvements

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 6.4.7, 7.0.0alpha7
    • Frontend (F)
    • None

      I recently had several hosts metrics plotted in the graph widget with a sum aggregation and aggregating the whole dataset. When visualized the graph was very choppy in a 90 day view. I was able to determine the cause to be that not all of the hosts  in the dataset had metrics as far back as 90 days. This becomes a problem in CSvgGraphHelper::getMetricsAggregatedData in this section here:

       

      each ($result as $points) {
          $tick = 0;
      
          usort($points['data'],	
              static function (array $point_a, array $point_b): int {
                  return $point_a['clock'] <=> $point_b['clock'];
              }
          );
      
          foreach ($points['data'] as $point) {
              if ($point['tick'] > ($tick + $approximation_tick_delta)) {
                  $tick = $point['tick'];
              }
              if (array_key_exists('count', $point)) {
                  $metric_points[$tick]['value'][] = $point['count'];
              }
              if (array_key_exists('value', $point)) {
                  $metric_points[$tick]['value'][] = $point['value'];
              }
          }
      } 

      For each itemid, the $tick is initialized to 0. That means the first 'tick' value in the array during the foreach ($points['data'] as $point) { will always end up being set to $tick. This becomes a problem if one itemid has trends data for the full 90 days, and if another itemid only has trends data for less than 90 days. In other words, the final $tick array keys in the final $metric_points array for both items will be offset and cause extremely choppy and difficult to read graphs.

       

      I think the solution is to run similar logic after the $metric_points array is finished by:

      1. Running a ksort($metric_points) to sort the array by the tick (timestamps)
      2. Initialize $tick to 0 again and iterate through $metric_points using the $approximation_tick_delta so that every tick key in the array is spaced apart equivalent to the $approximation_tick_delta.

       

      Let me know if this makes sense or not. 

            zabbix.dev Zabbix Development Team
            GRyan337 Ryan Eberly
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: