def with_program_options(self,
                             min_resolution,
                             max_delay,
                             disable_sampling=False):
        """How should the program underlying the visualization be run.

        Arguments:
            min_resolution: min resolution to use for computing program
            max_delay: How long to wait for late datapoints, in ms.
            disable_sampling: samples a subset of output MTS unless enabled.
                              Improves chart performance for heavier MTS.

        Consult this page for more information on min resolution:
            https://docs.signalfx.com/en/latest/reference/analytics-docs/how-choose-data-resolution.html

        Consult this page for more information on late datapoints:
            https://docs.signalfx.com/en/latest/charts/chart-options-tab.html#max-delay

        Returns:
            This TimeSeriesChart with program options.
        """

        util.assert_valid(min_resolution)
        util.assert_valid(max_delay)
        program_opts = {
            'minimumResolution': min_resolution,
            'maxDelay': max_delay,
            'disableSampling': disable_sampling
        }
        self.chart_options.update({'programOptions': program_opts})
        return self
Exemple #2
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.assert_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
        }
Exemple #3
0
    def with_event_line(self, event_line):
        """Show a line over the charts matching the event.

            Arguments: Boolean
        """
        util.assert_valid(event_line, expected_type=bool)
        self.opts.update({'eventLine': event_line})
        return self
    def with_id(self, ident):
        """The id for this resource.

        Useful for creates/deletes.
        """
        util.assert_valid(ident)
        self.options.update({'id': ident})
        return self
    def with_id(self, id):
        """The unique identifier for this chart.

        Useful when updating/deleting charts.
        """
        util.assert_valid(id)
        self.options.update({'id': id})
        return self
    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})
Exemple #7
0
    def with_group_id(self, ident):
        """The groupId for this resource. Useful for creates/deletes.

        Arguments:
            ident: String
        """
        util.assert_valid(ident)
        self.options.update({'groupId': ident})
        return self
Exemple #8
0
    def with_description(self, description):
        """The description to attach to this resource.

        Arguments:
            description: String
        """
        util.assert_valid(description)
        self.options.update({'description': description})
        return self
Exemple #9
0
    def __set_base_url__(self, base_url):
        """Internal helper for setting valid base_urls.

        Arguments:
            base_url: String
        """
        util.assert_valid(base_url,
                          error_message="Cannot proceed with empty base_url")
        self.base_url = base_url
Exemple #10
0
    def with_is_restricted(self, restricted):
        """Set if filter is restricted.

            Arguments:
                restricted: Boolean
        """
        util.assert_valid(restricted, expected_type=bool)
        self.options.update({'restricted': restricted})
        return self
Exemple #11
0
    def with_apply_if_exists(self, apply_if_exists):
        """Apply the filter if it exists.

            Arguments:
                apply_if_exists: Boolean
        """
        util.assert_valid(apply_if_exists, expected_type=bool)
        self.options.update({'apply_if_exists': apply_if_exists})
        return self
Exemple #12
0
    def with_start(self, start):
        """Set start time of filter.

            Arguments:
                start: Int
        """
        util.assert_valid(start, error_message='"start" cannot be empty')
        self.options.update({'start': start})
        return self
Exemple #13
0
    def with_maximum_precision(self, precision):
        """The maximum precision to for values displayed in the list.

            Arguments:
                precision: Int
        """
        util.assert_valid(precision)
        self.chart_options.update({'maximumPrecision': precision})
        return self
Exemple #14
0
    def with_refresh_interval(self, interval):
        """How often (in milliseconds) to refresh the values of the list.

            Arguments:
                interval: Int
        """
        util.assert_valid(interval)
        self.chart_options.update({'refreshInterval': interval})
        return self
Exemple #15
0
    def with_axis_precision(self, num):
        """Force a specific number of significant digits in the y-axis.

            Arguments:
                num: Int
        """
        util.assert_valid(num)
        self.chart_options.update({'axisPrecision': num})
        return self
Exemple #16
0
    def with_group_by(self, group_by):
        """Determine how values are grouped.

        Arguments:
            group_by: List of strings that defines how we group values. Ex. ['role', 'instance-id']
        """
        util.assert_valid(group_by)
        self.chart_options.update({'groupBy': group_by})
        return self
    def __set_api_token__(self, token):
        """Internal helper for setting valid API tokens."""

        message = """Cannot proceed with an empty API token.
        Either pass one in at Resource instantiation time or provide one
        via the `with_api_token` method."""

        util.assert_valid(token, message)
        self.api_token = token
Exemple #18
0
    def with_alias(self, alias):
        """Adds a filter alias to the FilterVariable.

            Arguments:
                alias: String
        """
        util.assert_valid(alias, error_message='"alias" cannot be empty', expected_type=str)
        self.options.update({'alias': alias})
        return self
    def with_parameterized_subject(self, subject):
        """Custom notification message subject for this rule when an alert is
        triggered.

        See the documentation for `with_parameterized_body` for more detail.
        """
        util.assert_valid(subject)
        self.options.update({'parameterizedSubject': subject})
        return self
Exemple #20
0
    def with_is_not(self, is_not):
        """Set if filter is a Not filter.

            Arguments:
                is_not: Boolean
        """
        util.assert_valid(is_not, expected_type=bool, error_message='"NOT" cannot be empty. It should be a boolean')
        self.options.update({'NOT': is_not})
        return self
Exemple #21
0
    def with_end(self, end):
        """Set end time of filter.

            Arguments:
                end: Int
        """
        util.assert_valid(end, error_message='"end" cannot be empty')
        self.options.update({'end': end})
        return self
Exemple #22
0
    def with_property(self, property):
        """Sets filter property.

            Arguments:
                property: String
        """
        util.assert_valid(property, error_message='"property" cannot be empty', expected_type=str)
        self.options.update({'property': property})
        return self
Exemple #23
0
    def with_replace_only(self, replace_only):
        """Replace existing filter.

            Arguments:
                replace_only: Boolean
        """
        util.assert_valid(replace_only, expected_type=bool)
        self.options.update({'replaceOnly': replace_only})
        return self
Exemple #24
0
    def for_label(self, label):
        """A label matching a `detect` label within the program text.

            Arguments:
                label: String
        """
        util.assert_valid(label)
        self.options.update({'detectLabel': label})
        return self
Exemple #25
0
    def __set_endpoint__(self, endpoint):
        """Internal helper for setting valid endpoints.

        Arguments:
            endpoint: String
        """
        util.assert_valid(
            endpoint, error_message="Cannot proceed with an empty endpoint")
        self.endpoint = endpoint
Exemple #26
0
 def with_chart_legend_options(self, dimension, show_legend=False):
     """Show the on-chart legend using the given dimension."""
     util.assert_valid(dimension)
     opts = {
         'showLegend': show_legend,
         'dimensionInLegend': dimension
     }
     self.chart_options.update({'onChartLegendOptions': opts})
     return self
Exemple #27
0
    def with_name(self, name):
        """The name to give this resource.

        Arguments:
            name: String
        """
        util.assert_valid(name)
        self.options.update({'name': name})
        return self
Exemple #28
0
    def with_max_delay(self, delay):
        """The number of milliseconds to wait for late datapoints before rejecting them.

        Arguments:
            delay: Int
        """
        util.assert_valid(delay)
        self.options.update({'maxDelay': delay})
        return self
Exemple #29
0
    def with_description(self, description):
        """Human-readable description for this rule.

            Arguments:
                description: String
        """
        util.assert_valid(description)
        self.options.update({'description': description})
        return self
    def with_runbook_url(self, url):
        """URL of the page to consult when an alert is triggered.

        This can be used with custom notification messages. It can be
        referenced using the {{runbookUrl}} template var.
        """
        util.assert_valid(url)
        self.options.update({'runbookUrl': url})
        return self