jiralert

package module
v3.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: MIT Imports: 21 Imported by: 0

README

JIRAlert Build Status Go Report Card GoDoc

Prometheus Alertmanager webhook receiver for JIRA.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Defaults  *ReceiverConfig   `yaml:"defaults,omitempty" json:"defaults,omitempty"`
	Receivers []*ReceiverConfig `yaml:"receivers,omitempty" json:"receivers,omitempty"`
	Template  string            `yaml:"template" json:"template"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-"`
}

Config is the top-level configuration for JIRAlert's config file.

func LoadConfig

func LoadConfig(s string) (*Config, error)

LoadConfig parses the YAML input into a Config.

func LoadConfigFile

func LoadConfigFile(filename string) (*Config, []byte, error)

LoadConfigFile parses the given YAML file into a Config.

func (*Config) ReceiverByName

func (c *Config) ReceiverByName(name string) *ReceiverConfig

ReceiverByName loops the receiver list and returns the first instance with that name

func (Config) String

func (c Config) String() string

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Duration

type Duration time.Duration

Duration Time in ms

func ParseDuration

func ParseDuration(durationStr string) (Duration, error)

ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML for duration

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML for duration

type Receiver

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

Receiver wraps a JIRA client corresponding to a specific Alertmanager receiver, with its configuration and templates.

func NewReceiver

func NewReceiver(c *ReceiverConfig, t *Template) (*Receiver, error)

NewReceiver creates a Receiver using the provided configuration and template.

func (*Receiver) Notify

func (r *Receiver) Notify(data *alertmanager.Data) (bool, error)

Notify implements the Notifier interface.

type ReceiverConfig

type ReceiverConfig struct {
	Name string `yaml:"name" json:"name"`

	// API access fields
	APIURL   string `yaml:"api_url" json:"api_url"`
	User     string `yaml:"user" json:"user"`
	Password Secret `yaml:"password" json:"password"`

	// Required issue fields
	Project     string `yaml:"project" json:"project"`
	IssueType   string `yaml:"issue_type" json:"issue_type"`
	Summary     string `yaml:"summary" json:"summary"`
	ReopenState string `yaml:"reopen_state" json:"reopen_state"`

	// Optional issue fields
	Priority          string                 `yaml:"priority" json:"priority"`
	Description       string                 `yaml:"description" json:"description"`
	WontFixResolution string                 `yaml:"wont_fix_resolution" json:"wont_fix_resolution"`
	Fields            map[string]interface{} `yaml:"fields" json:"fields"`
	Components        []string               `yaml:"components" json:"components"`
	ReopenDuration    *Duration              `yaml:"reopen_duration" json:"reopen_duration"`

	// Label copy settings
	AddGroupLabels bool `yaml:"add_group_labels" json:"add_group_labels"`

	// Label settings
	AddLabels bool `yaml:"add_labels" json:"add_labels"`

	// alert_hash to identify and search alerts
	AlertHash string `yaml:"alert_hash" json:"alert_hash"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-"`
}

ReceiverConfig is the configuration for one receiver. It has a unique name and includes API access fields (URL, user and password) and issue fields (required -- e.g. project, issue type -- and optional -- e.g. priority).

func (*ReceiverConfig) UnmarshalYAML

func (rc *ReceiverConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Secret

type Secret string

Secret is a string that must not be revealed on marshaling.

func (Secret) MarshalYAML

func (s Secret) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*Secret) UnmarshalYAML

func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for Secrets.

type Template

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

Template wraps a text template and error, to make it easier to execute multiple templates and only check for errors once at the end (assuming one is only interested in the first error, which is usually the case).

func LoadTemplate

func LoadTemplate(path string) (*Template, error)

LoadTemplate reads and parses all templates defined in the given file and constructs a jiralert.Template.

func (*Template) Execute

func (t *Template) Execute(text string, data interface{}) string

Execute parses the provided text (or returns it unchanged if not a Go template), associates it with the templates defined in t.tmpl (so they may be referenced and used) and applies the resulting template to the specified data object, returning the output as a string.

Directories

Path Synopsis
Package alertmanager defines structures and primitives to support Alertmanager's webhook API.
Package alertmanager defines structures and primitives to support Alertmanager's webhook API.
cmd

Jump to

Keyboard shortcuts

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