controller

package
v0.0.0-...-c229084 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAgentController

func NewAgentController(cc container.Container) web.Controller

func NewAuditController

func NewAuditController(cc container.Container) web.Controller

func NewDingdingRobotController

func NewDingdingRobotController(cc container.Container) web.Controller

func NewEventController

func NewEventController(cc container.Container) web.Controller

func NewGroupController

func NewGroupController(cc container.Container) web.Controller

func NewJiraController

func NewJiraController(cc container.Container) web.Controller

func NewPublicController

func NewPublicController(cc container.Container) web.Controller

func NewQueueController

func NewQueueController(cc container.Container) web.Controller

func NewRuleController

func NewRuleController(cc container.Container) web.Controller

func NewStatisticsController

func NewStatisticsController(cc container.Container) web.Controller

NewStatisticsController create a new StatisticsController

func NewTemplateController

func NewTemplateController(cc container.Container) web.Controller

func NewUserController

func NewUserController(cc container.Container) web.Controller

func NewWelcomeController

func NewWelcomeController(cc container.Container) web.Controller

Types

type AgentController

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

func (AgentController) All

func (AgentController) Register

func (c AgentController) Register(router *web.Router)

func (AgentController) Remove

func (c AgentController) Remove(req web.Request, repo repository.AgentRepo) error

type AgentResp

type AgentResp struct {
	repository.Agent
	Alive bool `json:"alive"`
}

type AggCount

type AggCount struct {
	AggregateKey  string `json:"aggregate_key"`
	Total         int64  `json:"total"`
	TotalMessages int64  `json:"total_messages"`
}

AggCount 聚合key包含的事件组数量

type AuditController

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

func (AuditController) Logs

func (AuditController) Register

func (u AuditController) Register(router *web.Router)

type DingdingRobotController

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

func (DingdingRobotController) Add

func (DingdingRobotController) Delete

func (DingdingRobotController) DingdingRobot

func (DingdingRobotController) DingdingRobotNames

DingdingRobotNames return all robot names only

func (DingdingRobotController) DingdingRobots

func (u DingdingRobotController) DingdingRobots(ctx web.Context, robotRepo repository.DingdingRobotRepo) web.Response

func (DingdingRobotController) Register

func (u DingdingRobotController) Register(router *web.Router)

func (DingdingRobotController) Update

type DingdingRobotForm

type DingdingRobotForm struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Token       string `json:"token"`
	Secret      string `json:"secret"`
}

func (*DingdingRobotForm) Validate

func (robotForm *DingdingRobotForm) Validate(req web.Request) error

type DingdingRobotNameResp

type DingdingRobotNameResp struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type EvalSampleReq

type EvalSampleReq struct {
	EventSample extension.CommonEvent `json:"event_sample"`
	EventID     string                `json:"event_id"`
	Expression  string                `json:"expression"`
}

type EventByDatetimeCount

type EventByDatetimeCount struct {
	Datetime string `json:"datetime"`
	Total    int64  `json:"total"`
}

EventByDatetimeCount 周期内事件数量统计返回对象

type EventController

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

func (*EventController) AddCommonEvent

func (m *EventController) AddCommonEvent(ctx web.Context, eventService service.EventService) web.Response

func (*EventController) AddEventRelationNote

func (m *EventController) AddEventRelationNote(ctx web.Context, evtRelationNoteRepo repository.EventRelationNoteRepo) web.Response

AddEventRelationNote 添加事件关联备注

func (*EventController) AddGrafanaEvent

func (m *EventController) AddGrafanaEvent(ctx web.Context, eventService service.EventService) web.Response

AddGrafanaEvent Add grafana message

func (*EventController) AddLogstashEvent

func (m *EventController) AddLogstashEvent(ctx web.Context, eventService service.EventService) web.Response

AddLogstashEvent Add logstash message

func (*EventController) AddOpenFalconEvent

func (m *EventController) AddOpenFalconEvent(ctx web.Context, eventService service.EventService) web.Response

add open-falcon message

func (*EventController) AddPrometheusAlertEvent

func (m *EventController) AddPrometheusAlertEvent(ctx web.Context, eventService service.EventService) web.Response

AddPrometheusAlertEvent add prometheus-alert message

func (*EventController) AddPrometheusEvent

func (m *EventController) AddPrometheusEvent(ctx web.Context, eventService service.EventService) web.Response

AddPrometheusEvent add prometheus alert message

func (*EventController) Count

func (m *EventController) Count(ctx web.Context, evtRepo repository.EventRepo) web.Response

Count return message count for your conditions

func (*EventController) DeleteEvent

func (m *EventController) DeleteEvent(ctx web.Context, evtRepo repository.EventRepo) web.Response

