models

package
v5.0.0-rc7 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ALERT_RULE_ACTIVE = 0
View Source
const ALERT_RULE_DISABLED = 1
View Source
const PULL = 1
View Source
const PUSH = 0

Variables

View Source
var AliasMapper = cmap.New()

Functions

func AlertEventTotal

func AlertEventTotal(stime, etime int64, query string, status, priority int) (num int64, err error)

func AlertEventsDel

func AlertEventsDel(ids []int64) error

func AlertRuleCount

func AlertRuleCount(where string, args ...interface{}) (num int64, err error)

func AlertRuleGroupCount

func AlertRuleGroupCount(where string, args ...interface{}) (num int64, err error)

func AlertRuleGroupFavoriteAdd

func AlertRuleGroupFavoriteAdd(groupId, userId int64) error

func AlertRuleGroupFavoriteCount

func AlertRuleGroupFavoriteCount(where string, args ...interface{}) (int64, error)

func AlertRuleGroupFavoriteDel

func AlertRuleGroupFavoriteDel(groupId, userId int64) error

func AlertRuleGroupFavoriteGetGroupIds

func AlertRuleGroupFavoriteGetGroupIds(userId int64) ([]int64, error)

func AlertRuleGroupTotal

func AlertRuleGroupTotal(query string) (num int64, err error)

func AlertRuleTotal

func AlertRuleTotal(query string) (num int64, err error)

func AlertRuleUpdateAppendTags

func AlertRuleUpdateAppendTags(ids []int64, appendTags, username string) error

func AlertRuleUpdateGroup

func AlertRuleUpdateGroup(alertRuleIds []int64, groupId int64) error

func AlertRuleUpdateNotifyChannels

func AlertRuleUpdateNotifyChannels(ids []int64, notifyChannels, username string) error

func AlertRuleUpdateNotifyGroups

func AlertRuleUpdateNotifyGroups(ids []int64, notifyGroups, notifyUsers, username string) error

func AlertRuleUpdateStatus

func AlertRuleUpdateStatus(ids []int64, status int, username string) error

func AlertRulesDel

func AlertRulesDel(ids []int64) error

func BindOrphanToPresetClasspath

func BindOrphanToPresetClasspath()

如果发现资源没有在all这个classpath下,就把它加进来

func ClasspathCount

func ClasspathCount(where string, args ...interface{}) (num int64, err error)

func ClasspathFavoriteAdd

func ClasspathFavoriteAdd(ClasspathId, userId int64) error

func ClasspathFavoriteCount

func ClasspathFavoriteCount(where string, args ...interface{}) (int64, error)

func ClasspathFavoriteDel

func ClasspathFavoriteDel(classpathId int64, userId int64) error

func ClasspathFavoriteGetClasspathIds

func ClasspathFavoriteGetClasspathIds(userId int64) ([]int64, error)

func ClasspathResourceAdd

func ClasspathResourceAdd(classpathId int64, resIdent string) error

func ClasspathResourceCount

func ClasspathResourceCount(where string, args ...interface{}) (num int64, err error)

func ClasspathResourceDel

func ClasspathResourceDel(classpathId int64, idents []string) error

func ClasspathTotal

func ClasspathTotal(query string) (num int64, err error)

func CollectRuleCount

func CollectRuleCount(where string, args ...interface{}) (num int64, err error)

func CollectRulesDel

func CollectRulesDel(ids []int64) error

func ConfigsGet

func ConfigsGet(ckey string) (string, error)

func ConfigsGets

func ConfigsGets(ckeys []string) (map[string]string, error)

func ConfigsSet

func ConfigsSet(ckey, cval string) error

func CryptoPass

func CryptoPass(raw string) (string, error)

CryptoPass crypto password use salt

func DBInsertOne

func DBInsertOne(bean interface{}) error

func DashboardCount

func DashboardCount(where string, args ...interface{}) (num int64, err error)

func DashboardFavoriteAdd

func DashboardFavoriteAdd(dashboardId, userId int64) error

func DashboardFavoriteCount

func DashboardFavoriteCount(where string, args ...interface{}) (int64, error)

func DashboardFavoriteDel

func DashboardFavoriteDel(dashboardId, userId int64) error

func DashboardFavoriteGetDashboardIds

func DashboardFavoriteGetDashboardIds(userId int64) ([]int64, error)

func DashboardTotal

func DashboardTotal(onlyfavorite bool, ids []int64, query string) (num int64, err error)

func HistoryAlertEventsTotal

func HistoryAlertEventsTotal(stime, etime int64, query string, status, isRecovery, priority int) (num int64, err error)

func InitError

func InitError()

func InitLdap

func InitLdap(ldap LdapSection)

func InitMySQL

func InitMySQL(MySQL MysqlSection)

func InitRoot

func InitRoot()

func InitSalt

func InitSalt()

InitSalt generate random salt

func InstanceDelDead

func InstanceDelDead(service string, endpoints []string) error

func InstanceGetAlive

func InstanceGetAlive(service string) ([]string, error)

