Beispiel #1
0
    def __init__(self, label, y_axis, palette_index, plot_type, display_name):
        """Initializes and validates publish label options.

        Arguments:
            label: label used in the publish statement that displayes the plot
            y_axis: the y-axis associated with values for this plot.
                    Must be 0 (left) or 1 (right).
            palette_index: the indexed palette color to use for all plot lines
            plot_type: the visualization style to use
            display_name: an alternate name to show in the legend
        """
        for arg in [label, display_name]:
            util.is_valid(arg)
        util.in_given_enum(palette_index, PaletteColor)
        util.in_given_enum(plot_type, PlotType)
        if y_axis not in [0, 1]:
            msg = "YAxis for chart must be 0 (Left) or 1 (Right); " +\
                    "'{0}' provided."
            raise ValueError(msg.format(y_axis))

        self.opts = {
            'label': label,
            'yAxis': y_axis,
            'paletteIndex': palette_index.value,
            'plotType': plot_type.value,
            'displayName': display_name
        }
    def __init__(self,
                 label,
                 y_axis=None,
                 palette_index=None,
                 plot_type=None,
                 display_name=None,
                 value_prefix=None,
                 value_suffix=None,
                 value_unit=None):
        """Initializes and validates publish label options.

        Arguments:
            label: label used in the publish statement that displayes the plot.
            y_axis: the y-axis associated with values for this plot.
                    Must be 0 (left) or 1 (right).
            palette_index: the indexed palette color to use for all plot lines
            plot_type: the visualization style to use
            display_name: an alternate name to show in the legend
            value_prefix: Indicates a string to prepend to the values displayed
                          when you are viewing a single value or list chart,
                          the data table for a chart, and the tooltip when
                          hovering over a point on a chart.
            value_suffix: Indicates a string to append to the values displayed
                          when you are viewing a single value or list chart,
                          the data table for a chart, and the tooltip when
                          hovering over a point on a chart.
            value_unit: Indicates display units for the values in the chart.
                        The plot values will be presented in a readable way
                        based on the assumption that the raw values are
                        denominated in the selected unit.
        """

        util.assert_valid(label)
        self.opts = {'label': label}

        if y_axis and y_axis not in [0, 1]:
            msg = "YAxis for chart must be 0 (Left) or 1 (Right); " +\
                    "'{0}' provided."
            raise ValueError(msg.format(y_axis))
        else:
            self.opts.update({'yAxis': y_axis})

        # A little ditty to translate optional simple parameters into a map
        # of camelCased keys to values
        for elem in [
                'display_name', 'value_prefix', 'value_suffix', 'value_unit'
        ]:
            for key, value in locals().items():
                if key is elem and value:
                    self.opts.update({util.snake_to_camel(key): value})

        if palette_index:
            util.in_given_enum(palette_index, PaletteColor)
            self.opts.update({'paletteIndex': palette_index.value})

        if plot_type:
            util.in_given_enum(plot_type, PlotType)
            self.opts.update({'plotType': plot_type.value})
Beispiel #3
0
    def with_type(self, time_type):
        """The type of time span defined.

        Arguments:
            time_type: String either 'relative' or 'absolute'
        """
        util.in_given_enum(time_type, Time)
        self.options.update({'type': time_type.value})
        return self
Beispiel #4
0
    def with_severity(self, severity):
        """Severity of the rule.
            SignalFx supports five severity levels: Critical, Warning, Major, Minor, and Info.

            Arguments:
                severity: String
        """
        util.in_given_enum(severity, Severity)
        self.options.update({'severity': severity.value})
        return self
Beispiel #5
0
    def with_unit_prefix(self, prefix):
        """Add a unit prefix to this chart.

        Arguments:
            prefix: String defining unit prefix (metric, binary)
        """
        util.assert_valid(prefix)
        util.in_given_enum(prefix, UnitPrefix)
        self.chart_options.update({'unitPrefix': prefix.value})
        return self
Beispiel #6
0
    def with_default_plot_type(self, plot_type):
        """The default plot display style for the visualization.

            Arguments:
                plot_type: Enumerated string to define default plot type in TimeSeriesChart
        """
        util.assert_valid(plot_type)
        util.in_given_enum(plot_type, PlotType)
        self.chart_options.update({'defaultPlotType': plot_type.value})
        return self
Beispiel #7
0
    def with_sort_by(self, sort_by):
        """Determine how values are sorted.

        Arguments:
            sort_by: String that defines how we sort values (-value, +value)
        """
        util.assert_valid(sort_by)
        util.in_given_enum(sort_by, SortBy)
        self.chart_options.update({'sortBy': sort_by.value})
        return self