DeleteEvent 删除事件

func (*EventController) Event

func (m *EventController) Event(ctx web.Context, eventRepo repository.EventRepo) (*repository.Event, error)

Event return one message

func (*EventController) Events

func (m *EventController) Events(ctx web.Context, evtRepo repository.EventRepo) (*EventsResp, error)

Events return all messages

func (*EventController) QueryEventRelation

func (m *EventController) QueryEventRelation(ctx web.Context, evtRelationRepo repository.EventRelationRepo) (*repository.EventRelation, error)

QueryEventRelation 查询事件关联

func (*EventController) QueryEventRelationNotes

func (m *EventController) QueryEventRelationNotes(ctx web.Context, evtRelationNoteRepo repository.EventRelationNoteRepo) (*EventRelationNotesResp, error)

QueryEventRelationNotes 查询事件关联的备注

func (*EventController) Register

func (m *EventController) Register(router *web.Router)

func (*EventController) ReproduceEvent

func (m *EventController) ReproduceEvent(ctx web.Context, eventRepo repository.EventRepo, eventService service.EventService) web.Response

func (*EventController) TestMatchedRules

func (m *EventController) TestMatchedRules(ctx web.Context, msgRepo repository.EventRepo, ruleRepo repository.RuleRepo) ([]job.MatchedRule, error)

TestMatchedRules 测试 message 匹配哪些规则

type EventGroupAggByDatetimeCount

type EventGroupAggByDatetimeCount struct {
	Datetime string     `json:"datetime"`
	AggCount []AggCount `json:"agg_count"`
}

EventGroupAggByDatetimeCount 时间范围内事件组聚合数量

type EventGroupAggByDatetimeCountResp

type EventGroupAggByDatetimeCountResp struct {
	Data          []EventGroupAggByDatetimeCount `json:"data"`
	AggregateKeys []string                       `json:"aggregate_keys"`
}

type EventGroupByRuleCounts

type EventGroupByRuleCounts []repository.EventGroupByRuleCount

func (EventGroupByRuleCounts) Len

func (e EventGroupByRuleCounts) Len() int

func (EventGroupByRuleCounts) Less

func (e EventGroupByRuleCounts) Less(i, j int) bool

func (EventGroupByRuleCounts) Swap

func (e EventGroupByRuleCounts) Swap(i, j int)

type EventGroupByUserCounts

type EventGroupByUserCounts []repository.EventGroupByUserCount

func (EventGroupByUserCounts) Len

func (e EventGroupByUserCounts) Len() int

func (EventGroupByUserCounts) Less

func (e EventGroupByUserCounts) Less(i, j int) bool

func (EventGroupByUserCounts) Swap

func (e EventGroupByUserCounts) Swap(i, j int)

type EventRelationNotesResp

type EventRelationNotesResp struct {
	Notes []repository.EventRelationNote `json:"notes"`
	Next  int64                          `json:"next"`
}

EventRelationNotesResp 事件关联备注响应对象

type EventSearch

type EventSearch struct {
	Tags    []string `json:"tags"`
	Meta    string   `json:"meta"`
	Status  []string `json:"status"`
	Origin  string   `json:"origin"`
	GroupID string   `json:"group_id"`
}

EventSearch is search conditions for messages

type EventsResp

type EventsResp struct {
	Events []repository.Event `json:"events"`
	Next   int64              `json:"next"`
	Search EventSearch        `json:"search"`
}

EventsResp is a response object for Events API

type GroupController

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

func (GroupController) CutGroupEvents

func (g GroupController) CutGroupEvents(webCtx web.Context, evtGrpRepo repository.EventGroupRepo, evtGroupSvc service.EventGroupService, em event.Manager) web.Response

CutGroupEvents 缩减事件组中包含的事件,对已经完成聚合的事件组有效, 该操作不会影响事件组上对事件总数的计数

func (GroupController) Group

func (g GroupController) Group(
	ctx web.Context,
	groupRepo repository.EventGroupRepo,
	eventRepo repository.EventRepo,
) (*GroupResp, error)

func (GroupController) Groups

func (g GroupController) Groups(ctx web.Context, groupRepo repository.EventGroupRepo, userRepo repository.UserRepo) (*GroupsResp, error)

Groups list all event groups Arguments:

  • offset/limit
  • status
  • rule_id
  • user_id

func (GroupController) RecoverableGroups

func (g GroupController) RecoverableGroups(recoveryRepo repository.RecoveryRepo) ([]repository.Recovery, error)

RecoverableGroups 当前待恢复的报警组

func (GroupController) Register

func (g GroupController) Register(router *web.Router)

type GroupResp

