Creating a slack notification channel

Notification channels are a way to send alerts to the notification system of your choice. You can attach one or more notification channel to an alert. You can also use the same notification channel for all the alerts.

Follow the steps to create a slack notification channel. Once configured a message will be sent to your slack channel with a link to the summary alert details.

#create a monitored entity
monitored = monitoring.get_or_create_monitored_entity("My Model")
# create summary
yesterday = time_window_start=today - timedelta(hours=30)
today = time_window_end=today - timedelta(hours=30)
mse_summary = monitoring.summaries.get_or_create("mse", NumericValue, monitored)
mse_summary.log_sample(NumericValue(0.3), {"source":"reference"}, yesterday, today)
# create fixed alert with slack notification channel
from verta.monitoring.comparison import GreaterThan
from verta.monitoring.alert import FixedAlerter
from verta.monitoring.notification_channel import SlackNotificationChannel
#webhook_url is configured when setting up your slack incoming webhook
channel = client.monitoring.notification_channels.get_or_create(
"Slack Demo Alerts",
SlackNotificationChannel(webhook_url),
)
from verta.monitoring.comparison import GreaterThan
from verta.monitoring.alert import FixedAlerter
alerter = FixedAlerter(GreaterThan(.7))
alert = mse_summary.alerts.create(
name="mse",
starting_from=today-timedelta(hours=90),
notification_channels=[channel],
alerter=alerter,
)

In order to configure a slack ntofication you need to setup a slack incoming webhook.