func InstanceGetDead

func InstanceGetDead(service string) ([]string, error)

func InstanceHeartbeat

func InstanceHeartbeat(service, endpoint string) error

func ListInsert

func ListInsert(obj Classpath, node *ClasspathNode)

func MetricDescriptionDel

func MetricDescriptionDel(ids []int64) error

func MetricDescriptionMapper

func MetricDescriptionMapper(metrics []string) (map[string]string, error)

MetricDescriptionMapper 即时看图页面,应该会用到这个方法,填充metric对应的description

func MetricDescriptionTotal

func MetricDescriptionTotal(query string) (num int64, err error)

func MetricDescriptionUpdate

func MetricDescriptionUpdate(mds []MetricDescription) error

func MuteCleanExpire

func MuteCleanExpire() error

MuteCleanExpire 这个方法应该由cron调用,所以返回error不需要是用户友好的

func MuteTotal

func MuteTotal(query string) (num int64, err error)

func ResourceAliasMapper

func ResourceAliasMapper() (map[string]string, error)

ResourceAliasMapper 返回map,key是ident,value是alias

func ResourceCleanExpire

func ResourceCleanExpire() error

func ResourceTotal

func ResourceTotal(query string) (int64, error)

ResourceTotal query resource only

func ResourceTotalByClasspathId

func ResourceTotalByClasspathId(classpathIds []int64, query string) (int64, error)

func ResourceTotalByClasspathQuery

func ResourceTotalByClasspathQuery(qpaths []int64, qres string) (int64, error)

这个sql写法很简单,只是不知道性能是否会是问题

func ResourceUpdateMute

func ResourceUpdateMute(ids []int64, btime, etime int64) error

func ResourceUpdateNote

func ResourceUpdateNote(ids []int64, note string) error

func ResourceUpdateTags

func ResourceUpdateTags(ids []int64, tags string) error

资源tags这个更新,一定要认真校验tags格式,后面会把这个tags附到监控数据里

func RoleHasOperation

func RoleHasOperation(roles []string, operation string) (bool, error)

func UpdateAlias

func UpdateAlias() error

func UserGroupCount

func UserGroupCount(where string, args ...interface{}) (num int64, err error)

func UserGroupMemberAdd

func UserGroupMemberAdd(groupId, userId int64) error

func UserGroupMemberCount

func UserGroupMemberCount(where string, args ...interface{}) (int64, error)

func UserGroupMemberDel

func UserGroupMemberDel(groupId int64, userIds []int64) error

func UserGroupTotal

func UserGroupTotal(query string) (num int64, err error)

func UserTotal

func UserTotal(query string) (num int64, err error)

Types

type AlertEvent

type AlertEvent struct {
	Id       int64  `json:"id"`
	RuleId   int64  `json:"rule_id"`
	RuleName string `json:"rule_name"`
	RuleNote string `json:"rule_note"`
	// ProcessorUid       int64             `json:"processor_uid"`
	// ProcessorObj       User              `json:"processor_user_obj" xorm:"-"`
	// EventNote          string            `json:"event_note"`
	HashId             string            `json:"hash_id"`                 // 唯一标识
	IsPromePull        int               `json:"is_prome_pull"`           // 代表是否是prometheus pull告警,为1时前端使用 ReadableExpression 拉取最近1小时数据
	LastSend           bool              `json:"last_sent" xorm:"-"`      // true 代表上次发了,false代表还没发:给prometheus做for判断的
	AlertDuration      int64             `xorm:"-" json:"alert_duration"` // 告警统计周期,PULL模型会当做P8S的for时间
	ResClasspaths      string            `json:"res_classpaths"`
	ResIdent           string            `json:"res_ident" xorm:"-"` // res_ident会出现在tags字段,就不用单独写入数据库了,但是各块逻辑中有个单独的res_ident字段更便于处理,所以struct里还留有这个字段;前端不用展示这个字段
	Priority           int               `json:"priority"`
	Status             int               `json:"status"`               // 标识是否 被屏蔽
	IsRecovery         int               `json:"is_recovery" xorm:"-"` // 0: alert, 1: recovery
	HistoryPoints      json.RawMessage   `json:"history_points"`       // HistoryPoints{}
	TriggerTime        int64             `json:"trigger_time"`
	Values             string            `json:"values" xorm:"-"` // e.g. cpu.idle: 23.3; load.1min: 32
	NotifyChannels     string            `json:"notify_channels"`
	NotifyGroups       string            `json:"notify_groups"`
	NotifyUsers        string            `json:"notify_users"`
	RunbookUrl         string            `json:"runbook_url"`
	ReadableExpression string            `json:"readable_expression"` // e.g. mem.bytes.used.percent(all,60s) > 0
	Tags               string            `json:"tags"`                // merge data_tags rule_tags and res_tags
	NotifyGroupObjs    []UserGroup       `json:"notify_group_objs" xorm:"-"`
	NotifyUserObjs     []User            `json:"notify_user_objs" xorm:"-"`
	TagMap             map[string]string `json:"tag_map" xorm:"-"`
}

