models

package
v0.48.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: Apache-2.0 Imports: 11 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 APIAlertGroup added in v0.48.1

type APIAlertGroup struct {
	AlertGroup
	Shared APIAlertGroupSharedMaps `json:"shared"`
}

APIAlertGroup is how AlertGroup is returned in the API response All labels and annotations that are shared between all alerts in given group are moved to Shared namespace, each alert instance only tracks labels and annotations that are unique to that instance

func (*APIAlertGroup) DedupSharedMaps added in v0.48.1

func (ag *APIAlertGroup) DedupSharedMaps()

DedupSharedMaps will find all labels and annotations shared by all alerts in this group and moved them to Shared namespace

type APIAlertGroupSharedMaps added in v0.48.1

type APIAlertGroupSharedMaps struct {
	Annotations Annotations         `json:"annotations"`
	Labels      map[string]string   `json:"labels"`
	Silences    map[string][]string `json:"silences"`
}

APIAlertGroupSharedMaps defines shared part of APIAlertGroup

type Alert

type Alert struct {
	Annotations Annotations       `json:"annotations"`
	Labels      map[string]string `json:"labels"`
	StartsAt    time.Time         `json:"startsAt"`
	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:"-"`
	// karma fields
	Alertmanager []AlertmanagerInstance `json:"alertmanager"`
	Receiver     string                 `json:"receiver"`
	// contains filtered or unexported fields
}

Alert is vanilla alert + some additional attributes karma 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, karma 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"`
	AlertmanagerCount map[string]int    `json:"alertmanagerCount"`
	StateCount        map[string]int    `json:"stateCount"`
	LatestStartsAt    time.Time         `json:"-"`
}

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) FindLatestStartsAt added in v0.48.1

func (ag AlertGroup) FindLatestStartsAt() time.Time

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 karmaAlert 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"`
	// this is the Alertmanager URI used for all requests made by the UI
	URI string `json:"uri"`
	// this is the Alertmanager URI used for links in the browser
	PublicURI      string            `json:"publicURI"`
	Headers        map[string]string `json:"headers"`
	Error          string            `json:"error"`
	Version        string            `json:"version"`
	Cluster        string            `json:"cluster"`
	ClusterMembers []string          `json:"clusterMembers"`
}

AlertmanagerAPIStatus describes the Alertmanager instance overall health

type AlertmanagerAPISummary

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

AlertmanagerAPISummary describes the Alertmanager instance overall health

type AlertmanagerInstance

type AlertmanagerInstance struct {
	Name    string `json:"name"`
	Cluster string `json:"cluster"`
	// 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"`
	// Source links to alert source for given alertmanager instance
	Source string `json:"source"`
	// all silences matching current alert in this upstream, we don't export this
	// in api responses, this is used internally
	Silences map[string]*Silence `json:"-"`
	// export list of silenced IDs in api response
	SilencedBy  []string `json:"silencedBy"`
	InhibitedBy []string `json:"inhibitedBy"`
}

AlertmanagerInstance describes the Alertmanager instance alert was collected from

type AlertmanagerStatus added in v0.48.1

type AlertmanagerStatus struct {
	Version string
	ID      string
	PeerIDs []string
}

type AlertsResponse

type AlertsResponse struct {
	Status      string                        `json:"status"`
	Timestamp   string                        `json:"timestamp"`
	Version     string                        `json:"version"`
	Upstreams   AlertmanagerAPISummary        `json:"upstreams"`
	Silences    map[string]map[string]Silence `json:"silences"`
	AlertGroups []APIAlertGroup               `json:"groups"`
	TotalAlerts int                           `json:"totalAlerts"`
	Colors      LabelsColorMap                `json:"colors"`
	Filters     []Filter                      `json:"filters"`
	Counters    LabelNameStatsList            `json:"counters"`
	Settings    Settings                      `json:"settings"`
}

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 representation, 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 karmaLabelColor to reprenset colors as RGBA

