modules

package
v0.0.0-...-faff564 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RuleDir = "/tmp"

Functions

func DebugNotifyFunc

func DebugNotifyFunc(logger log.Logger) rules.NotifyFunc

DebugNotifyFunc

func HTTPNotifyFunc

func HTTPNotifyFunc(logger log.Logger, token string, url string, retries int) rules.NotifyFunc

HTTPNotifyFunc whit resolved;

func HTTPQueryFunc

func HTTPQueryFunc(logger log.Logger, url string) rules.QueryFunc

HTTPQueryFunc TODO: use http keep-alive

func NewMockStorage

func NewMockStorage() (storage.Storage, error)

NewMockStorage create temporary storage

Types

type Alert

type Alert rules.Alert

Alert

func (*Alert) MarshalJSON

func (a *Alert) MarshalJSON() ([]byte, error)

MarshalJSON ...

type Config

type Config struct {
	NotifyReties       int
	AlertManagerUrl    string
	GatewayURL         string
	GatewayPathRule    string
	GatewayPathProm    string
	GatewayPathNotify  string
	EvaluationInterval model.Duration
	ReloadInterval     model.Duration
	AuthToken          string

	PromlogConfig promlog.Config
}

Config ...

type M

type M map[string]interface{}

M is map

type Manager

type Manager struct {
	Config  Config
	Prom    Prom
	Options *rules.ManagerOptions
	Manager *rules.Manager
	Rules   Rules
	// contains filtered or unexported fields
}

Manager ...

func NewManager

func NewManager(ctx context.Context, logger log.Logger,
	prom Prom, config Config) (*Manager, error)

NewManager ...

func (*Manager) Run

func (m *Manager) Run()

Run ...

func (*Manager) Stop

func (m *Manager) Stop()

Stop ...

func (*Manager) Update

func (m *Manager) Update(rules Rules) error

Update ...

type MockStorage

type MockStorage struct {
	storage.Storage
	// contains filtered or unexported fields
}

MockStorage temporary storage

func (MockStorage) Close

func (s MockStorage) Close() error

Close delete temporary files when closed

type NotifyAlert

type NotifyAlert struct {
	// Label value pairs for purpose of aggregation, matching, and disposition
	// dispatching. This must minimally include an "alertname" label.
	Labels labels.Labels `json:"labels"`

	// Extra key/value information which does not define alert identity.
	Annotations labels.Labels `json:"annotations"`

	// The known time range for this alert. Both ends are optional.
	StartsAt     time.Time `json:"startsAt,omitempty"`
	EndsAt       time.Time `json:"endsAt,omitempty"`
	GeneratorURL string    `json:"generatorURL,omitempty"`
}

type Prom

type Prom struct {
	ID  int64
	URL string
}

Prom ...

type PromRules

type PromRules struct {
	Prom  Prom
	Rules Rules
}

PromRules ...

type PromsResp

type PromsResp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data []Prom `json:"data"`
}

PromsResp ...

type Reloader

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

Reloader ...

func NewReloader

func NewReloader(logger log.Logger, cfg Config) *Reloader

NewReloader ...

func (*Reloader) Loop

func (r *Reloader) Loop()

Loop for checking the rules

func (*Reloader) Run

func (r *Reloader) Run()

Run rule manager

func (*Reloader) Stop

func (r *Reloader) Stop()

Stop rule manager

func (*Reloader) Update

func (r *Reloader) Update() error

download the rules and update rule manager

type Rule

type Rule struct {
	ID          int64             `json:"id"`
	AlertN      string            `json:"alertn"`
	Cluster     string            `json:"cluster"`
	Severity    string            `json:"severity"`
	Type        string            `json:"type"`
	ProjectName string            `json:"project_name"`
	AppName     string            `json:"app_name"`
	Env         string            `json:"env"`
	PromID      int64             `json:"prom_id"`
	Expr        string            `json:"expr"`
	Op          string            `json:"op"`
	Value       string            `json:"value"`
	For         string            `json:"for"`
	Labels      map[string]string `json:"labels"`
	//Labels      Labels
	Summary     string `json:"summary"`
	Description string `json:"description"`
}

Rule ...

type Rules

type Rules []Rule

Rules ...

func (Rules) Content

func (r Rules) Content() ([]byte, error)

Content get prom rules

func (Rules) PromRules

func (r Rules) PromRules() []PromRules

PromRules cut prom rules

type RulesResp

type RulesResp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data Rules  `json:"data"`
}

RulesResp ...

type S

type S []interface{}

S is slice

Jump to

Keyboard shortcuts

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