func AlertEventGet

func AlertEventGet(where string, args ...interface{}) (*AlertEvent, error)

func AlertEventGetAll

func AlertEventGetAll() ([]*AlertEvent, error)

func AlertEventGets

func AlertEventGets(stime, etime int64, query string, status, priority int, limit, offset int) ([]AlertEvent, error)

func (*AlertEvent) Add

func (ae *AlertEvent) Add() error

func (*AlertEvent) Del

func (ar *AlertEvent) Del() error

func (*AlertEvent) DelByHashId

func (ar *AlertEvent) DelByHashId() error

func (*AlertEvent) FillObjs

func (ae *AlertEvent) FillObjs() error

func (*AlertEvent) GetHistoryPoints

func (ae *AlertEvent) GetHistoryPoints() ([]vos.HistoryPoints, error)

func (*AlertEvent) HashIdExists

func (ar *AlertEvent) HashIdExists() (bool, error)

func (*AlertEvent) IsAlert

func (ae *AlertEvent) IsAlert() bool

IsAlert 语法糖,避免直接拿IsRecovery字段做比对不直观易出错

func (*AlertEvent) IsRecov

func (ae *AlertEvent) IsRecov() bool

IsRecov 语法糖,避免直接拿IsRecovery字段做比对不直观易出错

func (*AlertEvent) MarkAlert

func (ae *AlertEvent) MarkAlert()

MarkAlert 语法糖,标记为告警状态

func (*AlertEvent) MarkMuted

func (ae *AlertEvent) MarkMuted()

MarkMuted 语法糖,标记为屏蔽状态

func (*AlertEvent) MarkRecov

func (ae *AlertEvent) MarkRecov()

MarkRecov 语法糖,标记为恢复状态

func (*AlertEvent) String

func (ae *AlertEvent) String() string

func (*AlertEvent) TableName

func (ae *AlertEvent) TableName() string

type AlertRule

type AlertRule struct {
	Id                 int64           `json:"id"`
	GroupId            int64           `json:"group_id"`
	Name               string          `json:"name"`
	Type               int             `json:"type"` // 0: nightingale, 1: prometheus
	Expression         json.RawMessage `json:"expression"`
	Status             int             `json:"status"` // 0: active, 1: disabled
	AppendTags         string          `json:"append_tags"`
	EnableStime        string          `json:"enable_stime"`
	EnableEtime        string          `json:"enable_etime"`
	EnableDaysOfWeek   string          `json:"enable_days_of_week"`
	RecoveryNotify     int             `json:"recovery_notify"`
	Priority           int             `json:"priority"`
	NotifyChannels     string          `json:"notify_channels"`
	NotifyGroups       string          `json:"notify_groups"`
	NotifyUsers        string          `json:"notify_users"`
	Callbacks          string          `json:"callbacks"`
	RunbookUrl         string          `json:"runbook_url"`
	Note               string          `json:"note"`
	CreateAt           int64           `json:"create_at"`
	CreateBy           string          `json:"create_by"`
	UpdateAt           int64           `json:"update_at"`
	UpdateBy           string          `json:"update_by"`
	AlertDuration      int             `json:"alert_duration"` // 告警统计周期,PULL模型会当做P8S的for时间
	PushExpr           PushExpression  `xorm:"-" json:"-"`
	PullExpr           PullExpression  `xorm:"-" json:"-"`
	FirstMetric        string          `xorm:"-" json:"-"` // Exps里可能有多个metric,只取第一个,给后续制作map使用
	NotifyUsersDetail  []*User         `xorm:"-" json:"notify_users_detail"`
	NotifyGroupsDetail []*UserGroup    `xorm:"-" json:"notify_groups_detail"`
}

func AlertRuleGet

func AlertRuleGet(where string, args ...interface{}) (*AlertRule, error)

func AlertRuleGets

func AlertRuleGets(query string, limit, offset int) ([]AlertRule, error)

func AlertRulesOfGroup

func AlertRulesOfGroup(groupId int64) ([]AlertRule, error)

func AllAlertRules

func AllAlertRules() ([]*AlertRule, error)

func (*AlertRule) Add

func (ar *AlertRule) Add() error

func (*AlertRule) Decode

func (ar *AlertRule) Decode() error

func (*AlertRule) Del

func (ar *AlertRule) Del() error

func (*AlertRule) TableName

func (ar *AlertRule) TableName() string

func (*AlertRule) Update

func (ar *AlertRule) Update(cols ...string) error

func (*AlertRule) Validate

func (ar *AlertRule) Validate() error

type AlertRuleGroup

type AlertRuleGroup struct {
	Id           int64       `json:"id"`
	Name         string      `json:"name"`
	UserGroupIds string      `json:"user_group_ids"`
	CreateAt     int64       `json:"create_at"`
	CreateBy     string      `json:"create_by"`
	UpdateAt     int64       `json:"update_at"`
	UpdateBy     string      `json:"update_by"`
	UserGroups   []UserGroup `json:"user_groups" xorm:"-"`
}

func AlertRuleGroupGet

func AlertRuleGroupGet(where string, args ...interface{}) (*AlertRuleGroup, error)

func AlertRuleGroupGets

func AlertRuleGroupGets(query string, limit, offset int) ([]AlertRuleGroup, error)

func (*AlertRuleGroup) Add

func (arg *AlertRuleGroup) Add() error

func (*AlertRuleGroup) Del

func (arg *AlertRuleGroup) Del() error

Del AlertRuleGroup删除,前提是下面没有AlertRule了

func (*AlertRuleGroup) FillUserGroups

func (arg *AlertRuleGroup) FillUserGroups() error

func (*AlertRuleGroup) TableName

func (arg *AlertRuleGroup) TableName() string

func (*AlertRuleGroup) Update

func (arg *AlertRuleGroup) Update(cols ...string) error

func (*AlertRuleGroup) Validate

func (arg *AlertRuleGroup) Validate() error

type AlertRuleGroupFavorite

type AlertRuleGroupFavorite struct {
	Id      int64
	GroupId int64
	UserId  int64
}

func (AlertRuleGroupFavorite) TableName

func (AlertRuleGroupFavorite) TableName() string

type AlertRuleStatistic

type AlertRuleStatistic struct {
	Count       int64 `json:"count"`
	MaxUpdateAt int64 `json:"max_update_at"`
}

func GetAlertRuleStatistic

func GetAlertRuleStatistic() (AlertRuleStatistic, error)

type AliasTime

type AliasTime struct {
	Alias string
	Time  int64
}

type Chart

type Chart struct {
	Id      int64  `json:"id"`
	GroupId int64  `json:"group_id"`
	Configs string `json:"configs"`
	Weight  int    `json:"weight"`
}

func ChartGet

func ChartGet(where string, args ...interface{}) (*Chart, error)

func ChartGets

func ChartGets(groupId int64) ([]Chart, error)

func (*Chart) Add

func (c *Chart) Add() error

func (*Chart) Del

func (c *Chart) Del() error

func (*Chart) TableName

func (c *Chart) TableName() string

func (*Chart) Update

func (c *Chart) Update(cols ...string) error

type ChartGroup

type ChartGroup struct {
	Id          int64  `json:"id"`
	DashboardId int64  `json:"dashboard_id"`
	Name        string `json:"name"`
	Weight      int    `json:"weight"`
}

func ChartGroupGet

func ChartGroupGet(where string, args ...interface{}) (*ChartGroup, error)

func ChartGroupGets

func ChartGroupGets(dashboardId int64) ([]ChartGroup, error)

func (*ChartGroup) Add

func (cg *ChartGroup) Add() error

func (*ChartGroup) Del

func (cg *ChartGroup) Del() error

func (*ChartGroup) TableName

func (cg *ChartGroup) TableName() string

func (*ChartGroup) Update

func (cg *ChartGroup) Update(cols ...string) error

func (*ChartGroup) Validate

func (cg *ChartGroup) Validate() error

type ChartTmp

type ChartTmp struct {
	Id       int64  `json:"id"`
	Configs  string `json:"configs"`
	CreateBy string `json:"create_by"`
	CreateAt int64  `json:"create_at"`
}

func ChartTmpGet

func ChartTmpGet(where string, args ...interface{}) (*ChartTmp, error)

func (*ChartTmp) Add

func (t *ChartTmp) Add() error

type Classpath

type Classpath struct {
	Id       int64  `json:"id"`
	Path     string `json:"path"`
	Note     string `json:"note"`
	Preset   int    `json:"preset"`
	CreateAt int64  `json:"create_at"`
	CreateBy string `json:"create_by"`
	UpdateAt int64  `json:"update_at"`
	UpdateBy string `json:"update_by"`
}

func ClasspathGet

func ClasspathGet(where string, args ...interface{}) (*Classpath, error)

func ClasspathGetAll

func ClasspathGetAll() ([]Classpath, error)

func ClasspathGets

func ClasspathGets(query string, limit, offset int) ([]Classpath, error)

func ClasspathGetsByPrefix

func ClasspathGetsByPrefix(prefix string) ([]Classpath, error)

func (*Classpath) Add

func (c *Classpath) Add() error

func (*Classpath) AddResources

func (c *Classpath) AddResources(idents []string) error

func (*Classpath) Del

func (c *Classpath) Del() error

Del classpath的删除,前提是挂载的机器、配置的采集策略都要提前删除

func (*Classpath) DelResources

func (c *Classpath) DelResources(idents []string) error

func (*Classpath) DirectChildren

func (cp *Classpath) DirectChildren() ([]Classpath, error)

func (*Classpath) TableName

func (c *Classpath) TableName() string

func (*Classpath) Update

func (c *Classpath) Update(cols ...string) error

func (*Classpath) Validate

func (c *Classpath) Validate() error

type ClasspathFavorite

type ClasspathFavorite struct {
	Id          int64
	ClasspathId int64
	UserId      int64
}

func (ClasspathFavorite) TableName