type Filter

type Filter struct {
	Text    string `json:"text"`
	Name    string `json:"name"`
	Matcher string `json:"matcher"`
	Value   string `json:"value"`
	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 GridSettings added in v0.48.1

type GridSettings struct {
	Order   string `json:"order"`
	Reverse bool   `json:"reverse"`
	Label   string `json:"label"`
}

GridSettings exposes all grid settings from the config file

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 {
	Brightness int32 `json:"brightness"`
	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 LabelNameStats added in v0.48.1

type LabelNameStats struct {
	Name   string              `json:"name"`
	Values LabelValueStatsList `json:"values"`
	Hits   int                 `json:"hits"`
}

LabelStats is used in the overview modal, it shows top labels across alerts

type LabelNameStatsList added in v0.48.1

type LabelNameStatsList []LabelNameStats

func (LabelNameStatsList) Len added in v0.48.1

func (lnsl LabelNameStatsList) Len() int

func (LabelNameStatsList) Less added in v0.48.1

func (lnsl LabelNameStatsList) Less(i, j int) bool

func (LabelNameStatsList) Swap added in v0.48.1

func (lnsl LabelNameStatsList) Swap(i, j int)

type LabelValueStats added in v0.48.1

type LabelValueStats struct {
	Value   string `json:"value"`
	Raw     string `json:"raw"`
	Hits    int    `json:"hits"`
	Percent int    `json:"percent"`
	Offset  int    `json:"offset"`
}

type LabelValueStatsList added in v0.48.1

type LabelValueStatsList []LabelValueStats

func (LabelValueStatsList) Len added in v0.48.1

func (lvsl LabelValueStatsList) Len() int

func (LabelValueStatsList) Less added in v0.48.1

func (lvsl LabelValueStatsList) Less(i, j int) bool

func (LabelValueStatsList) Swap added in v0.48.1

func (lvsl LabelValueStatsList) Swap(i, j int)

type LabelsColorMap

type LabelsColorMap map[string]map[string]LabelColors

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

type LabelsCountMap

type LabelsCountMap map[string]map[string]int

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

type ManagedSilence added in v0.48.1

type ManagedSilence struct {
	Cluster   string  `json:"cluster"`
	IsExpired bool    `json:"isExpired"`
	Silence   Silence `json:"silence"`
}

ManagedSilence is a standalone silence detached from any alert

type Settings added in v0.48.1

type Settings struct {
	StaticColorLabels        []string            `json:"staticColorLabels"`
	AnnotationsDefaultHidden bool                `json:"annotationsDefaultHidden"`
	AnnotationsHidden        []string            `json:"annotationsHidden"`
	AnnotationsVisible       []string            `json:"annotationsVisible"`
	Sorting                  SortSettings        `json:"sorting"`
	SilenceForm              SilenceFormSettings `json:"silenceForm"`
}

Settings is used to export karma configuration that is used by UI

type Silence

type Silence struct {
	ID        string           `json:"id"`
	Matchers  []SilenceMatcher `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"`
	// karma fields
	JiraID  string `json:"jiraID"`
	JiraURL string `json:"jiraURL"`
}

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

type SilenceFormSettings added in v0.48.1

type SilenceFormSettings struct {
	Strip  SilenceFormStripSettings `json:"strip"`
	Author string                   `json:"author"`
}

type SilenceFormStripSettings added in v0.48.1

type SilenceFormStripSettings struct {
	Labels []string `json:"labels"`
}

type SilenceMatcher added in v0.48.1

type SilenceMatcher struct {
	Name    string `json:"name"`
	Value   string `json:"value"`
	IsRegex bool   `json:"isRegex"`
}

type SortSettings added in v0.48.1

type SortSettings struct {
	Grid         GridSettings                 `json:"grid"`
	ValueMapping map[string]map[string]string `json:"valueMapping"`
}

SortSettings nests all settings specific to sorting

Jump to

Keyboard shortcuts

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