conf

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppYamlSchema = `` /* 1482-byte string literal not displayed */
View Source
var RuleYamlSchema = `` /* 1249-byte string literal not displayed */

Functions

func BuildFindByIdsDSLBody

func BuildFindByIdsDSLBody(ids []string) string

func GetMetricsOpRedisFingerprint

func GetMetricsOpRedisFingerprint(uniqueId string, path string, cmd string, key string, statusCode int) string

func GetMetricsWebhookNotifyFingerprint

func GetMetricsWebhookNotifyFingerprint(uniqueId string, path string, statusCode int) string

Types

type AppConfig

type AppConfig struct {
	Exporter struct {
		ListenAddr string `yaml:"listen_addr" default:":9003"`
		Enabled    bool   `yaml:"enabled" default:"true"`
	} `yaml:"exporter"`
	Loader struct {
		Type   string         `yaml:"type" default:"FileLoader"`
		Config map[string]any `yaml:"config"`
	} `yaml:"loader"`
	Alert struct {
		Alertmanager struct {
			Url       string `yaml:"url"`
			BasicAuth struct {
				Username string `yaml:"username"`
				Password string `yaml:"password"`
			} `yaml:"basic_auth"`
		} `yaml:"alertmanager"`
		Generator struct {
			BaseUrl string          `yaml:"base_url"`
			Expire  xtime.TimeLimit `yaml:"expire"`
		} `yaml:"generator"`
	} `yaml:"alert"`
	Redis struct {
		Addr         string `yaml:"addr" default:"127.0.0.1"`
		Port         int    `yaml:"port" default:"6379"`
		Password     string `yaml:"password"`
		Db           int    `yaml:"db" default:"0"`
		PoolSize     int    `yaml:"pool_size" default:"512"`
		ReadTimeout  int    `yaml:"read_timeout" default:"30"`
		WriteTimeout int    `yaml:"write_timeout" default:"30"`
		DialTimeout  int    `yaml:"dial_timeout" default:"5"`
	} `yaml:"redis"`
	RunEvery          xtime.TimeLimit `yaml:"run_every"`
	BufferTime        xtime.TimeLimit `yaml:"buffer_time"`
	AlertTimeLimit    xtime.TimeLimit `yaml:"alert_time_limit"`
	MaxScrollingCount uint            `yaml:"max_scrolling_count" default:"5"`
}

AppConfig is application global configure

var AppConf *AppConfig

func GetAppConfig

func GetAppConfig(path string) *AppConfig

type EsConfig

type EsConfig struct {
	Addresses   []string `yaml:"addresses"`
	Username    string   `yaml:"username"`
	Password    string   `yaml:"password"`
	ConnTimeout uint     `yaml:"conn_timeout" default:"10"`
	Version     string   `yaml:"version" default:"v7"`
}

type FlagOption

type FlagOption struct {
	ConfigPath string `short:"c" long:"config" description:"config.yaml path" default:"./config.yaml"`
	Debug      bool   `long:"debug" description:"debug log level"`
	Verbose    string `short:"v" long:"verbose" description:"log level: debug、info、warn、error" default:"info"`
	Rule       string `long:"rule" description:"will only run the given single rule. The rule file may be a complete file path"`
	Zone       string `long:"zone" description:"time zone, e.g like PRC、UTC" default:"PRC"`
}

FlagOption is application run args

func (FlagOption) GetLogLevel

func (f FlagOption) GetLogLevel() log.Level

GetLogLevel can get application log level

func (FlagOption) IsDebug

func (f FlagOption) IsDebug() bool

type Rule

type Rule struct {
	UniqueId string          `yaml:"unique_id"`
	Enabled  bool            `yaml:"enabled" default:"true"`
	ES       EsConfig        `yaml:"es"`
	Index    string          `yaml:"index"`
	RunEvery xtime.TimeLimit `yaml:"run_every"`
	Query    struct {
		Type   string `yaml:"type"`
		Config struct {
			Timeframe xtime.TimeLimit `yaml:"timeframe"`
			NumEvents uint            `yaml:"num_events"`
		} `yaml:"config"`
		QueryString string            `yaml:"query_string"`
		Labels      map[string]string `yaml:"labels"`
		Annotations map[string]string `yaml:"annotations"`
	} `yaml:"query"`
	RawContent string
	FilePath   string
}

func (*Rule) GetEsAddress

func (rl *Rule) GetEsAddress() string

func (*Rule) GetMetricsOpRedisFingerprint

func (rl *Rule) GetMetricsOpRedisFingerprint(cmd string, key string, statusCode int) string

func (*Rule) GetMetricsQueryFingerprint

func (rl *Rule) GetMetricsQueryFingerprint(statusCode int) string

func (*Rule) GetQueryStringCountDSL

func (rl *Rule) GetQueryStringCountDSL(start time.Time, end time.Time) string

func (*Rule) GetQueryStringDSL

func (rl *Rule) GetQueryStringDSL(from int, size int, start time.Time, end time.Time) string

Jump to

Keyboard shortcuts

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