signal_analog package¶
Submodules¶
signal_analog.charts module¶
signal_analog.cli module¶
-
signal_analog.cli.
invoke
(resource, action, api_key, **kwargs)[source]¶ Attempt to invoke the provided action on each resource.
Parameters: - resource – Object defining a Sfx resource (chart, dashboard, dashboard group, etc)
- action – String to create, update, read, or delete a resource
- api_key – String
Returns: The response from the action taken.
signal_analog.combinators module¶
Provides n-ary combinators for SignalFlow programs.
-
class
signal_analog.combinators.
NAryCombinator
(operator, *ns)[source]¶ Bases:
object
N-ary combinator for SignalFlow objects.
Parameters: - operator – the operator to intersperse amongst expressions.
- ns – the expressions to compose.
Returns: An object that can be serialized to SignalFlow.
-
class
signal_analog.combinators.
And
(*ns)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
And combinator for combining SignalFlow objects.
-
class
signal_analog.combinators.
Or
(*ns)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
Or combinator for combining SignalFlow objects.
-
class
signal_analog.combinators.
Not
(expr)[source]¶ Bases:
object
Not combinator for performing nullification on SignalFlow objects.
Negate the given expression.
Parameters: expr – the expression to negate. Returns: An object that can be serialized to SignalFlow.
-
class
signal_analog.combinators.
LT
(left, right)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
Less Than combinator for comparing SignalFlow objects.
-
class
signal_analog.combinators.
GT
(left, right)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
Greater Than combinator for comparing SignalFlow objects.
-
class
signal_analog.combinators.
EQ
(left, right)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
Equal combinator for comparing SignalFlow objects.
-
class
signal_analog.combinators.
NE
(left, right)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
Not Equal combinator for comparing SignalFlow objects.
-
class
signal_analog.combinators.
Mul
(left, right)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
Multiplication combinator for performing math on SignalFlow objects.
-
class
signal_analog.combinators.
Div
(left, right)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
Division combinator for performing math on SignalFlow objects.
-
class
signal_analog.combinators.
Add
(left, right)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
Addition combinator for performing math on SignalFlow objects.
-
class
signal_analog.combinators.
Sub
(left, right)[source]¶ Bases:
signal_analog.combinators.NAryCombinator
Subtraction combinator for performing math on SignalFlow objects.
signal_analog.dashboards module¶
signal_analog.detectors module¶
signal_analog.errors module¶
-
exception
signal_analog.errors.
SignalAnalogError
[source]¶ Bases:
exceptions.Exception
Base exception for any invalid states in the Signal Analog library.
-
exception
signal_analog.errors.
ResourceMatchNotFoundError
(resource_name)[source]¶ Bases:
signal_analog.errors.SignalAnalogError
Resource not found error.
-
exception
signal_analog.errors.
ResourceAlreadyExistsError
(name)[source]¶ Bases:
signal_analog.errors.SignalAnalogError
Resource already exists error.
-
exception
signal_analog.errors.
ResourceHasMultipleExactMatchesError
(dashboard_name)[source]¶ Bases:
signal_analog.errors.SignalAnalogError
Resource has multiple matches error.
-
exception
signal_analog.errors.
ProgramValidationError
[source]¶ Bases:
signal_analog.errors.SignalAnalogError
Base exception for an invalid program in the Signal Analog library.
signal_analog.eventoverlays module¶
Event objects representable in the SignalFX API.
-
class
signal_analog.eventoverlays.
EventSignals
[source]¶ Bases:
object
A set of variables for defining event signals
-
class
signal_analog.eventoverlays.
EventOverlays
[source]¶ Bases:
object
Options for displaying event overlays chosen from drop down and determining which color they will use, and if they will show an event line.
-
with_event_signals
(eventsignals)[source]¶ The search term used to find events of the specified type to be overlaid on the charts in this dashboard.
Parameters: eventsignals – Object defining the event signal related to this overlay
-
signal_analog.filters module¶
-
class
signal_analog.filters.
FilterVariable
[source]¶ Bases:
object
A set of predefined filters that are available by default at the top of the dashboard. The properties of the included objects are indicated as filters.variables[x].propertyName. This notation means the propertyName property is part of the object in each element of the variables array.
-
with_apply_if_exists
(apply_if_exists)[source]¶ Apply the filter if it exists.
True enables the UI option “Allow data matching the filter condition or missing <dimension-name>”.
See https://docs.signalfx.com/en/latest/dashboards/dashboard-filter-dynamic.html#how-allow-data
- Arguments:
- apply_if_exists: Boolean
-
with_description
(description)[source]¶ Sets a description for the filter.
Parameters: description – String
-
with_preferred_suggestions
(*preferred_suggestions)[source]¶ Sets preferred suggestions in the filter drop down.
Parameters: *preferred_suggestions – List of Strings
-
-
class
signal_analog.filters.
FilterSource
[source]¶ Bases:
object
Each element represents an adhoc filter to apply to the charts within the dashboard. Each filter can key off of one dimension or custom property (either user defined or supplied by default) and can either include or exclude all data matching the supplied criteria. The properties of the included objects are indicated as filters.sources[x].propertyName; this notation means the propertyName property is part of the object in each element of the sources array.
-
class
signal_analog.filters.
FilterTime
[source]¶ Bases:
object
The properties of the included objects are indicated as filters.time.propertyName.
-
class
signal_analog.filters.
DashboardFilters
[source]¶ Bases:
object
A filters model to be attached to a dashboard. Filters allow fine grained control over the data displayed in the charts within the dashboard. They can be adhoc or saved as variables to allow easy reuse of filter criteria. Filters can also be used to apply a custom time window to all of the charts in the dashboard. The properties of the included object are indicated as filters.propertyName.
Example:
>>> Dashboard().with_filter(DashboardFilters().with_variables( >>> FilterVariable().with_property("aws_account_id").with_alias("aws_account_id").with_value(aws_account_id) >>> ).with_time(FilterTime().with_start("-7d").with_end("Now")) >>> )
Initialize filters object
-
with_variables
(*variables)[source]¶ Set dashboard level filter variables.
Parameters: *variables – List of variables (such as ‘alias’ and ‘property’)
-
signal_analog.flow module¶
This module provides bindings for the SignalFx SignalFlow DSL.
-
class
signal_analog.flow.
Program
(*statements)[source]¶ Bases:
object
Encapsulation of a SignalFlow program.
Initialize a new program, optionally with statements.
Example:
>>> Program( >>> Plot( >>> assigned_name="A", >>> signal_name="ConsumedReadCapacityUnits", >>> filter=And( >>> Filter("TableName", table_name), >>> Filter("stat", "sum") >>> ), >>> rollup=RollupType.sum, >>> fx=[Sum(by=["TableName", "aws_account_id"])], >>> label="ConsumedReadCapacity" >>> ), >>> Plot( >>> assigned_name="B", >>> signal_name="ConsumedWriteCapacityUnits", >>> filter=And( >>> Filter("TableName", table_name), >>> Filter("stat", "sum") >>> ), >>> rollup=RollupType.sum, >>> fx=[Sum(by=["TableName", "aws_account_id"])], >>> label="ConsumedWriteCapacity" >>> ) >>> )
Raises: ValueError
– when any provided statement is found to not be a valid statement. See __valid_statement__ for more detail.-
validate
(*validations)[source]¶ Validate this Program.
If no validations are provided this Program will validate against all validation functions from self.DEFAULT_VALIDATIONS.
A validation function is one that inspects the given Programs statements and returns nothing if verified, an appropriate Exception otherwise.
Parameters: validations – if provided, override the default validations for this program. Returns: An appropriate Exception if invalid, None otherwise.
-
add_statements
(*statements)[source]¶ Add a statement to this program.
Parameters: statement – the statement to add Raises: ValueError
– when any provided statement is found to not be a valid statement. See __valid_statement__ for more detail.Returns: None
-
-
class
signal_analog.flow.
Plot
(assigned_name, signal_name, filter=None, rollup=None, fx=None, label=None, visible=True, extrapolation_policy=None, max_extrapolations=None)[source]¶ Bases:
object
Represents a Plot for a Chart as configured in the SignalFx UI. It is a helper class that makes it simpler to use lower-level abstractions like Assign, Function, Data, publish()
Represents a Plot for a Chart as configured in the SignalFx UI. It is a helper class that makes it simpler to use lower-level abstractions like Assign, Function, Data, publish()
Other options available in the UI for a plot include: display_units, plot_color, and visualization_type. These values can be configured in with_publish_label_options() in the Chart itself. See PublishLabelOptions.
Example:
>>> TimeSeriesChart().with_name("Cpu Utilization").with_program( >>> Program( >>> Plot("A", "CPUUtilization", filter, rollup=RollupType.max, fx=[Mean(by="app")]) >>> ) >>> )
Parameters: - assigned_name – the assigned name used in the SignalFlow program, use A-Z to keep compatibility with the builder in the SignalFx UI. E.g. the “A” in “A = data(‘metric_name’)”
- signal_name – the metric name, e.g. “CPUUtilization”
- filter – the filter to apply to the metric, e.g. And(Filter(“env, “prod”), Filter(“app”, “foo”)) Also, consider filters at the Dashboard level, see ‘DashboardFilters’ class.
- rollup – RollupType If None then the default rollup for the metric is used. Otherwise use the RollupType enum. E.g. RollupType.average, RollupType.rate, RollupType.delta, RollupType.max
- fx – List of Signal Flow function(s) to apply e.g. [ Mean(by=”app”) ]
- label – the name visible in the chart on hover. This is also the label used in PublishLabelOptions
- visible – True if this plot should be visible in the chart. False is used for values that used in a formula but that aren’t displayed themselves. Defaults to True.
- extrapolation_policy –
String How to extrapolate missing data. One of the following string values:
null: Missing data is not emitted. (default)
zero: Missing data is considered to be a value of 0
last_value: Missing data is considered to have the last value
- max_extrapolations – Int How many extrapolations will be performed when data is no longer received from a source. A negative value indicates infinite extrapolation.
-
class
signal_analog.flow.
Function
(name)[source]¶ Bases:
object
Base SignalFlow stream function class.
Parameters: name – String defines name of Function -
bottom
(count=None, percentage=None, by=None)[source]¶ Get the bottom values in the stream.
Parameters: - count – count of bottom inputs to pass thru. Mutually exclusive with percentage parameter
- percentage – percent of bottom inputs to pass thru expressed as a double between 0 and 1.0
- by – either string or list of strings of the names of properties to group by
-
count
(by=None, over=None)[source]¶ Counts the number of inputs that have data.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
delta
()[source]¶ - Calculates the difference between the current value and the
- previous value for each time interval.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
Delta operates independently on each time series.
-
dimensions
(aliases=None, renames=None)[source]¶ - The dimensions method duplicates or renames metadata of time series
in the stream.
The aliases and renames parameters are optional, but at least one must be specified. Any supplied parameter must be a dictionary of strings to strings. The keys of the dictionaries specify the names of the new metadata dimensions. The values of the dictionaries specify the corresponding names of existing metadata dimensions or custom properties from which the new dimensions are derived.
The difference between aliases and renames is that aliases introduce new dimensions while leaving the existing dimensions as is, whereas renames replace existing dimensions.
The return value is a data stream whose time series have altered metadata dimensions
Parameters: - aliases – dictionary of strings of strings
- renames – dictionary of strings of strings
-
mean
(by=None, over=None)[source]¶ Find the mean on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
mean_plus_stddev
(by=None, over=None)[source]¶ Calculates the mean + n standard deviations.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
median
(by=None, over=None)[source]¶ Find the median on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
min
(by=None, over=None)[source]¶ Find the minimum value on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
max
(by=None, over=None)[source]¶ Find the maximum value on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
percentile
(percentage, by=None, over=None)[source]¶ Calculates the n-th percentile of inputs in the stream.
Parameters: - percentage – the percentile to calculate. Double between 0.0(exclusive) and 100.0(inclusive)
- by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
random
(count, by=None, over=None)[source]¶ Get random values in the stream by count or percentage.
Parameters: - count – count of random inputs to pass thru.
- by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
sample_stddev
(by=None, over=None)[source]¶ Calculates the sample standard deviation of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
sample_variance
(by=None, over=None)[source]¶ Calculates the sample variance of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
size
(by=None, over=None)[source]¶ Counts the number of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
stddev
(by=None, over=None)[source]¶ Calculates the standard deviation of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
sum
(by=None, over=None)[source]¶ Find the sum on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
top
(count=None, percentage=None, by=None)[source]¶ Get the top values in the stream.
Parameters: - count – Int count of top inputs to pass thru. Mutually exclusive with percentage parameter
- percentage – Double percent of top inputs to pass thru expressed as a double between 0 and 1.0
- by – String or List of strings of the names of properties to group by
-
variance
(by=None, over=None)[source]¶ Calculates the variance of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
publish
(label=None, enable=None)[source]¶ - Publish the output of a stream so that it is visible outside of a
computation.
This is also the label used in the ‘PublishLabelOptions’ class.
Parameters: - label – String defining a label for the stream
- enable – Boolean True/False means show/hide the Time Series in the chart.
-
timeshift
(offset)[source]¶ - Timeshift the datapoints for a stream, offset by a specified time
- period e.g. 1 week (1w), to enable comparison of time series with its own past behavior.
Parameters: offset – String defining time offset
-
ewma
(alpha=None, over=None)[source]¶ Calculates the exponentially weighted moving average of the stream.
Parameters: alpha – Int (must be between 0 and 1) used to calculate the EWMA of each input time series.
-
above
(limit, inclusive=None, clamp=None)[source]¶ - Only pass through data in the stream that is above a particular
- value, or clamp data above a value to that value.
Parameters: - limit – Int
- inclusive – Boolean if True limit is included in the filter
- clamp – Boolean if True then when data is below limit it is passed on as limit, otherwise data is not passed through
-
below
(limit, inclusive=None, clamp=None)[source]¶ - Only pass through data in the stream that is below a particular
- value, or clamp data below a value to that value.
Parameters: - limit – Int
- inclusive – Boolean if True limit is included in the filter
- clamp – Boolean if True then when data is below limit it is passed on as limit, otherwise data is not passed through
-
between
(low_limit, high_limit, low_inclusive=None, high_inclusive=None, clamp=None)[source]¶ - Only pass through data in the stream that is between two particular
- values or replace data that is not between two particular values with the limit that they are closest to.
Parameters: - low_limit – Int the value of the lower limit
- high_limit – Int the value of the higher limit (must be greater than low_limit)
- low_inclusive – Boolean if True then low_limit is included in the filter
- high_inclusive – Boolean if True then high_limit is included in the filter
- clamp – Boolean if True data that is not between low_limit and high_limit will be replaced with the value of the closest of low_limit or high_limit, otherwise data is not passed through
-
equals
(value, replacement=None)[source]¶ - Only pass through data in the stream that is equal to a particular
- value or replace data that is not equal to a particular value with another value.
Parameters: - value – Int the value to filter for
- replacement – Int if not None, data that is not equal to value will be replaced with this value, otherwise data is not passed through.
-
not_between
(low_limit, high_limit, low_inclusive=None, high_inclusive=None)[source]¶ - Only pass through data in the stream that is not between two
- particular values.
Parameters: - low_limit – Int the value of the lower limit
- high_limit – Int the value of the higher limit (must be greater than low_limit)
- low_inclusive – Boolean if True then low_limit is included in the filter
- high_inclusive – Boolean if True then high_limit is included in the filter
-
not_equals
(value, replacement=None)[source]¶ - Only pass through data in the stream that is not equal to a
- particular value or replace data that is equal to a particular value with another value.
Parameters: - value – Int the value to filter for
- replacement – Int if not None, data that is not equal to value will be replaced with this value, otherwise data is not passed through.
-
promote
(*properties)[source]¶ Promotes a metadata property to a dimension.
Parameters: Property – String a property name, or list of property names, or series of property names that should be used as dimensions.
-
fill
(value=None, duration=None)[source]¶ Fills in missing values for time series in a stream. See https://developers.signalfx.com/signalflow_analytics/methods/fill_stream_method.html
The fill method accepts an optional value parameter to substitute missing values of a time series. If no value parameter is supplied, the last observed value of that time series is used.
The optional duration parameter specifies the maximum continuous length of time that the fill is applied for a specific time series, after which the fill is discontinued. If the duration parameter is not specified, the fill is performed for as long as the time series is included in the stream. Actual reported values in the time series cause the fill duration to be reset.
The return value is a data stream with missing values filled.
-
integrate
()[source]¶ Multiplies the values of each input time series by the resolution (in seconds) of the computation. See https://developers.signalfx.com/signalflow_analytics/methods/integrate_stream_method.html
-
kpss
(over=None, mode='level')[source]¶ Calculates the Kwiatkowski–Phillips–Schmidt–Shin (KPSS) statistic on the specified time window of the stream see https://developers.signalfx.com/signalflow_analytics/methods/kpss_stream_method.html
-
rateofchange
()[source]¶ Calculates the difference between the current value and the previous value for each time interval See https://developers.signalfx.com/signalflow_analytics/methods/rateofchange_stream_method.html
-
-
class
signal_analog.flow.
RollupType
[source]¶ Bases:
enum.Enum
The Roll-up Type for SignalFlow
See [SignalFx Documentation on Roll-ups](https://docs.signalfx.com/en/latest/charts/resolution-rollups.html)
-
average
= 'average'¶ Default for gauges. Divide the result of Sum by the count of datapoints for the time interval.
-
count
= 'count'¶ The number of datapoints observed in the time interval.
-
delta
= 'delta'¶ Return the difference between the first and last value observed in the time interval. This difference is never negative. If the value of a cumulative counter datapoint is ever smaller than the previous value, the delta for that interval will be just the new value, not the negative difference between them.
-
latest
= 'latest'¶ Return the value of the last datapoint received in the time interval.
-
max
= 'max'¶ Select the maximum value seen in the time interval.
-
min
= 'min'¶ The minimum value seen in the time interval.
-
rate
= 'rate'¶ Default for counters. Divide the result of Sum (counter) or Delta (cumulative counter) by the number of seconds in the time interval.
-
sum
= 'sum'¶ Compute the sum of all points for the time interval.
-
lag
= 'lag'¶ Return the average time in milliseconds between each datapoint’s timestamp and the time of its receipt at SignalFx.
-
-
class
signal_analog.flow.
StreamMethod
(name)[source]¶ Bases:
object
Base SignalFlow stream method class.
Parameters: name – String
-
class
signal_analog.flow.
KWArg
(keyword, arg)[source]¶ Bases:
object
Base SignalFlow KWArg method class.
-
class
signal_analog.flow.
VarStrArg
(args)[source]¶ Bases:
object
Base SignalFlow VarStrArg method class.
-
class
signal_analog.flow.
Data
(metric, filter=None, rollup=None, extrapolation=None, maxExtrapolations=None)[source]¶ Bases:
signal_analog.flow.Function
The data() function is used to create a stream.
Assigning data is required to keep your Signal Flow program compatible with the SignalFx UI builder, e.g. Assign(‘A’, Data(‘mymetric’, filter).publish(label)).
An alternative to using the Data class directly is to use the Plot class for an higher-level API that provides options more like the UI in SignalFx.
Parameters: - metric – String metric name (can use * as a wildcard)
- filter – String filter name to match
- rollup – RollupType If None then the default rollup for the metric is used. Otherwise use the RollupType enum. E.g. RollupType.average, RollupType.rate, RollupType.delta, RollupType.max
- extrapolation –
String How to extrapolate missing data. One of the following string values:
null: Missing data is not emitted. (default)
zero: Missing data is considered to be a value of 0
last_value: Missing data is considered to have the last value
- maxExtrapolations – Int How many extrapolations will be performed when data is no longer received from a source. A negative value indicates infinite extrapolation.
-
class
signal_analog.flow.
Filter
(parameter_name, query, *args)[source]¶ Bases:
signal_analog.flow.Function
Creates a _filter_ object.
E.g. And(Filter(‘app’, app), Filter(‘env’, env))
This is a filter at the individual plot level within a ‘Chart’.
Also see the ‘DashboardFilters’ class.
Parameters: - parameter_name – String filter with on this variable
- query – String Value to match for the property_name. Supports non-starting wildcard queries via the ‘*’
- character. –
- *args – String additional values to query for. Resultant filter will be a logically or. Supports and, or, and not binary operations.
-
class
signal_analog.flow.
Const
(value, key, timeseries)[source]¶ Bases:
signal_analog.flow.Function
- The const() function is used to create a stream of constant-value
- timeseries.
Parameters: - value – Int the numeric value to use when generating a single timeseries
- key – String timeseries dimensions to use when generating a single timeseries
- timeseries – List of timeseries specifications describing the timeseries to generate and their values
-
class
signal_analog.flow.
Graphite
(metric, rollup=None, extrapolation=None, maxExtrapolations=None, **kwargs)[source]¶ Bases:
signal_analog.flow.Function
- The graphite() function is used to create a stream interpreting the
- metric query as a series of period separated dimensions.
Parameters: - metric – String metric name (can use * as a wildcard)
- filter – String filter name to match
- rollup – RollupType If None then the default rollup for the metric is used. Otherwise use the RollupType enum. E.g. RollupType.average, RollupType.rate, RollupType.delta, RollupType.max
- extrapolation –
String How to extrapolate missing data. One of the following string values:
null: Missing data is not emitted. (default)
zero: Missing data is considered to be a value of 0
last_value: Missing data is considered to have the last value
- maxExtrapolations – Int How many extrapolations will be performed when data is no longer received from a source. A negative value indicates infinite extrapolation.
- **kwargs – Used to map positions to names
-
class
signal_analog.flow.
Newrelic
(metric, filter=None, rollup=None, extrapolation=None, maxExtrapolations=None, **kwargs)[source]¶ Bases:
signal_analog.flow.Function
- The newrelic() function is used to create a stream interpreting the
- metric query as a series of slash separated dimensions.
Parameters: - metric – String metric name (can use * as a wildcard)
- filter – String filter name to match
- rollup – RollupType If None then the default rollup for the metric is used. Otherwise use the RollupType enum. E.g. RollupType.average, RollupType.rate, RollupType.delta, RollupType.max
- extrapolation –
String How to extrapolate missing data. One of the following string values:
null: Missing data is not emitted. (default)
zero: Missing data is considered to be a value of 0
last_value: Missing data is considered to have the last value
- maxExtrapolations – Int How many extrapolations will be performed when data is no longer received from a source. A negative value indicates infinite extrapolation.
- **kwargs – Used to map positions to names
-
class
signal_analog.flow.
Union
[source]¶ Bases:
signal_analog.flow.Function
The union function merges multiple time series streams into a single time series stream.
-
class
signal_analog.flow.
Detect
(on, off=None, mode=None, auto_resolve_after=None)[source]¶ Bases:
signal_analog.flow.Function
Creates an object.
A ‘detect’ object is used to create events when a condition is met and when it clears. These events can be used to notify people of when the conditions within the detect block are met. In order to actually publish the events the must be invoked on a stream.
Parameters: - on – Data when expression that will fire an event with the status “anomalous”.
- off – Data when expression that will fire an event with the status “ok”. If not specified then the ‘off’ is equivalent to not on
- mode –
String mode of the detector
- paired: both on and off conditions are always evaluated simultaneously. The alert is raised if on
- is true and off is false, and the alert is cleared if the off is true and on is false.
- split: the on condition is evaluated only if there is no alert, and the alert is raised when the
- on condition evaluates to true. The off condition is only evaluated when the alert is raised, and the alert is cleared when the off condition evaluates to true.
- auto_resolve_after – After any input data stream stops receiving data points for the specified duration, the detector clears active alerts.
-
class
signal_analog.flow.
Op
(stmt)[source]¶ Bases:
signal_analog.flow.Function
Op combines two streams using mathematical operators and function calls into a SignalFlow Formula to be used in a Chart or Detector. A Formula in SignalFlow requires operations such as *, /, +, - and allows function calls such as .sum(), .publish(), etc.
Parameters: stmt – Data describing a SignalFlow statement
-
class
signal_analog.flow.
When
(predicate, lasting=None, at_least=None)[source]¶ Bases:
signal_analog.flow.Function
Creates a object for use in functions.
Parameters: - predicate – Boolean to indicate when this expression should evaluate to True
- lasting – Int duration to indicate how the predicate must be true before the when is considered to have a value of True. If not specified, then this expression will evaluate True as long as the predicate is met.
- at_least – Float value indicating the percentage of lasting that the predicate must be true in order for this expression to evaluate to True.Supports and, or, and not binary operations
-
class
signal_analog.flow.
Lasting
(lasting=None, at_least=None)[source]¶ Bases:
signal_analog.flow.Function
- Convenience wrapper for holding both the lasting and optionally the
- at_least parameter to pass to a function.
Parameters: - lasting – Int duration to indicate how the predicate must be true before the when is considered to have a value of True. If not specified, then this expression will evaluate True as long as the predicate is met.
- at_least – Float value indicating the percentage of lasting that the predicate must be true in order for this expression to evaluate to True.Supports and, or, and not binary operations
-
class
signal_analog.flow.
Assign
(assignee, expr)[source]¶ Bases:
signal_analog.flow.Function
Assign the given expression to the assignee
A-Z are recommended values to keep your Signal Flow program compatible with the SignalFx UI builder.Parameters: - assignee – the name to which to assign the expression, e.g. ‘A’, ‘B’
- expr – the expression to assign
Returns: An object that can be serialized to SignalFlow
-
class
signal_analog.flow.
AggregationTransformationMixin
[source]¶ Bases:
object
Mixin providing pre-condition checks for StreamMethods that perform both aggregations and transformations.
-
class
signal_analog.flow.
Bottom
(count=None, percentage=None, by=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
Get the bottom values in the stream.
Parameters: - count – count of bottom inputs to pass thru. Mutually exclusive with percentage parameter
- percentage – percent of bottom inputs to pass thru expressed as a double between 0 and 1.0
- by – either string or list of strings of the names of properties to group by
-
class
signal_analog.flow.
Count
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Counts the number of inputs that have data.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Delta
[source]¶ Bases:
signal_analog.flow.StreamMethod
- Calculates the difference between the current value and the previous
- value for each time interval.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Mean
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Find the mean on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Mean_plus_stddev
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Calculates the mean + n standard deviations.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Median
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Find the median on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Min
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Find the minimum value on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Max
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Find the maximum value on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Percentile
(percentage, by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Calculates the n-th percentile of inputs in the stream.
Parameters: - percentage – the percentile to calculate. Double between 0.0(exclusive) and 100.0(inclusive)
- by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Random
(count, by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Get random values in the stream by count or percentage.
Parameters: - count – count of random inputs to pass thru. Mutually exclusive with percentage parameter
- by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Sample_stddev
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
Calculates the sample standard deviation of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Sample_variance
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
Calculates the sample variance of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Size
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Counts the number of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Stddev
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Calculates the standard deviation of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Sum
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Find the sum on a stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Top
(count=None, percentage=None, by=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
Get the top values in the stream.
Parameters: - count – count of top inputs to pass thru. Mutually exclusive with percentage parameter
- percentage – percent of top inputs to pass thru expressed as a double between 0 and 1.0
- by – String or List of Strings of names of properties to group by
-
class
signal_analog.flow.
Variance
(by=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
,signal_analog.flow.AggregationTransformationMixin
Calculates the variance of inputs in the stream.
Parameters: - by – String or List of Strings of names of properties to group by
- over – Int as positive duration over which to get the count of inputs that have data
-
class
signal_analog.flow.
Publish
(label=None, enable=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
- Publish the output of a stream so that it is visible outside of a
- computation.
Parameters: - label – String label for published stream
- enable – Boolean
-
class
signal_analog.flow.
Timeshift
(offset)[source]¶ Bases:
signal_analog.flow.StreamMethod
- Timeshift the datapoints for a stream, offset by a specified time
- period e.g. 1 week (1w), to enable comparison of time series with its own past behavior.
Parameters: offset – String
-
class
signal_analog.flow.
Ewma
(alpha=None, over=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
- Calculates the exponentially weighted moving average of the stream.
- ewma(alpha)Returns a new object.
Parameters: alpha – Int smoothing parameter (must be between 0 and 1) used to calculate the EWMA of each input time series.
-
class
signal_analog.flow.
Abs
[source]¶ Bases:
signal_analog.flow.StreamMethod
Apply absolute value to data in the stream.abs()Returns reference to the input object.
-
class
signal_analog.flow.
Ceil
[source]¶ Bases:
signal_analog.flow.StreamMethod
Apply the ceil() function to data in the stream.
-
class
signal_analog.flow.
Floor
[source]¶ Bases:
signal_analog.flow.StreamMethod
Apply floor() to data in the stream.
-
class
signal_analog.flow.
Log
[source]¶ Bases:
signal_analog.flow.StreamMethod
Apply the natural log function to data in the stream.
-
class
signal_analog.flow.
Log10
[source]¶ Bases:
signal_analog.flow.StreamMethod
Apply the logarithm(base 10) function to data in the stream.
-
class
signal_analog.flow.
Pow
(base=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
- return base
Parameters: base – Int the power/exponent to raise the data too
-
class
signal_analog.flow.
Scale
(multiplier)[source]¶ Bases:
signal_analog.flow.StreamMethod
Scale data in the stream by a multiplier.
Parameters: multiplier – Int
-
class
signal_analog.flow.
Sqrt
[source]¶ Bases:
signal_analog.flow.StreamMethod
Apply a square root to data in the stream.
-
class
signal_analog.flow.
Above
(limit, inclusive=None, clamp=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
- Only pass through data in the stream that is above a particular
- value, or clamp data above a value to that value.
Parameters: - limit – Int
- inclusive – Boolean if True then limit is included in the filter
- clamp – Boolean if True then when data is below limit it is passed on as limit, otherwise data is not passed
-
class
signal_analog.flow.
Below
(limit, inclusive=None, clamp=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
- Only pass through data in the stream that is below a particular
- value, or clamp data below a value to that value.
Parameters: - limit – Int
- inclusive – Boolean if True then limit is included in the filter
- clamp – Boolean if True then when data is below limit it is passed on as limit, otherwise data is not passed
-
class
signal_analog.flow.
Between
(low_limit, high_limit, low_inclusive=None, high_inclusive=None, clamp=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
- Only pass through data in the stream that is between two particular
- values or replace data that is not between two particular values with the limit that they are closest to.
Parameters: - low_limit – Int the value of the lower limit
- high_limit – Int the value of the higher limit (must be greater than low_limit)
- low_inclusive – Boolean if True then low_limit is included in the filter
- high_inclusive – Boolean if True then high_limit is included in the filter
- clamp – Boolean if True data that is not between low_limit and high_limit will be replaced with the value of the closest of low_limit or high_limit, otherwise data is not passed through
-
class
signal_analog.flow.
Equals
(value, replacement=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
- Only pass through data in the stream that is equal to a particular
- value or replace data that is not equal to a particular value with another value.
Parameters: - value – Int the value to filter for
- replacement – Int if not None, data that is not equal to value will be replaced with this value, otherwise data is not passed through.
-
class
signal_analog.flow.
Not_between
(low_limit, high_limit, low_inclusive=None, high_inclusive=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
- Only pass through data in the stream that is not between two
- particular values.
Parameters: - low_limit – Int the value of the lower limit
- high_limit – Int the value of the higher limit (must be greater than low_limit)
- low_inclusive – Boolean if True then low_limit is included in the filter
- high_inclusive – Boolean if True then high_limit is included in the filter
- clamp – Boolean if True data that is not between low_limit and high_limit will be replaced with the value of the closest of low_limit or high_limit, otherwise data is not passed through
-
class
signal_analog.flow.
Not_equals
(value, replacement=None)[source]¶ Bases:
signal_analog.flow.StreamMethod
- Only pass through data in the stream that is not equal to a
- particular value or replace data that is equal to a particular value with another value.
Parameters: - value – Int the value to filter for
- replacement – Int if not None, data that is not equal to value will be replaced with this value, otherwise data is not passed through.
-
class
signal_analog.flow.
Promote
(*properties)[source]¶ Bases:
signal_analog.flow.StreamMethod
Promotes a metadata property to a dimension.
-
class
signal_analog.flow.
Fill
(value, duration)[source]¶ Bases:
signal_analog.flow.StreamMethod
Fills in missing values for time series in a stream.
-
class
signal_analog.flow.
Kpss
(over, mode)[source]¶ Bases:
signal_analog.flow.StreamMethod
Fills in missing values for time series in a stream.
-
class
signal_analog.flow.
Ref
(arg)[source]¶ Bases:
signal_analog.flow.Arg
-
class
signal_analog.flow.
Alerts
(detector_id)[source]¶ Bases:
signal_analog.flow.Function
- The Alerts() function is used to create a stream of data generated by a detector
- including notifications that an alert has been triggered or that an alert has been turned off. Once published in a chart, it will link the chart to the detector in the web UI. This code will not validate that the decector_id is valid.
- Usage: prog = Program(Data(‘some.metric’).publish())
- prog.statements.append(Alerts(detector_id).publish())
Parameters: detector_id – String the value assigned to a Detector by SignalFx. Can be obtained in the web UI
signal_analog.resources module¶
signal_analog.util module¶
Methods useful throughout the signal_analog project.
-
signal_analog.util.
check_collection
(coll, type_)[source]¶ Ensure type consistency for the given collection.
Parameters: - coll – List of resources
- type – Type of resource to check against
-
signal_analog.util.
in_given_enum
(value, enum)[source]¶ - Determines if the given value is in the given enum. Raises ValueError
- if it is not.
Parameters: - value – Int
- enum – enum to check if value is in
-
signal_analog.util.
check_markdown
(text, error_message=None)[source]¶ Determines if the given text is a markdown and able to generate HTML
-
signal_analog.util.
assert_valid
(value, error_message=None, expected_type=None)[source]¶ Void method ensuring value is non-empty.
Parameters: - value – the value to check
- expected_type – expected data type of the value. Ex: bool, str
- error_message – an optional error message to provide the user
Returns: Nothing.
-
signal_analog.util.
find_duplicates
(xs)[source]¶ Find duplicates in a list.
Parameters: xs – String to find duplicates of
-
signal_analog.util.
flatten_charts
(opts)[source]¶ Given an options object, return a list of JSON-serialized chart objects.
Parameters: opts – a Resource chart object Returns: A list of charts serialized as JSON objects.