type GroupResp struct {
	Group  repository.EventGroup `json:"group"`
	Events []repository.Event    `json:"events"`
	Next   int64                 `json:"next"`
}

type GroupsGroupResp

type GroupsGroupResp struct {
	repository.EventGroup
	CollectTimeRemain int64 `json:"collect_time_remain"`
}

type GroupsResp

type GroupsResp struct {
	Groups []GroupsGroupResp `json:"groups"`
	Users  map[string]string `json:"users"`
	Next   int64             `json:"next"`
}

type JiraController

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

func (JiraController) CustomFields

func (j JiraController) CustomFields(webCtx web.Context, conf *configs.Config) web.Response

func (JiraController) IssueOptions

func (j JiraController) IssueOptions(webCtx web.Context, conf *configs.Config) web.Response

func (JiraController) IssueTypes

func (j JiraController) IssueTypes(webCtx web.Context, conf *configs.Config) web.Response

func (JiraController) Priorities

func (j JiraController) Priorities(webCtx web.Context, conf *configs.Config) web.Response

func (JiraController) Register

func (j JiraController) Register(router *web.Router)

type MessageGroupByDatetimeCount

type MessageGroupByDatetimeCount struct {
	Datetime      string `json:"datetime"`
	Total         int64  `json:"total"`
	TotalMessages int64  `json:"total_messages"`
}

MessageGroupByDatetimeCount 周期内事件组数量

type PublicController

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

func (PublicController) Group

Group 分组展示

func (PublicController) Register

func (p PublicController) Register(router *web.Router)

func (PublicController) Reports

func (p PublicController) Reports(ctx web.Context, groupRepo repository.EventGroupRepo, msgRepo repository.EventRepo, templateRepo repository.TemplateRepo) web.Response

Reports 报表展示

type QueueController

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

func (*QueueController) Control

func (q *QueueController) Control(ctx web.Context, manager queue.Manager) web.Response

Control controls the queue behaviors Args: op=pause/container/info

func (*QueueController) Delete

func (q *QueueController) Delete(ctx web.Context, repo repository.QueueRepo) error

func (*QueueController) Job

func (*QueueController) Jobs

func (*QueueController) Register

func (q *QueueController) Register(router *web.Router)

type QueueJob

type QueueJob struct {
	repository.QueueJob
	ExecuteTimeRemain int64 `json:"execute_time_remain"`
}

type QueueJobsResp

type QueueJobsResp struct {
	Jobs []QueueJob `json:"jobs"`
	Next int64      `json:"next"`
}

type RuleController

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

func (RuleController) Add

Add create a new rule

func (RuleController) Check

func (r RuleController) Check(ctx web.Context, conf *configs.Config, msgRepo repository.EventRepo) web.Response

Check validate the rule

func (RuleController) Delete

func (r RuleController) Delete(ctx web.Context, em event.Manager, repo repository.RuleRepo) error

Delete delete a rule

func (RuleController) EvaluateExpressionSample

func (r RuleController) EvaluateExpressionSample(ctx web.Context) web.Response

func (RuleController) MessageSample

func (r RuleController) MessageSample(ctx web.Context, groupRepo repository.EventGroupRepo, msgRepo repository.EventRepo) (*repository.Event, error)

MessageSample 根据规则id查询一个匹配的消息样本

func (RuleController) Register

func (r RuleController) Register(router *web.Router)

func (RuleController) Rule

func (r RuleController) Rule(ctx web.Context, ruleRepo repository.RuleRepo) (*repository.Rule, error)

Rule return one rule

func (RuleController) Rules

func (r RuleController) Rules(ctx web.Context, ruleRepo repository.RuleRepo, userRepo repository.UserRepo) (*RulesResp, error)

Rules return all rules

func (RuleController) Tags

Tags return all tags existed

func (RuleController) Update

func (r RuleController) Update(ctx web.Context, ruleRepo repository.RuleRepo, em event.Manager, manager action.Manager) (*repository.Rule, error)

Update replace one rule for specified id

type RuleForm

type RuleForm struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Tags        []string `json:"tags"`

	AggregateRule string `json:"aggregate_rule"`
	RelationRule  string `json:"relation_rule"`

	ReadyType        string                 `json:"ready_type"`
	Interval         int64                  `json:"interval"`
	DailyTimes       []string               `json:"daily_times"`
	TimeRanges       []repository.TimeRange `json:"time_ranges"`
	RealtimeInterval int64                  `json:"realtime_interval"`

	Rule             string            `json:"rule"`
	IgnoreRule       string            `json:"ignore_rule"`
	Template         string            `json:"template"`
	SummaryTemplate  string            `json:"summary_template"`
	ReportTemplateID string            `json:"report_template_id"`
	Triggers         []RuleTriggerForm `json:"triggers"`

	Status string `json:"status"`
	// contains filtered or unexported fields
}