func (ClasspathFavorite) TableName() string

type ClasspathNode

type ClasspathNode struct {
	Id       int64            `json:"id"`
	Path     string           `json:"path"`
	Note     string           `json:"note"`
	Preset   int              `json:"preset"`
	Children []*ClasspathNode `json:"children"`
}

func ClasspathNodeAllChildren

func ClasspathNodeAllChildren(cps []Classpath) []*ClasspathNode

func ClasspathNodeGets

func ClasspathNodeGets(query string) ([]*ClasspathNode, error)

func ToClasspathNode

func ToClasspathNode(cp Classpath, path string) ClasspathNode

type ClasspathResource

type ClasspathResource struct {
	Id          int64
	ClasspathId int64
	ResIdent    string
}

func ClasspathResourceGetAll

func ClasspathResourceGetAll() ([]ClasspathResource, error)

func ClasspathResourceGets

func ClasspathResourceGets(where string, args ...interface{}) ([]ClasspathResource, error)

func (ClasspathResource) TableName

func (ClasspathResource) TableName() string

type CollectRule

type CollectRule struct {
	Id          int64  `json:"id"`
	ClasspathId int64  `json:"classpath_id"`
	PrefixMatch int    `json:"prefix_match"`
	Name        string `json:"name"`
	Note        string `json:"note"`
	Step        int    `json:"step"`
	Type        string `json:"type"`
	Data        string `json:"data"`
	AppendTags  string `json:"append_tags"`
	CreateAt    int64  `json:"create_at"`
	CreateBy    string `json:"create_by"`
	UpdateAt    int64  `json:"update_at"`
	UpdateBy    string `json:"update_by"`
}

func CollectRuleGet

func CollectRuleGet(where string, args ...interface{}) (*CollectRule, error)

func CollectRuleGetAll

func CollectRuleGetAll() ([]*CollectRule, error)

func CollectRuleGets

func CollectRuleGets(where string, args ...interface{}) ([]CollectRule, error)

CollectRuleGets 量不大,前端检索和排序

func (*CollectRule) Add

func (cr *CollectRule) Add() error

func (*CollectRule) Del

func (cr *CollectRule) Del() error

func (*CollectRule) TableName

func (cr *CollectRule) TableName() string

func (*CollectRule) Update

func (cr *CollectRule) Update(cols ...string) error

func (*CollectRule) Validate

func (cr *CollectRule) Validate() error

type Configs

type Configs struct {
	Id   int64
	Ckey string
	Cval string
}

type Dashboard

type Dashboard struct {
	Id       int64  `json:"id"`
	Name     string `json:"name"`
	Tags     string `json:"tags"`
	Configs  string `json:"configs"`
	Favorite int    `json:"favorite" xorm:"-"`
	CreateAt int64  `json:"create_at"`
	CreateBy string `json:"create_by"`
	UpdateAt int64  `json:"update_at"`
	UpdateBy string `json:"update_by"`
}

func DashboardGet

func DashboardGet(where string, args ...interface{}) (*Dashboard, error)

func DashboardGets

func DashboardGets(onlyfavorite bool, ids []int64, query string, limit, offset int) ([]Dashboard, error)

func DashboardGetsByIds

func DashboardGetsByIds(ids []int64) ([]*Dashboard, error)

func (*Dashboard) Add

func (d *Dashboard) Add() error

func (*Dashboard) AddOnly

func (d *Dashboard) AddOnly() error

func (*Dashboard) Del

func (d *Dashboard) Del() error

func (*Dashboard) FillFavorite

func (d *Dashboard) FillFavorite(ids []int64)

func (*Dashboard) TableName

func (d *Dashboard) TableName() string

func (*Dashboard) Update

func (d *Dashboard) Update(cols ...string) error

func (*Dashboard) Validate

func (d *Dashboard) Validate() error

type DashboardFavorite

type DashboardFavorite struct {
	Id          int64
	DashboardId int64
	UserId      int64
}

func (DashboardFavorite) TableName

func (DashboardFavorite) TableName() string

type Exp

type Exp struct {
	Optr      string  `json:"optr"`      //>,<,=,!=
	Func      string  `json:"func"`      //all,max,min
	Metric    string  `json:"metric"`    //metric
	Params    []int   `json:"params"`    //连续n秒
	Threshold float64 `json:"threshold"` //阈值
}

type HistoryAlertEvent

