Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def OutsideRange(from_value, to_value):
return Evaluator(EVAL_OUTSIDE_RANGE, [from_value, to_value])def NoValue():
return Evaluator(EVAL_NO_VALUE, [])def GreaterThan(value):
return Evaluator(EVAL_GT, [value]):param Target target: Metric the alert condition is based on.
:param Evaluator evaluator: How we decide whether we should alert on the
metric. e.g. ``GreaterThan(5)`` means the metric must be greater than 5
to trigger the condition. See ``GreaterThan``, ``LowerThan``,
``WithinRange``, ``OutsideRange``, ``NoValue``.
:param TimeRange timeRange: How long the condition must be true for before
we alert.
:param operator: One of ``OP_AND`` or ``OP_OR``. How this condition
combines with other conditions.
:param reducerType: RTYPE_*
:param type: CTYPE_*
"""
target = attr.ib(validator=instance_of(Target))
evaluator = attr.ib(validator=instance_of(Evaluator))
timeRange = attr.ib(validator=instance_of(TimeRange))
operator = attr.ib()
reducerType = attr.ib()
type = attr.ib(default=CTYPE_QUERY)
def to_json_data(self):
queryParams = [
self.target.refId, self.timeRange.from_time, self.timeRange.to_time
]
return {
"evaluator": self.evaluator,
"operator": {
"type": self.operator,
},
"query": {
"model": self.target,def LowerThan(value):
return Evaluator(EVAL_LT, [value])def WithinRange(from_value, to_value):
return Evaluator(EVAL_WITHIN_RANGE, [from_value, to_value])