monitor_schema.models.monitor#

Schema for configuring a monitor.

Attributes#

Classes#

CronSchedule

Support for scheduling.

FixedCadenceSchedule

Support for scheduling based on a predefined cadence.

ImmediateSchedule

Schedule the monitor to run immediately.

Metadata

Metadata for a top-level objects such as monitors, analyzers, and schema.

NoExtrasBaseModel

No extras base model.

MonitorConfigMetadata

Metadata related to a monitor.

GlobalAction

Actions that are configured at the team/organization level.

SendEmail

Action to send an email.

SlackWebhook

Action to send a Slack webhook.

RawWebhook

Action to send a Slack webhook.

AnomalyFilter

Filter the anomalies based on certain criteria. If the alerts are filtered down to 0, the monitor won't fire.

EveryAnomalyMode

Config mode that indicates the monitor will send out individual messages per anomaly.

DigestModeGrouping

Enable the ability to group digest by various fields.

DigestMode

Config mode that indicates the monitor will send out a digest message.

Monitor

Customer specified monitor configs.

Functions#

anyOf_to_oneOf(→ None)

Turn anyOf in JSON schema to oneOf.

Module Contents#

class monitor_schema.models.monitor.CronSchedule[source]#

Bases: NoExtrasBaseModel

Support for scheduling.

type: Literal['cron']#
cron: str#
exclusionRanges: List[TimeRange] | None#
class monitor_schema.models.monitor.FixedCadenceSchedule[source]#

Bases: NoExtrasBaseModel

Support for scheduling based on a predefined cadence.

type: Literal['fixed']#
cadence: Literal[Cadence, Cadence, Cadence, Cadence]#
exclusionRanges: List[TimeRange] | None#
class monitor_schema.models.monitor.ImmediateSchedule[source]#

Bases: NoExtrasBaseModel

Schedule the monitor to run immediately.

type: Literal['immediate']#
class monitor_schema.models.monitor.Metadata[source]#

Bases: NoExtrasBaseModel

Metadata for a top-level objects such as monitors, analyzers, and schema.

This object is managed by WhyLabs. Any user-provided values will be ignored on WhyLabs side.

version: int#
schemaVersion: int | None#
updatedTimestamp: int#
author: str#
description: str | None#
class monitor_schema.models.monitor.NoExtrasBaseModel[source]#

Bases: pydantic.BaseModel

No extras base model.

Inherit to prevent accidental extra fields.

monitor_schema.models.monitor.COLUMN_NAME_TYPE#
monitor_schema.models.monitor.METRIC_NAME_STR#
monitor_schema.models.monitor.anyOf_to_oneOf(schema: Dict[str, Any], field_name: str) None[source]#

Turn anyOf in JSON schema to oneOf.

onfOf is much stricter and pyDantic doesn’t produce this tag. We hijack the JSON schema object to set this correctly.

See: https://github.com/samuelcolvin/pydantic/issues/656

class monitor_schema.models.monitor.MonitorConfigMetadata[source]#

Bases: monitor_schema.models.commons.NoExtrasBaseModel

Metadata related to a monitor.

revision: int#
update_timestamp: int#
update_author: str#
class monitor_schema.models.monitor.GlobalAction[source]#

Bases: monitor_schema.models.commons.NoExtrasBaseModel

Actions that are configured at the team/organization level.

type: Literal['global']#
target: str#
class monitor_schema.models.monitor.SendEmail[source]#

Bases: monitor_schema.models.commons.NoExtrasBaseModel

Action to send an email.

type: Literal['email']#
target: str#
class monitor_schema.models.monitor.SlackWebhook[source]#

Bases: monitor_schema.models.commons.NoExtrasBaseModel

Action to send a Slack webhook.

type: Literal['slack']#
target: pydantic.HttpUrl#
class monitor_schema.models.monitor.RawWebhook[source]#

Bases: monitor_schema.models.commons.NoExtrasBaseModel

Action to send a Slack webhook.

type: Literal['raw']#
target: pydantic.HttpUrl#
class monitor_schema.models.monitor.AnomalyFilter[source]#

Bases: monitor_schema.models.commons.NoExtrasBaseModel

Filter the anomalies based on certain criteria. If the alerts are filtered down to 0, the monitor won’t fire.

includeColumns: List[monitor_schema.models.utils.COLUMN_NAME_TYPE] | None#
excludeColumns: List[monitor_schema.models.utils.COLUMN_NAME_TYPE] | None#
minWeight: float | None#
maxWeight: float | None#
minRankByWeight: int | None#
maxRankByWeight: int | None#
minTotalWeight: float | None#
maxTotalWeight: float | None#
minAlertCount: int | None#
maxAlertCount: int | None#
includeMetrics: List[monitor_schema.models.utils.METRIC_NAME_STR] | None#
monitor_schema.models.monitor.excludeMetrics: List[monitor_schema.models.utils.METRIC_NAME_STR] | None#
class monitor_schema.models.monitor.EveryAnomalyMode[source]#

Bases: monitor_schema.models.commons.NoExtrasBaseModel

Config mode that indicates the monitor will send out individual messages per anomaly.

type: Literal['EVERY_ANOMALY']#
filter: AnomalyFilter | None#
class monitor_schema.models.monitor.DigestModeGrouping[source]#

Bases: str, enum.Enum

Enable the ability to group digest by various fields.

byField = 'byColumn'#
byDataset = 'byDataset'#
byAnalyzer = 'byAnalyzer'#
byDay = 'byDay'#
byHour = 'byHour'#
class monitor_schema.models.monitor.DigestMode[source]#

Bases: monitor_schema.models.commons.NoExtrasBaseModel

Config mode that indicates the monitor will send out a digest message.

type: Literal['DIGEST']#
filter: AnomalyFilter | None#
creationTimeOffset: str | None#
datasetTimestampOffset: str | None#
groupBy: List[DigestModeGrouping] | None#
class monitor_schema.models.monitor.Monitor[source]#

Bases: monitor_schema.models.commons.NoExtrasBaseModel

Customer specified monitor configs.

metadata: monitor_schema.models.commons.Metadata | None#
id: str#
displayName: str | None#
tags: Optional[List[constr(min_length=3, max_length=256, regex='[0-9a-zA-Z\\-_]')]]#
analyzerIds: List[constr(regex='^[A-Za-z0-9_\\-]+$')]#
schedule: monitor_schema.models.commons.FixedCadenceSchedule | monitor_schema.models.commons.CronSchedule | monitor_schema.models.commons.ImmediateSchedule#
disabled: bool | None#
severity: int | None#
mode: EveryAnomalyMode | DigestMode#
actions: List[GlobalAction | SendEmail | SlackWebhook | RawWebhook]#
class Config[source]#

Updates JSON schema anyOf to oneOf.

static schema_extra(schema: Dict[str, Any], model: pydantic.BaseModel) None[source]#

Update specific fields here (for Union type, specifically).