type HistoryAlertEvent struct {
	Id       int64  `json:"id"`
	RuleId   int64  `json:"rule_id"`
	RuleName string `json:"rule_name"`
	RuleNote string `json:"rule_note"`
	//ProcessorUid       int64           `json:"processor_uid"`
	//ProcessorObj       User            `json:"processor_user_objs" xorm:""`
	//EventNote          string          `json:"event_note"`
	HashId             string          `json:"hash_id"`       // 唯一标识
	IsPromePull        int             `json:"is_prome_pull"` // 代表是否是prometheus pull告警,为1时前端使用 ReadableExpression 拉取最近1小时数据
	ResClasspaths      string          `json:"res_classpaths"`
	ResIdent           string          `json:"res_ident" xorm:"-"` // res_ident会出现在tags字段,就不用单独写入数据库了,但是各块逻辑中有个单独的res_ident字段更便于处理,所以struct里还留有这个字段;前端不用展示这个字段
	Priority           int             `json:"priority"`
	Status             int             `json:"status"`         // 标识是否 被屏蔽
	IsRecovery         int             `json:"is_recovery"`    // 0: alert, 1: recovery
	HistoryPoints      json.RawMessage `json:"history_points"` // HistoryPoints{}
	TriggerTime        int64           `json:"trigger_time"`
	Values             string          `json:"values" xorm:"-"` // e.g. cpu.idle: 23.3; load.1min: 32
	NotifyChannels     string          `json:"notify_channels"`
	NotifyGroups       string          `json:"notify_groups"`
	NotifyUsers        string          `json:"notify_users"`
	RunbookUrl         string          `json:"runbook_url"`
	ReadableExpression string          `json:"readable_expression"` // e.g. mem.bytes.used.percent(all,60s) > 0
	Tags               string          `json:"tags"`                // merge data_tags rule_tags and res_tags
	NotifyGroupObjs    []UserGroup     `json:"notify_group_objs" xorm:"-"`
	NotifyUserObjs     []User          `json:"notify_user_objs" xorm:"-"`
}

func HistoryAlertEventGet

func HistoryAlertEventGet(where string, args ...interface{}) (*HistoryAlertEvent, error)

func HistoryAlertEventGets

func HistoryAlertEventGets(stime, etime int64, query string, status, isRecovery, priority int, limit, offset int) ([]HistoryAlertEvent, error)

func (*HistoryAlertEvent) Add

func (hae *HistoryAlertEvent) Add() error

func (*HistoryAlertEvent) FillObjs

func (hae *HistoryAlertEvent) FillObjs() error

func (*HistoryAlertEvent) IsAlert

func (hae *HistoryAlertEvent) IsAlert() bool

IsAlert 语法糖,避免直接拿IsRecovery字段做比对不直观易出错

func (*HistoryAlertEvent) IsRecov

func (hae *HistoryAlertEvent) IsRecov() bool

IsRecov 语法糖,避免直接拿IsRecovery字段做比对不直观易出错

func (*HistoryAlertEvent) MarkAlert

func (hae *HistoryAlertEvent) MarkAlert()

MarkAlert 语法糖,标记为告警状态

func (*HistoryAlertEvent) MarkMuted

func (hae *HistoryAlertEvent) MarkMuted()

MarkMuted 语法糖,标记为屏蔽状态

func (*HistoryAlertEvent) MarkRecov

func (hae *HistoryAlertEvent) MarkRecov()

MarkRecov 语法糖,标记为恢复状态

type Instance

type Instance struct {
	Service  string
	Endpoint string
	Clock    time.Time
}

type LdapSection

type LdapSection struct {
	Enable          bool           `yaml:"enable"`
	Host            string         `yaml:"host"`
	Port            int            `yaml:"port"`
	BaseDn          string         `yaml:"baseDn"`
	BindUser        string         `yaml:"bindUser"`
	BindPass        string         `yaml:"bindPass"`
	AuthFilter      string         `yaml:"authFilter"`
	Attributes      ldapAttributes `yaml:"attributes"`
	CoverAttributes bool           `yaml:"coverAttributes"`
	TLS             bool           `yaml:"tls"`
	StartTLS        bool           `yaml:"startTLS"`
}
var LDAP LdapSection

type LogConfig

type LogConfig struct {
	FilePath    string            `json:"file_path"`
	Func        string            `json:"func"`
	Pattern     string            `json:"pattern"`
	TagsPattern map[string]string `json:"tags_pattern"`
}

type MetricDescription

type MetricDescription struct {
	Id          int64  `json:"id"`
	Metric      string `json:"metric"`
	Description string `json:"description"`
}

func MetricDescriptionGet

func MetricDescriptionGet(where string, args ...interface{}) (*MetricDescription, error)

func MetricDescriptionGetAll

func MetricDescriptionGetAll() ([]MetricDescription, error)

func MetricDescriptionGets

func MetricDescriptionGets(query string, limit, offset int) ([]MetricDescription, error)

func (*MetricDescription) TableName

func (md *MetricDescription) TableName() string

func (*MetricDescription) Update

func (md *MetricDescription) Update(cols ...string) error

type Mute

type Mute struct {
	Id              int64             `json:"id"`
	ClasspathPrefix string            `json:"classpath_prefix"`
	Metric          string            `json:"metric"`
	ResFilters      string            `json:"res_filters"`
	TagFilters      string            `json:"tags_filters"`
	Cause           string            `json:"cause"`
	Btime           int64             `json:"btime"`
	Etime           int64             `json:"etime"`
	CreateBy        string            `json:"create_by"`
	CreateAt        int64             `json:"create_at"`
	ResRegexp       *regexp.Regexp    `xorm:"-" json:"-"`
	TagsMap         map[string]string `xorm:"-" json:"-"`
}

