models

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const AlertStateActive = "active"

AlertStateActive is the state in which we know that the alert should fire

View Source
const AlertStateSuppressed = "suppressed"

AlertStateSuppressed means that we know that alert is silenced or inhibited

View Source
const AlertStateUnprocessed = "unprocessed"

AlertStateUnprocessed means that Alertmanager notify didn't yet process it and AM doesn't know if alert is active or suppressed

Variables

AlertStateList exports all alert states so other packages can get this list

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Annotations Annotations       `json:"annotations"`
	Labels      map[string]string `json:"labels"`
	StartsAt    time.Time         `json:"startsAt"`
	EndsAt      time.Time         `json:"endsAt"`
	State       string            `json:"state"`
	// those are not exposed in JSON, Alertmanager specific value will be in kept
	// in the Alertmanager slice
	// skip those when generating alert fingerprint too
	GeneratorURL string   `json:"-" hash:"-"`
	SilencedBy   []string `json:"-" hash:"-"`
	InhibitedBy  []string `json:"-" hash:"-"`
	// unsee fields
	Alertmanager []AlertmanagerInstance `json:"alertmanager"`
	Receiver     string                 `json:"receiver"`
	// contains filtered or unexported fields
}

Alert is vanilla alert + some additional attributes unsee extends an alert object with:

  • Links map, it's generated from annotations if annotation value is an url it's pulled out of annotation map and returned under links field, unsee UI used this to show links differently than other annotations

func (*Alert) ContentFingerprint

func (a *Alert) ContentFingerprint() string

ContentFingerprint is a checksum computed from entire alert object except some blacklisted fields tagged with hash:"-"

func (*Alert) IsActive

func (a *Alert) IsActive() bool

IsActive will return true if alert is not suppressed in any way

func (*Alert) IsInhibited

func (a *Alert) IsInhibited() bool

IsInhibited will return true if alert should be considered silenced

func (*Alert) IsSilenced

func (a *Alert) IsSilenced() bool

IsSilenced will return true if alert should be considered silenced

func (*Alert) LabelsFingerprint

func (a *Alert) LabelsFingerprint() string

LabelsFingerprint is a checksum computed only from labels which should be unique for every alert

func (*Alert) UpdateFingerprints

func (a *Alert) UpdateFingerprints()

UpdateFingerprints will generate a new set of fingerprints for this alert it should be called after modifying any field that isn't tagged with hash:"-"

type AlertGroup

type AlertGroup struct {
	Receiver   string            `json:"receiver"`
	Labels     map[string]string `json:"labels"`
	Alerts     AlertList         `json:"alerts"`
	ID         string            `json:"id"`
	Hash       string            `json:"hash"`
	StateCount map[string]int    `json:"stateCount"`
}

AlertGroup is vanilla Alertmanager group, but alerts are flattened There is a hash computed from all alerts, it's used by UI to quickly tell if there was any change in a group and it needs to refresh it

func (AlertGroup) ContentFingerprint

func (ag AlertGroup) ContentFingerprint() string

ContentFingerprint is a checksum of all alerts in the group

func (AlertGroup) LabelsFingerprint

func (ag AlertGroup) LabelsFingerprint() string

LabelsFingerprint is a checksum of this AlertGroup labels and the receiver it should be unique for each AlertGroup

type AlertList

type AlertList []Alert

AlertList is flat list of UnseeAlert objects

func (AlertList) Len

func (a AlertList) Len() int

func (AlertList) Less

func (a AlertList) Less(i, j int) bool

func (AlertList) Swap

func (a AlertList) Swap(i, j int)

type AlertmanagerAPICounters

type AlertmanagerAPICounters struct {
	Total   int `json:"total"`
	Healthy int `json:"healthy"`
	Failed  int `json:"failed"`
}

AlertmanagerAPICounters returns number of Alertmanager instances in each state

type AlertmanagerAPIStatus

type AlertmanagerAPIStatus struct {
	Name  string `json:"name"`
	URI   string `json:"uri"`
	Error string `json:"error"`
}

AlertmanagerAPIStatus describes the Alertmanager instance overall health

type AlertmanagerAPISummary

type AlertmanagerAPISummary struct {
	Counters  AlertmanagerAPICounters `json:"counters"`
	Instances []AlertmanagerAPIStatus `json:"instances"`
}

