slack

package
v1.5.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2018 License: MIT Imports: 13 Imported by: 76

Documentation

Index

Constants

View Source
const DefaultUsername = "kapacitor"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Whether Slack integration is enabled.
	Enabled bool `toml:"enabled" override:"enabled"`
	// Whether this is the default slack config.
	Default bool `toml:"default" override:"default"`
	// ID assigned if multiple slack configs are given
	Workspace string `toml:"workspace"  override:"workspace"`
	// The Slack webhook URL, can be obtained by adding Incoming Webhook integration.
	URL string `toml:"url" override:"url,redact"`
	// The default channel, can be overridden per alert.
	Channel string `toml:"channel" override:"channel"`
	// The username of the Slack bot.
	// Default: kapacitor
	Username string `toml:"username" override:"username"`
	// IconEmoji uses an emoji instead of the normal icon for the message.
	// The contents should be the name of an emoji surrounded with ':', i.e. ':chart_with_upwards_trend:'
	IconEmoji string `toml:"icon-emoji" override:"icon-emoji"`
	// Whether all alerts should automatically post to slack
	Global bool `toml:"global" override:"global"`
	// Whether all alerts should automatically use stateChangesOnly mode.
	// Only applies if global is also set.
	StateChangesOnly bool `toml:"state-changes-only" override:"state-changes-only"`

	// Path to CA file
	SSLCA string `toml:"ssl-ca" override:"ssl-ca"`
	// Path to host cert file
	SSLCert string `toml:"ssl-cert" override:"ssl-cert"`
	// Path to cert key file
	SSLKey string `toml:"ssl-key" override:"ssl-key"`
	// Use SSL but skip chain & host verification
	InsecureSkipVerify bool `toml:"insecure-skip-verify" override:"insecure-skip-verify"`
}

func NewConfig

func NewConfig() Config

func NewDefaultConfig added in v1.5.0

func NewDefaultConfig() Config

func (*Config) ApplyDefaults added in v1.5.0

func (c *Config) ApplyDefaults()

func (Config) Validate added in v1.1.0

func (c Config) Validate() error

type Configs added in v1.5.0

type Configs []Config

func (*Configs) UnmarshalTOML added in v1.5.0

func (cs *Configs) UnmarshalTOML(data interface{}) error

func (Configs) Validate added in v1.5.0

func (cs Configs) Validate() error

type Diagnostic added in v1.4.0

type Diagnostic interface {
	WithContext(ctx ...keyvalue.T) Diagnostic

	InsecureSkipVerify()

	Error(msg string, err error)
}

type HandlerConfig added in v1.2.0

type HandlerConfig struct {
	// Slack workspace ID to use when posting messages
	// If empty uses the default config
	Workspace string `mapstructure:"workspace"`

	// Slack channel in which to post messages.
	// If empty uses the channel from the configuration.
	Channel string `mapstructure:"channel"`

	// Username of the Slack bot.
	// If empty uses the username from the configuration.
	Username string `mapstructure:"username"`

	// IconEmoji is an emoji name surrounded in ':' characters.
	// The emoji image will replace the normal user icon for the slack bot.
	IconEmoji string `mapstructure:"icon-emoji"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(confs []Config, d Diagnostic) (*Service, error)

func (*Service) Alert

func (s *Service) Alert(workspace, channel, message, username, iconEmoji string, level alert.Level) error

func (*Service) Close

func (s *Service) Close() error

func (*Service) Global

func (s *Service) Global() bool

func (*Service) Handler added in v1.2.0

func (s *Service) Handler(c HandlerConfig, ctx ...keyvalue.T) alert.Handler

func (*Service) Open

func (s *Service) Open() error

func (*Service) StateChangesOnly added in v0.11.0

func (s *Service) StateChangesOnly() bool

func (*Service) Test added in v1.1.0

func (s *Service) Test(options interface{}) error

func (*Service) TestOptions added in v1.1.0

func (s *Service) TestOptions() interface{}

func (*Service) Update added in v1.1.0

func (s *Service) Update(newConfigs []interface{}) error

type Workspace added in v1.5.0

type Workspace struct {
	// contains filtered or unexported fields
}

func NewWorkspace added in v1.5.0

func NewWorkspace(c Config) (*Workspace, error)

func (*Workspace) Client added in v1.5.0

func (w *Workspace) Client() *http.Client

func (*Workspace) Config added in v1.5.0

func (w *Workspace) Config() Config

func (*Workspace) Update added in v1.5.0

func (w *Workspace) Update(c Config) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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