func MuteGet

func MuteGet(where string, args ...interface{}) (*Mute, error)

func MuteGets

func MuteGets(query string, limit, offset int) ([]Mute, error)

func MuteGetsAll

func MuteGetsAll() ([]Mute, error)

func (*Mute) Add

func (m *Mute) Add() error

func (*Mute) Del

func (m *Mute) Del() error

func (*Mute) Parse

func (m *Mute) Parse() error

func (*Mute) TableName

func (m *Mute) TableName() string

func (*Mute) Validate

func (m *Mute) Validate() error

type MysqlSection

type MysqlSection struct {
	Addr  string `yaml:"addr"`
	Max   int    `yaml:"max"`
	Idle  int    `yaml:"idle"`
	Debug bool   `yaml:"debug"`
}
var MySQL MysqlSection

type PortConfig

type PortConfig struct {
	Port     int    `json:"port"`
	Protocol string `json:"protocol"` // tcp or udp
	Timeout  int    `json:"timeout"`  // second
}

type ProcConfig

type ProcConfig struct {
	Method string `json:"method"`
	Param  string `json:"param"`
}

type PullExpression

type PullExpression struct {
	PromQl             string `json:"promql"`              // promql 最终表达式
	EvaluationInterval int    `json:"evaluation_interval"` // promql pull 计算周期
}

type PushExpression

type PushExpression struct {
	TagFilters    []TagFilter `json:"tags_filters"`
	ResFilters    []ResFilter `json:"res_filters"`
	Exps          []Exp       `json:"trigger_conditions"`
	TogetherOrAny int         `json:"together_or_any"` // 所有触发还是触发一条即可,=0所有 =1一条
}

type ResFilter

type ResFilter struct {
	Func string `json:"func"`
	// * InClasspath -> 可以内存里做个大map,host->classpath,然后看host对应的classpath中是否有某一个满足InClasspath的条件
	// * NotInClasspath
	// * InClasspathPrefix -> 可以内存里做个大map,host->classpath,然后看host对应的classpath中是否有某一个满足InClasspathPrefix的条件
	// * NotInClasspathPrefix
	// * InResourceList
	// * NotInResourceList
	// * HasPrefixString
	// * NoPrefixString
	// * HasSuffixString
	// * NoSuffixString
	// * ContainsString
	// * NotContainsString
	// * MatchRegexp
	// * NotMatchRegexp
	Params []string `json:"params"`
}

type Resource

type Resource struct {
	Id           int64   `json:"id"`
	Ident        string  `json:"ident"`
	Alias        string  `json:"alias"`
	Tags         string  `json:"tags"`
	Note         string  `json:"note"`
	MuteBtime    int64   `json:"mute_btime"`
	MuteEtime    int64   `json:"mute_etime"`
	ClasspathIds []int64 `xorm:"-" json:"classpath_ids"`
}

func ResourceGet

func ResourceGet(where string, args ...interface{}) (*Resource, error)

func ResourceGetAll

func ResourceGetAll() ([]Resource, error)

func ResourceGets

func ResourceGets(query string, limit, offset int) ([]Resource, error)

ResourceGets query resource only

func ResourceGetsByClasspathId

func ResourceGetsByClasspathId(classpathIds []int64, query string, limit, offset int) ([]Resource, error)

func ResourceGetsByClasspathQuery

func ResourceGetsByClasspathQuery(qpaths []int64, qres string, limit, offset int) ([]Resource, error)

func (*Resource) Del

func (r *Resource) Del() error

type Role

