How to use the grafanalib.core.Evaluator function in grafanalib

To help you get started, we’ve selected a few grafanalib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github weaveworks / grafanalib / grafanalib / core.py View on Github external
def OutsideRange(from_value, to_value):
    return Evaluator(EVAL_OUTSIDE_RANGE, [from_value, to_value])
github weaveworks / grafanalib / grafanalib / core.py View on Github external
def NoValue():
    return Evaluator(EVAL_NO_VALUE, [])
github weaveworks / grafanalib / grafanalib / core.py View on Github external
def GreaterThan(value):
    return Evaluator(EVAL_GT, [value])
github weaveworks / grafanalib / grafanalib / core.py View on Github external
: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,
github weaveworks / grafanalib / grafanalib / core.py View on Github external
def LowerThan(value):
    return Evaluator(EVAL_LT, [value])
github weaveworks / grafanalib / grafanalib / core.py View on Github external
def WithinRange(from_value, to_value):
    return Evaluator(EVAL_WITHIN_RANGE, [from_value, to_value])