RuleForm is a form object using create or update rule

func (RuleForm) Validate

func (r RuleForm) Validate(req web.Request) error

Validate implement web.Validator interface

type RuleSearch

type RuleSearch struct {
	Name   string `json:"name"`
	Status string `json:"status"`
	UserID string `json:"user_id"`
}

type RuleTriggerForm

type RuleTriggerForm struct {
	ID            string   `json:"id"`
	Name          string   `json:"name"`
	IsElseTrigger bool     `json:"is_else_trigger"`
	PreCondition  string   `json:"pre_condition"`
	Action        string   `json:"action"`
	Meta          string   `json:"meta"`
	UserRefs      []string `json:"user_refs"`
}

RuleTriggerForm is a form object using to hold a trigger

type RulesResp

type RulesResp struct {
	Rules []repository.Rule `json:"rules"`
	Users map[string]string `json:"users"`

	Next   int64      `json:"next"`
	Search RuleSearch `json:"search"`
}

type StatisticsController

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

StatisticsController 统计功能

func (StatisticsController) DailyGroupCounts

DailyGroupCounts 每日报警次数汇总

func (StatisticsController) EventCountInPeriod

func (s StatisticsController) EventCountInPeriod(webCtx web.Context, evtRepo repository.EventRepo) ([]EventByDatetimeCount, error)

EventCountInPeriod 统计周期内的事件数量 支持的参数: days/step/format/meta/tags/origin/status/relation_id/group_id/event_id

func (StatisticsController) EventGroupAggCounts

func (s StatisticsController) EventGroupAggCounts(webCtx web.Context, evtGrpRepo repository.EventGroupRepo) ([]repository.EventGroupAggCount, error)

EventGroupAggCounts 事件组聚合Key数量统计 参数 rule_id

func (StatisticsController) EventGroupAggInPeriod

func (s StatisticsController) EventGroupAggInPeriod(webCtx web.Context, evtGrpRepo repository.EventGroupRepo) (EventGroupAggByDatetimeCountResp, error)

EventCountInPeriod 统计周期内的事件组数量,按照聚合key分类返回 支持的参数: rule_id

func (StatisticsController) Register

func (s StatisticsController) Register(router *web.Router)

Register 注册路由

func (StatisticsController) RuleGroupCounts

RuleGroupCounts 报警规则报警次数汇总

func (StatisticsController) UserGroupCounts

UserGroupCounts 用户报警次数汇总

type TemplateController

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

func (*TemplateController) Add

func (*TemplateController) Delete

func (*TemplateController) Get

func (*TemplateController) Register

func (t *TemplateController) Register(router *web.Router)

func (*TemplateController) Templates

func (*TemplateController) Update

type TemplateForm

type TemplateForm struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Content     string `json:"content"`
	Type        string `json:"type"`
}

func (TemplateForm) Validate

func (t TemplateForm) Validate(req web.Request) error

type UserController

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

func (UserController) Add

func (UserController) Delete

func (u UserController) Delete(ctx web.Context, userRepo repository.UserRepo, em event.Manager) error

func (UserController) Register

func (u UserController) Register(router *web.Router)

func (UserController) Update

func (u UserController) Update(ctx web.Context, userRepo repository.UserRepo, em event.Manager) (*repository.User, error)

func (UserController) User

func (u UserController) User(ctx web.Context, userRepo repository.UserRepo) (*repository.User, error)

func (UserController) UserNames

func (u UserController) UserNames(ctx web.Context, userRepo repository.UserRepo) ([]UserNameResp, error)

UserNames return all user names only

func (UserController) Users

func (u UserController) Users(ctx web.Context, userRepo repository.UserRepo) web.Response

type UserForm

type UserForm struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Phone string `json:"phone"`

	Password string `json:"password"`
	Role     string `json:"role"`

	Metas  []repository.UserMeta `json:"metas"`
	Status string                `json:"status"`
	// contains filtered or unexported fields
}

func (*UserForm) GetMetas

func (userForm *UserForm) GetMetas() []repository.UserMeta

func (*UserForm) Init

func (userForm *UserForm) Init(repo repository.UserRepo, update bool)

func (*UserForm) Validate

func (userForm *UserForm) Validate(req web.Request) error

type UserNameResp

type UserNameResp struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type WelcomeController

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

func (*WelcomeController) Home

Home 欢迎页面,API版本信息 @Summary 欢迎页面,API版本信息 @Success 200 {object} controller.WelcomeMessage @Router / [get]

func (*WelcomeController) Register

func (w *WelcomeController) Register(router *web.Router)

type WelcomeMessage

type WelcomeMessage struct {
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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