type Role struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`
	Note string `json:"note"`
}

func RoleGets

func RoleGets(where string, args ...interface{}) ([]Role, error)

func RoleGetsAll

func RoleGetsAll() ([]Role, error)

func (Role) TableName

func (Role) TableName() string

type RoleOperation

type RoleOperation struct {
	RoleName  string
	Operation string
}

func (RoleOperation) TableName

func (RoleOperation) TableName() string

type ScriptConfig

type ScriptConfig struct {
	Path    string            `json:"path"`
	Params  string            `json:"params"`
	Stdin   string            `json:"stdin"`
	Env     map[string]string `json:"env"`
	Timeout int               `json:"timeout"` // second
}

type TagFilter

type TagFilter struct {
	Key  string `json:"key"`
	Func string `json:"func"`
	// * InList
	// * NotInList
	// * HasPrefixString
	// * NoPrefixString
	// * HasSuffixString
	// * NoSuffixString
	// * ContainsString
	// * NotContainsString
	// * MatchRegexp
	// * NotMatchRegexp
	Params []string `json:"params"`
}

type User

type User struct {
	Id         int64           `json:"id"`
	Username   string          `json:"username"`
	Nickname   string          `json:"nickname"`
	Password   string          `json:"-"`
	Phone      string          `json:"phone"`
	Email      string          `json:"email"`
	Portrait   string          `json:"portrait"`
	Status     int             `json:"status"`
	RolesForDB string          `json:"-" xorm:"'roles'"` // 这个字段写入数据库
	RolesForFE []string        `json:"roles" xorm:"-"`   // 这个字段和前端交互
	Contacts   json.RawMessage `json:"contacts"`         // 内容为 map[string]string 结构
	CreateAt   int64           `json:"create_at"`
	CreateBy   string          `json:"create_by"`
	UpdateAt   int64           `json:"update_at"`
	UpdateBy   string          `json:"update_by"`
}

func LdapLogin

func LdapLogin(username, pass string) (*User, error)

func PassLogin

func PassLogin(username, pass string) (*User, error)

func UserGet

func UserGet(where string, args ...interface{}) (*User, error)

func UserGetAll

func UserGetAll() ([]User, error)

func UserGetById

func UserGetById(id int64) (*User, error)

func UserGetByUsername

func UserGetByUsername(username string) (*User, error)

func UserGets

func UserGets(query string, limit, offset int) ([]User, error)

func UserGetsByIds

func UserGetsByIds(ids []int64) ([]User, error)

func UserGetsByIdsStr

func UserGetsByIdsStr(ids []string) ([]User, error)

func (*User) Add

func (u *User) Add() error

func (*User) CanDo

func (u *User) CanDo(op string) (bool, error)

func (*User) CanModifyUserGroup

func (u *User) CanModifyUserGroup(ug *UserGroup) (bool, error)

func (*User) ChangePassword

func (u *User) ChangePassword(oldpass, newpass string) error

func (*User) Del

func (u *User) Del() error

func (*User) FavoriteAlertRuleGroupIds

func (u *User) FavoriteAlertRuleGroupIds() ([]int64, error)

func (*User) FavoriteAlertRuleGroups

func (u *User) FavoriteAlertRuleGroups() ([]AlertRuleGroup, error)

func (*User) FavoriteClasspathIds

func (u *User) FavoriteClasspathIds() ([]int64, error)

func (*User) FavoriteClasspaths

func (u *User) FavoriteClasspaths() ([]Classpath, error)

func (*User) FavoriteDashboardIds

func (u *User) FavoriteDashboardIds() ([]int64, error)

func (*User) MustPerm

func (u *User) MustPerm(op string) *User

MustPerm return *User for link program

func (*User) MyUserGroups

func (u *User) MyUserGroups() ([]UserGroup, error)

func (*User) TableName

func (u *User) TableName() string

func (*User) Update

func (u *User) Update(cols ...string) error

func (*User) UserGroupIds

func (u *User) UserGroupIds() ([]int64, error)

UserGroupIds 我是成员的用户组ID列表

func (*User) Validate

func (u *User) Validate() error

type UserGroup

type UserGroup struct {
	Id       int64  `json:"id"`
	Name     string `json:"name"`
	Note     string `json:"note"`
	CreateAt int64  `json:"create_at"`
	CreateBy string `json:"create_by"`
	UpdateAt int64  `json:"update_at"`
	UpdateBy string `json:"update_by"`
}

func UserGroupGet

func UserGroupGet(where string, args ...interface{}) (*UserGroup, error)

func UserGroupGetAll

func UserGroupGetAll() ([]UserGroup, error)

func UserGroupGets

func UserGroupGets(query string, limit, offset int) ([]UserGroup, error)

func UserGroupGetsByIdsStr

func UserGroupGetsByIdsStr(ids []string) ([]UserGroup, error)

func (*UserGroup) Add

func (ug *UserGroup) Add() error

func (*UserGroup) AddMembers

func (ug *UserGroup) AddMembers(userIds []int64) error

func (*UserGroup) Del

func (ug *UserGroup) Del() error

func (*UserGroup) DelMembers

func (ug *UserGroup) DelMembers(userIds []int64) error

func (*UserGroup) MemberIds

func (ug *UserGroup) MemberIds() ([]int64, error)

func (*UserGroup) TableName

func (ug *UserGroup) TableName() string

func (*UserGroup) Update

func (ug *UserGroup) Update(cols ...string) error

func (*UserGroup) Validate

func (ug *UserGroup) Validate() error

type UserGroupMember

type UserGroupMember struct {
	GroupId int64
	UserId  int64
}

func UserGroupMemberGetAll

func UserGroupMemberGetAll() ([]UserGroupMember, error)

func (UserGroupMember) TableName

func (UserGroupMember) TableName() string

type UserToken

type UserToken struct {
	UserId   int64  `json:"user_id"`
	Username string `json:"username"`
	Token    string `json:"token"`
}

func UserTokenGet

func UserTokenGet(where string, args ...interface{}) (*UserToken, error)

func UserTokenGets

func UserTokenGets(where string, args ...interface{}) ([]UserToken, error)

func UserTokenNew

func UserTokenNew(userId int64, username string) (*UserToken, error)

func UserTokenReset

func UserTokenReset(userId int64, token string) (*UserToken, error)

func (UserToken) TableName

func (UserToken) TableName() string

Jump to

Keyboard shortcuts

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