AlertmanagerAPISummary describes the Alertmanager instance overall health

type AlertmanagerInstance

type AlertmanagerInstance struct {
	Name string `json:"name"`
	URI  string `json:"uri"`
	// per instance alert state
	State string `json:"state"`
	// timestamp collected from this instance, those on the alert itself
	// will be calculated min/max values
	StartsAt time.Time `json:"startsAt"`
	EndsAt   time.Time `json:"endsAt"`
	// Source links to alert source for given alertmanager instance
	Source string `json:"source"`
	// all silences matching current alert in this upstream
	Silences map[string]Silence `json:"silences"`
}

AlertmanagerInstance describes the Alertmanager instance alert was collected from

type AlertsResponse

type AlertsResponse struct {
	Status      string                 `json:"status"`
	Timestamp   string                 `json:"timestamp"`
	Version     string                 `json:"version"`
	Upstreams   AlertmanagerAPISummary `json:"upstreams"`
	AlertGroups []AlertGroup           `json:"groups"`
	Colors      LabelsColorMap         `json:"colors"`
	Filters     []Filter               `json:"filters"`
	Counters    LabelsCountMap         `json:"counters"`
}

AlertsResponse is the structure of JSON response UI will use to get alert data

type Annotation

type Annotation struct {
	Name    string `json:"name"`
	Value   string `json:"value"`
	Visible bool   `json:"visible"`
	IsLink  bool   `json:"isLink"`
}

Annotation extends Alertmanager scheme of key:value with additional data to control how given annotation should be rendered

type Annotations

type Annotations []Annotation

Annotations is a slice of Annotation structs, needed to implement sorting

func AnnotationsFromMap

func AnnotationsFromMap(m map[string]string) Annotations

AnnotationsFromMap will convert a map[string]string to a list of Annotation instances, it takes care of setting proper value for Visible attribute

func (Annotations) Len

func (a Annotations) Len() int

func (Annotations) Less

func (a Annotations) Less(i, j int) bool

func (Annotations) Swap

func (a Annotations) Swap(i, j int)

type Autocomplete

type Autocomplete struct {
	Value  string   `json:"value"`
	Tokens []string `json:"tokens"`
}

Autocomplete is the structure of autocomplete object for filter hints this is internal represenation, not what's returned to the user

type Color

type Color struct {
	Red   uint8 `json:"red"`
	Green uint8 `json:"green"`
	Blue  uint8 `json:"blue"`
	Alpha uint8 `json:"alpha"`
}

Color is used by UnseeLabelColor to reprenset colors as RGBA

type Filter

type Filter struct {
	Text    string `json:"text"`
	Hits    int    `json:"hits"`
	IsValid bool   `json:"isValid"`
}

Filter holds returned data on any filter passed by the user as part of the query

type JiraRule added in v0.9.0

type JiraRule struct {
	Regex string
	URI   string
}

JiraRule is used to detect JIRA issue IDs in strings and turn those into links

type LabelColors

type LabelColors struct {
	Font       Color `json:"font"`
	Background Color `json:"background"`
}

LabelColors holds color information for labels that should be colored in the UI every configured label will have a distinct coloring for each value

type LabelsColorMap

type LabelsColorMap map[string]map[string]LabelColors

LabelsColorMap is a map of "Label Key" -> "Label Value" -> UnseeLabelColors

type LabelsCountMap

type LabelsCountMap map[string]map[string]int

LabelsCountMap is a map of "Label Key" -> "Label Value" -> number of occurence

type Silence

type Silence struct {
	ID       string `json:"id"`
	Matchers []struct {
		Name    string `json:"name"`
		Value   string `json:"value"`
		IsRegex bool   `json:"isRegex"`
	} `json:"matchers"`
	StartsAt  time.Time `json:"startsAt"`
	EndsAt    time.Time `json:"endsAt"`
	CreatedAt time.Time `json:"createdAt"`
	CreatedBy string    `json:"createdBy"`
	Comment   string    `json:"comment"`
	// unsee fields
	JiraID  string `json:"jiraID"`
	JiraURL string `json:"jiraURL"`
}

Silence is vanilla silence + some additional attributes Unsee adds JIRA support, it can extract JIRA IDs from comments extracted ID is used to generate link to JIRA issue this means Unsee needs to store additional fields for each silence

Jump to

Keyboard shortcuts

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