monitor

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllLocal

func GetAllLocal(rootDir string) (map[string]Monitor, mapset.Set, error)

GetAllLocal Parse all local monitors under rootDir

func GetAllRemote

func GetAllRemote(esClient es.Client, destinationsMap map[string]string) (map[string]Monitor, mapset.Set, error)

GetAllRemote will pull all the monitors from ES cluster

Types

type Action

type Action struct {
	ID            string `json:"id,omitempty" yaml:"-"`
	Name          string `json:"name"`
	DestinationID string `json:"destination_id,omitempty" yaml:"destinationId"`
	// Why duplicated Subject and Message ? This is to simplify customer experience on writing new monitors.
	// Taking input which is important default are being filled by CLI
	Subject         string `json:"-"`
	Message         string `json:"-"`
	SubjectTemplate Script `json:"subject_template" yaml:"-"`
	MessageTemplate Script `json:"message_template" yaml:"-"`
}

Action action model

type Condition

type Condition struct {
	Script Script `json:"script"`
}

Condition define condition for the triggers

type Cron

type Cron struct {
	Expression string `json:"expression"`
	Timezone   string `json:"timezone"`
}

Cron Define monitor with Cron

type Monitor

type Monitor struct {
	Name     string    `json:"name"`
	Enabled  bool      `json:"enabled"`
	Schedule Schedule  `json:"schedule"`
	Inputs   []Search  `json:"inputs"`
	Triggers []Trigger `json:"triggers"`
	// contains filtered or unexported fields
}

Monitor Alert monitor object

func (*Monitor) Create

func (monitor *Monitor) Create(esClient es.Client) error

Create will create new monitor

func (*Monitor) Delete

func (monitor *Monitor) Delete(esClient es.Client) error

Delete delete a monitor from remote

func (*Monitor) Prepare

func (monitor *Monitor) Prepare(
	remoteMonitor Monitor,
	destinationsMap map[string]string,
	isUpdate bool,
	odVersion int) error

Prepare will modify the monitor to populate correct IDs

func (*Monitor) Run

func (monitor *Monitor) Run(esClient es.Client, dryRun bool) error

Run will execute monitor

func (*Monitor) Update

func (monitor *Monitor) Update(esClient es.Client) error

Update will modify existing monitor

type Period

type Period struct {
	Interval int    `json:"interval"`
	Unit     string `json:"unit"`
}

Period Define monitor with period

type Schedule

type Schedule struct {
	Period *Period `json:"period,omitempty"`
	Cron   *Cron   `json:"cron,omitempty"`
}

Schedule type of Monitor (Cron / Period)

type Script

type Script struct {
	Source string `json:"source"`
	Lang   string `json:"lang"`
}

Script Works for mustache and painless

type Search struct {
	Search struct {
		Indices []string               `json:"indices"`
		Query   map[string]interface{} `json:"query"`
	} `json:"search"`
}

Search hello

type Trigger

type Trigger struct {
	ID       string `json:"id,omitempty" yaml:"-"`
	Name     string `json:"name"`
	Severity string `json:"severity"`
	//YCondition (YAML Condition), is to to minimize customer input for now
	YCondition string    `json:"-" yaml:"condition"`
	Condition  Condition `json:"condition" yaml:"-"`
	Actions    []Action  `json:"actions,omitempty"`
}

Trigger define a Trigger struct

Jump to

Keyboard shortcuts

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