utils

package
v0.0.0-...-1569ab3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuleStatusDisabled = 0
	RuleStatusEnable   = 1
)

Variables

This section is empty.

Functions

func DeletePrometheusRuleAndReload

func DeletePrometheusRuleAndReload(ids []string) error

func GetMysqlInstance

func GetMysqlInstance() *gorm.DB

func GetPrometheusMetricValue

func GetPrometheusMetricValue(metric string) (interface{}, error)

func ModifyPrometheusRuleAndReload

func ModifyPrometheusRuleAndReload(alertRules []*models.AlertRules) error

func NewMysqlInstanceByConn

func NewMysqlInstanceByConn(conf *mysql.MysqlConfig) (*gorm.DB, error)

func PostPrometheusReload

func PostPrometheusReload() error

func ReadRule

func ReadRule() ([]byte, error)

func StrArrayIsContain

func StrArrayIsContain(arr []string, str string) bool

func WriteRule

func WriteRule(ruleBytes []byte) error

Types

type GroupsYml

type GroupsYml struct {
	Name  string     `yaml:"name"`
	Rules []*RuleYml `yaml:"rules"`
}

type PrometheusYml

type PrometheusYml struct {
	Groups []*GroupsYml `yaml:"groups"`
}

type RuleYml

type RuleYml struct {
	Alert       string            `yaml:"alert"`
	Annotations map[string]string `yaml:"annotations"`
	Expr        string            `yaml:"expr"`
	For         string            `yaml:"for"`
	Labels      map[string]string `yaml:"labels"`
}

func CreatAndUpdateRule

func CreatAndUpdateRule(ruleYml *RuleYml, alertRule *models.AlertRules) *RuleYml

Jump to

Keyboard shortcuts

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