action

package
v0.0.0-...-890d60c Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package action implements all the different actions an alert can take should its condition be found to be true

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type string
	Actioner
}

Action is a wrapper around an Actioner which contains some type information

func ToActioner

func ToActioner(in interface{}) (Action, error)

ToActioner takes in some arbitrary data (hopefully a map[string]interface{}, looks at its "type" key, and any other fields necessary based on that type, and returns an Actioner (or an error)

type Actioner

type Actioner interface {

	// Do takes in the alert context, and possibly returnes an error if the
	// action failed
	Do(context.Context) error
}

Actioner describes an action type. There all multiple action types, but they all simply attempt to perform one action and that's it

type HTTP

type HTTP struct {
	Method  string            `mapstructure:"method"`
	URL     string            `mapstructure:"url"`
	Headers map[string]string `mapstructure:"headers"`
	Body    string            `mapstructure:"body"`
}

HTTP is an action which performs a single http request. If the request's response doesn't have a 2xx response code then it's considered an error

func (*HTTP) Do

func (h *HTTP) Do(_ context.Context) error

Do performs the actual http request. It doesn't need the alert context

type Log

type Log struct {
	Message string `mapstructure:"message"`
}

Log is an action which does nothing but print a log message. Useful when testing alerts and you don't want to set up any actions yet

func (*Log) Do

func (l *Log) Do(_ context.Context) error

Do logs the Log's message. It doesn't actually need any context

type Slack

type Slack struct {
	Text string `json:"text" mapstructure:"text"`
}

OpsGenie submits an alert to an Slack endpoint

func (*Slack) Do

func (s *Slack) Do(c context.Context) error

Do performs the actual trigger request to the Slack api

Jump to

Keyboard shortcuts

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