Beispiel #8
0
    def with_color_by(self, color_by):
        """Determine how timeseries are colored in this chart.

        Arguments:
            color_by: String that defines how to color a chart (dimension, metric, scale)
        """
        util.assert_valid(color_by)
        util.in_given_enum(color_by, ColorBy)
        self.chart_options.update({'colorBy': color_by.value})
        return self
Beispiel #9
0
 def with_default_plot_type(self, plot_type):
     """The default plot display style for the visualization."""
     util.is_valid(plot_type)
     util.in_given_enum(plot_type, PlotType)
     self.chart_options.update({'defaultPlotType': plot_type.value})
     return self
Beispiel #10
0
 def with_unit_prefix(self, prefix):
     """Add a unit prefix to this chart."""
     util.is_valid(prefix)
     util.in_given_enum(prefix, UnitPrefix)
     self.chart_options.update({'unitPrefix': prefix.value})
     return self
Beispiel #11
0
 def with_sort_by(self, sort_by):
     """Determine how values are sorted."""
     util.is_valid(sort_by)
     util.in_given_enum(sort_by, SortBy)
     self.chart_options.update({'sortBy': sort_by.value})
     return self
Beispiel #12
0
 def with_color_by(self, color_by):
     """Determine how timeseries are colored in this chart."""
     util.is_valid(color_by)
     util.in_given_enum(color_by, ColorBy)
     self.chart_options.update({'colorBy': color_by.value})
     return self
Beispiel #13
0
    def __init__(self,
                 label,
                 y_axis=None,
                 palette_index=None,
                 plot_type=None,
                 display_name=None,
                 value_prefix=None,
                 value_suffix=None,
                 value_unit=None):
        """Initializes and validates publish label options.

        These options are applied at the individual plot level (vs. the chart level).

        Also see method 'with_publish_label_options()'

        Arguments:
            label: label used in the publish statement that displays the plot.
                    If you defined your plot with the 'Plot' class this should be
                    the same as the 'label' in that class.  Otherwise it should be
                    the same label used in 'Function.publish(label)'
            y_axis: the y-axis associated with values for this plot.
                    Must be 0 (left) or 1 (right).
            palette_index: the indexed palette color to use for all plot lines,
                    e.g. PaletteColor.green
            plot_type: the visualization style to use, e.g. PlotType.area_chart.
                    This value overrides the value defined in the 'TimeSeriesChart'
                    for a single plot.
                    Also see 'TimeSeriesChart.with_default_plot_type()'.
            display_name: an alternate name to show in the legend
            value_prefix: Indicates a string to prepend to the values displayed
                          when you are viewing a single value or list chart,
                          the data table for a chart, and the tooltip when
                          hovering over a point on a chart.
            value_suffix: Indicates a string to append to the values displayed
                          when you are viewing a single value or list chart,
                          the data table for a chart, and the tooltip when
                          hovering over a point on a chart.
            value_unit: Indicates display units for the values in the chart.
                        The plot values will be presented in a readable way
                        based on the assumption that the raw values are
                        denominated in the selected unit. E.g. 60,000 milliseconds
                        will be displayed 1 minute in the chart. Example values
                        include 'Millisecond', 'Nanosecond', 'Byte', 'Kibibyte',
                        'Bit', 'Kilobit', 'Megabit', etc. (as seen in the SignalFx UI)
        """

        util.assert_valid(label)
        self.opts = {'label': label}

        if y_axis and y_axis not in [0, 1]:
            msg = "YAxis for chart must be 0 (Left) or 1 (Right); " +\
                    "'{0}' provided."
            raise ValueError(msg.format(y_axis))
        else:
            self.opts.update({'yAxis': y_axis})

        # A little ditty to translate optional simple parameters into a map
        # of camelCased keys to values
        for elem in [
                'display_name', 'value_prefix', 'value_suffix', 'value_unit'
        ]:
            for key, value in locals().items():
                if key is elem and value:
                    self.opts.update({util.snake_to_camel(key): value})

        if palette_index:
            util.in_given_enum(palette_index, PaletteColor)
            self.opts.update({'paletteIndex': palette_index.value})

        if plot_type:
            util.in_given_enum(plot_type, PlotType)
            self.opts.update({'plotType': plot_type.value})
Beispiel #14
0
 def with_type(self, time_type):
     """The type of time span defined."""
     util.in_given_enum(time_type, Time)
     self.options.update({'type': time_type.value})
     return self
Beispiel #15
0
 def with_severity(self, severity):
     """Severity of the rule."""
     util.in_given_enum(severity, Severity)
     self.options.update({'severity': severity.value})
     return self