notify

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package notify warns when a run fails.

It exists because it was the biggest gap against Kestra: the 51 flows in that repository each carried the SAME copied `errors: alert_slack` block -- twenty lines of payload repeated fifty times. Here the alert is a property of the INSTALLATION: configure the webhook once and every workflow starts warning, with the option to silence one.

The webhook does not come from the workflow's YAML, on purpose. It is a credential: whoever has the URL posts in the channel as if they were the platform, and a pipeline file is no place for that.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert added in v0.7.0

type Alert struct {
	Workflow    string
	RunID       string
	Status      string
	Trigger     string
	Attempts    int
	LogicalDate *time.Time
	Err         string

	// Step is the node that failed. It arrives as a field of its own, and not
	// only embedded in the error text, because it is the first thing whoever is
	// on call looks for: "which step?" before "why?".
	Step string

	// LogExcerpt is the last few lines of that step's output, read from
	// `task_runs.log`. Without it the alert says something failed; with it the
	// alert says what failed and why, without anyone opening the screen at
	// 4am.
	LogExcerpt string

	// The workflow's tags become the message's "Domain" and "Pipeline" fields --
	// in Kestra that came from `labels`, and it is what makes an alert
	// actionable without opening the screen.
	Tags []string

	// BaseURL of the UI, for the run's direct link. Empty means no link.
	BaseURL string
}

Alert is what gets told about a failure.

type Notificador

type Notificador interface {
	Failed(ctx context.Context, a Alert) error
}

Notificador sends the alert. A small interface so the dispatcher knows nothing of Slack -- and so the test needs no network.

type Slack

type Slack struct {
	Webhook string
	Client  *http.Client

	// Ambiente appears in the header ("prod", "dev"). Without it, a staging
	// alert at three in the morning is indistinguishable from a production
	// one.
	Environment string
}

Slack posts to an Incoming Webhook.

func NovoSlack

func NovoSlack(webhook, environment string) *Slack

func (*Slack) Failed added in v0.7.0

func (s *Slack) Failed(ctx context.Context, a Alert) error

Failed posts the message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL