Skip to content

Expression🔗

Definition🔗

class Expression:
    # The type of query if this is a query expression
    query_type: typing.Optional[str]
    relative_time_range: typing.Optional[alertingv0alpha1.RelativeTimeRange]
    # The UID of the datasource to run this expression against. If omitted, the expression will be run against the `__expr__` datasource
    datasource_uid: typing.Optional[alertingv0alpha1.DatasourceUID]
    model: object
    # Used to mark the expression to be used as the final source for the rule evaluation
    # Only one expression in a rule can be marked as the source
    # For AlertRules, this is the expression that will be evaluated against the alerting condition
    # For RecordingRules, this is the expression that will be recorded
    source: typing.Optional[bool]

Methods🔗

to_json🔗

Converts this object into a representation that can easily be encoded to JSON.

def to_json() -> dict[str, object]

from_json🔗

Builds this object from a JSON-decoded dict.

@classmethod
def from_json(data: dict[str, typing.Any]) -> typing.Self

See also🔗