Exemple #1
0
 def plot_cdf(self, graphing_library='matplotlib'):
   """
   plot CDF for important sub-metrics
   """
   graphed = False
   for percentile_csv in self.percentiles_files:
     csv_filename = os.path.basename(percentile_csv)
     # The last element is .csv, don't need that in the name of the chart
     column = self.csv_column_map[percentile_csv.replace(".percentiles.", ".")]
     if not self.check_important_sub_metrics(column):
       continue
     column = naarad.utils.sanitize_string(column)
     graph_title = '.'.join(csv_filename.split('.')[0:-1])
     if self.sub_metric_description and column in self.sub_metric_description.keys():
       graph_title += ' (' + self.sub_metric_description[column] + ')'
     if self.sub_metric_unit and column in self.sub_metric_unit.keys():
       plot_data = [PD(input_csv=percentile_csv, csv_column=1, series_name=graph_title, x_label='Percentiles',
                       y_label=column + ' (' + self.sub_metric_unit[column] + ')', precision=None, graph_height=600, graph_width=1200, graph_type='line')]
     else:
       plot_data = [PD(input_csv=percentile_csv, csv_column=1, series_name=graph_title, x_label='Percentiles', y_label=column, precision=None,
                       graph_height=600, graph_width=1200, graph_type='line')]
     graphed, div_file = Metric.graphing_modules[graphing_library].graph_data_on_the_same_graph(plot_data, self.resource_directory,
                                                                                                self.resource_path, graph_title)
     if graphed:
       self.plot_files.append(div_file)
   return True
Exemple #2
0
 def plot_timeseries(self, graphing_library='matplotlib'):
   """
   plot timeseries for sub-metrics
   """
   if self.groupby:
     plot_data = {}
     # plot time series data for submetrics
     for out_csv in sorted(self.csv_files, reverse=True):
       csv_filename = os.path.basename(out_csv)
       transaction_name = ".".join(csv_filename.split('.')[1:-1])
       if transaction_name in self.anomalies.keys():
         highlight_regions = self.anomalies[transaction_name]
       else:
         highlight_regions = None
       # The last element is .csv, don't need that in the name of the chart
       column = csv_filename.split('.')[-2]
       transaction_name = ' '.join(csv_filename.split('.')[1:-2])
       plot = PD(input_csv=out_csv, csv_column=1, series_name=transaction_name + '.' + column,
                 y_label=column + ' (' + self.sub_metric_description[column] + ')', precision=None, graph_height=500, graph_width=1200, graph_type='line',
                 highlight_regions=highlight_regions)
       if transaction_name in plot_data:
         plot_data[transaction_name].append(plot)
       else:
         plot_data[transaction_name] = [plot]
     for transaction in plot_data:
       graphed, div_file = Metric.graphing_modules[graphing_library].graph_data(plot_data[transaction], self.resource_directory, self.resource_path,
                                                                                self.label + '.' + transaction)
       if graphed:
         self.plot_files.append(div_file)
   else:
     graphed = False
     for out_csv in self.csv_files:
       csv_filename = os.path.basename(out_csv)
       transaction_name = ".".join(csv_filename.split('.')[1:-1])
       if transaction_name in self.anomalies.keys():
         highlight_regions = self.anomalies[transaction_name]
       else:
         highlight_regions = None
       # The last element is .csv, don't need that in the name of the chart
       column = self.csv_column_map[out_csv]
       column = naarad.utils.sanitize_string(column)
       graph_title = '.'.join(csv_filename.split('.')[0:-1])
       if self.sub_metric_description and column in self.sub_metric_description.keys():
         graph_title += ' (' + self.sub_metric_description[column] + ')'
       if self.sub_metric_unit and column in self.sub_metric_unit.keys():
         plot_data = [PD(input_csv=out_csv, csv_column=1, series_name=graph_title, y_label=column + ' (' + self.sub_metric_unit[column] + ')',
                         precision=None, graph_height=600, graph_width=1200, graph_type='line', highlight_regions=highlight_regions)]
       else:
         plot_data = [PD(input_csv=out_csv, csv_column=1, series_name=graph_title, y_label=column, precision=None, graph_height=600, graph_width=1200,
                         graph_type='line', highlight_regions=highlight_regions)]
       graphed, div_file = Metric.graphing_modules[graphing_library].graph_data(plot_data, self.resource_directory, self.resource_path, graph_title)
       if graphed:
         self.plot_files.append(div_file)
   return True
Exemple #3
0
 def plot_timeseries(self, graphing_library='matplotlib'):
     if graphing_library != 'matplotlib':
         return Metric.plot_timeseries(self, graphing_library)
     else:
         logger.info(
             'Using graphing_library {lib} for metric {name}'.format(
                 lib=graphing_library, name=self.label))
         plot_data = {}
         # plot time series data for submetrics
         for out_csv in sorted(self.csv_files, reverse=True):
             csv_filename = os.path.basename(out_csv)
             # The last element is .csv, don't need that in the name of the chart
             column = csv_filename.split('.')[-2]
             transaction_name = ' '.join(csv_filename.split('.')[1:-2])
             plot = PD(input_csv=out_csv,
                       csv_column=1,
                       series_name=transaction_name,
                       y_label=self.sub_metric_description[column] + ' (' +
                       self.sub_metric_units[column] + ')',
                       precision=None,
                       graph_height=500,
                       graph_width=1200,
                       graph_type='line')
             if transaction_name in plot_data:
                 plot_data[transaction_name].append(plot)
             else:
                 plot_data[transaction_name] = [plot]
         for transaction in plot_data:
             graphed, div_file = Metric.graphing_modules[
                 graphing_library].graph_data(
                     plot_data[transaction], self.resource_directory,
                     self.resource_path, self.label + '.' + transaction)
             if graphed:
                 self.plot_files.append(div_file)
         return True
Exemple #4
0
 def plot_diff(self, graphing_library = 'matplotlib'):
   """
   Generate CDF diff plots of the submetrics
   """
   diff_datasource = sorted(set(self.reports[0].datasource) & set(self.reports[1].datasource))
   graphed = False
   for submetric in diff_datasource:
     baseline_csv = naarad.utils.get_default_csv(self.reports[0].local_location, (submetric+'.percentiles'))
     current_csv = naarad.utils.get_default_csv(self.reports[1].local_location, (submetric+'.percentiles'))
     if ((naarad.utils.is_valid_file(baseline_csv) & naarad.utils.is_valid_file(current_csv)) == False):
       continue
     baseline_plot = PD(input_csv=baseline_csv, csv_column=1, series_name=submetric, y_label=submetric, precision=None, graph_height=600, graph_width=1200, graph_type='line', plot_label='baseline', x_label='Percentiles')
     current_plot = PD(input_csv=current_csv, csv_column=1, series_name=submetric, y_label=submetric, precision=None, graph_height=600, graph_width=1200, graph_type='line', plot_label='current', x_label='Percentiles')
     graphed, div_file = Diff.graphing_modules[graphing_library].graph_data_on_the_same_graph([baseline_plot, current_plot], os.path.join(self.output_directory, self.resource_path), self.resource_path, (submetric+'.diff'))
     if graphed:
       self.plot_files.append(div_file)
   return True