types

package
v0.0.0-...-9970c52 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToModel

func ConvertToModel(tenantKey string, a *Alert, channelID int) (*model.AlertHistory, error)

辅助函数:将业务 Alert 转换为 DB Model

func NewApi

func NewApi(req *ApiCreateRequest) *model.Api

Types

type AggregationSendResult

type AggregationSendResult struct {
	FiringErr   error
	ResolvedErr error
}

AggregationSendResult 代表批量发送的结果,包含发送错误信息和对应的告警列表

type Alert

type Alert struct {
	Status       string            `json:"status"` // "firing" or "resolved"
	Labels       map[string]string `json:"labels"`
	Annotations  map[string]string `json:"annotations"`
	StartsAt     time.Time         `json:"startsAt"`
	EndsAt       *time.Time        `json:"endsAt"`
	GeneratorURL string            `json:"generatorURL"`
	Fingerprint  string            `json:"fingerprint"`
	IsSilenced   bool              `json:"isSilenced"`
	SilenceID    int               `json:"silenceID"`
}

Alert 代表单条告警的详情

type AlertArry

type AlertArry struct {
	FiringAlertArry   []*Alert
	ResolvedAlertArry []*Alert
}

type AlertChannelCreateRequest

type AlertChannelCreateRequest struct {
	Name              string         `json:"name" binding:"required,max=15"`
	Type              string         `json:"type" binding:"required,oneof=feishuApp feishuBoot webhook"`
	Status            *int           `json:"status" binding:"required,oneof=0 1"`
	AggregationStatus *int           `json:"aggregationStatus" binding:"oneof=0 1"`
	Config            map[string]any `json:"config" binding:"required"`
	Description       string         `json:"description"`
}

type AlertChannelListRequest

type AlertChannelListRequest struct {
	*Pagination
	Name      string `form:"name"`
	Type      string `form:"type" binding:"omitempty,oneof=feishuApp feishuBoot webhook"`
	Sort      string `form:"sort" binding:"omitempty,oneof=id name created_at updated_at"`
	Direction string `form:"direction" binding:"omitempty,oneof=asc desc"`
}

type AlertChannelListResponse

type AlertChannelListResponse struct {
	*ListResponse
	List []*model.AlertChannel `json:"list"`
}

func NewAlertChannelListResponse

func NewAlertChannelListResponse(alertChannels []*model.AlertChannel, total int64, pageSize, page int) *AlertChannelListResponse

type AlertChannelUpdateRequest

type AlertChannelUpdateRequest struct {
	*IDRequest
	Type              string         `json:"type" binding:"required,oneof=feishuApp feishuBoot webhook"`
	Status            *int           `json:"status" binding:"required,oneof=0 1"`
	AggregationStatus *int           `json:"aggregationStatus" binding:"required,oneof=0 1"`
	Config            map[string]any `json:"config" binding:"required"`
	Description       string         `json:"description"`
	TemplateID        int            `json:"templateID"`
}

type AlertHistoryListRequest

type AlertHistoryListRequest struct {
	*Pagination
	Fingerprint       string   `form:"fingerprint"`
	AlertName         string   `form:"alertName"`
	Status            string   `form:"status" binding:"omitempty,oneof=resolved firing"`
	Severity          string   `form:"severity"`
	Instance          string   `form:"instance"`
	StartsAt          *int64   `form:"startsAt"`
	EndsAt            *int64   `form:"endsAt"`
	Labels            []string `form:"labels"`
	AlertSendRecordId int      `form:"alertSendRecordId"`
	Sort              string   `form:"sort" binding:"omitempty,oneof=id alertname fingerprint starts_at ends_at severity instance"`
	Direction         string   `form:"direction" binding:"omitempty,oneof=asc desc"`
}

type AlertHistoryListResponse

type AlertHistoryListResponse struct {
	*ListResponse
	List []*model.AlertHistory `json:"list"`
}

func NewAlertHistoryListResponse

func NewAlertHistoryListResponse(alertHistorys []*model.AlertHistory, total int64, pageSize, page int) *AlertHistoryListResponse

type AlertHistoryUpdateRequest

type AlertHistoryUpdateRequest struct {
	*IDRequest
	Status string `json:"status" binding:"required,eq=resolved"`
}

type AlertMap

type AlertMap struct {
	FiringAlertMap   map[string]*Alert
	ResolvedAlertMap map[string]*Alert
	SilencedAlertMap map[string]*Alert
}

type AlertReceiveReq

type AlertReceiveReq struct {
	ChannelName       string            `form:"channelName" binding:"required"`
	Receiver          string            `json:"receiver"`
	Status            string            `json:"status"` // "firing" or "resolved"
	Alerts            []*Alert          `json:"alerts"`
	GroupLabels       map[string]string `json:"groupLabels"`
	CommonLabels      map[string]string `json:"commonLabels"`
	CommonAnnotations map[string]string `json:"commonAnnotations"`
	ExternalURL       string            `json:"externalURL"`
	Version           string            `json:"version"`
	GroupKey          string            `json:"groupKey"`
	TruncatedAlerts   uint64            `json:"truncatedAlerts"`
}

AlertReceiveReq 是 Alertmanager 发送的 Webhook 顶层 JSON 结构

func NewTestAlertReceiveReq

func NewTestAlertReceiveReq() *AlertReceiveReq

NewTestAlertReceiveReq 测试模板使用的告警数据

func (*AlertReceiveReq) DeepCopy

func (receiver *AlertReceiveReq) DeepCopy() *AlertReceiveReq

DeepCopy 创建 AlertReceiveReq 的深拷贝,确保在处理过程中数据不被修改

type AlertSilenceCreateRequest

type AlertSilenceCreateRequest struct {
	Type        int             `json:"type"  binding:"required,oneof=1 2"`
	Status      *int            `json:"status" binding:"required,oneof=0 1"`
	StartsAt    *int64          `json:"startsAt" binding:"required"`
	EndsAt      *int64          `json:"endsAt" binding:"required,gtfield=StartsAt"`
	Fingerprint string          `json:"fingerprint" binding:"required_without=Matchers"`
	Matchers    []model.Matcher `json:"matchers" binding:"required_without=Fingerprint"`
	CreatedBy   string          `json:"createdBy" binding:"required"`
	Comment     string          `json:"comment" binding:"required,max=255"`
}

func (*AlertSilenceCreateRequest) TOMolelAlertSilence

func (receiver *AlertSilenceCreateRequest) TOMolelAlertSilence() (*model.AlertSilence, error)

type AlertSilenceListRequest

type AlertSilenceListRequest struct {
	*Pagination
	Status    *int            `form:"status" binding:"required,oneof=0 1"`
	StartsAt  *int64          `form:"startsAt"`
	EndsAt    *int64          `form:"endsAt" binding:"omitempty,gtfield=StartsAt"`
	Matchers  []model.Matcher `form:"matchers" binding:"omitempty,gt=0"`
	CreatedBy string          `form:"createdBy" binding:"omitempty"`
	Sort      string          `form:"sort" binding:"omitempty,oneof=id name created_at updated_at"`
	Direction string          `form:"direction" binding:"omitempty,oneof=asc desc"`
}

type AlertSilenceListResponse

type AlertSilenceListResponse struct {
	*ListResponse
	List []*model.AlertSilence `json:"list"`
}

func NewAlertSilenceListResponse

func NewAlertSilenceListResponse(alertSilences []*model.AlertSilence, total int64, pageSize, page int) *AlertSilenceListResponse

type AlertTemplateCreateRequest

type AlertTemplateCreateRequest struct {
	Name                string `json:"name" binding:"required"`
	Description         string `json:"description"`
	Template            string `json:"template" binding:"required,base64"`
	AggregationTemplate string `json:"aggregationTemplate" binding:"omitempty,base64"`
}

type AlertTemplateListRequest

type AlertTemplateListRequest struct {
	*Pagination
	Name      string `form:"name"`
	Sort      string `form:"sort" binding:"omitempty,oneof=id name created_at updated_at"`
	Direction string `form:"direction" binding:"omitempty,oneof=asc desc"`
}

type AlertTemplateListResponse

type AlertTemplateListResponse struct {
	*ListResponse
	List []*model.AlertTemplate `json:"list"`
}

func NewAlertTemplateListResponse

func NewAlertTemplateListResponse(alertTemplates []*model.AlertTemplate, total int64, pageSize, page int) *AlertTemplateListResponse

type AlertTemplateUpdateRequest

type AlertTemplateUpdateRequest struct {
	*IDRequest
	Template            string `json:"template" binding:"required,base64"`
	AggregationTemplate string `json:"aggregationTemplate" binding:"omitempty,base64"`
	Description         string `json:"description"`
}

type ApiCreateRequest

type ApiCreateRequest struct {
	Name        string `json:"name" binding:"required"`
	Path        string `json:"path" binding:"required,uri"`
	Method      string `json:"method" binding:"required,oneof=GET POST PUT DELETE *"`
	Effect      string `json:"effect" binding:"required,oneof=allow deny"`
	Description string `json:"description"`
}

type ApiInfo

type ApiInfo struct {
	Method  string `json:"method"`
	Path    string `json:"path"`
	Handler string `json:"handler"`
}

type ApiListRequest

type ApiListRequest struct {
	*Pagination
	Name      string `form:"name"`
	Path      string `form:"path" binding:"omitempty,uri"`
	Method    string `form:"method" binding:"omitempty,oneof=GET POST PUT DELETE"`
	Sort      string `form:"sort" binding:"omitempty,oneof=id name path method created_at updated_at"`
	Direction string `form:"direction" binding:"omitempty,oneof=asc desc"`
}

type ApiListResponse

type ApiListResponse struct {
	*ListResponse
	List []*model.Api `json:"list"`
}

func NewApiListResponse

func NewApiListResponse(apis []*model.Api, total int64, pageSize, page int) *ApiListResponse

type ApiUpdateRequest

type ApiUpdateRequest struct {
	*IDRequest
	Description string `json:"description"`
}

type IDRequest

type IDRequest struct {
	ID int64 `uri:"id" binding:"required"`
}

type ListResponse

type ListResponse struct {
	*Pagination
	Total int64 `json:"total"`
}

type NotifyAlerts

type NotifyAlerts struct {
	FiringAlerts   []*Alert
	ResolvedAlerts []*Alert
}

NotifyAlerts 代表一次告警发送中所有的告警详情,分为正在触发的告警和已恢复的告警两类

type NotifyReq

type NotifyReq struct {
	AlertChannel     *model.AlertChannel
	AlertReceiveReq  *AlertReceiveReq
	TenantValue      string
	AlertMap         *AlertMap
	ExistingAlertMap map[string]*model.AlertHistory
	AlertArry        *AlertArry
}

NotifyReq 是内部服务处理告警发送的请求结构,包含了告警发送通道信息、告警详情和原始接收请求

func NewNotifyReq

func NewNotifyReq() *NotifyReq

type NotifySendResult

type NotifySendResult struct {
	AggregationSendResult *AggregationSendResult
	SingleSendResult      []*SingleSendResult
}

NotifySendResult 代表一次告警发送的结果,包含聚合发送结果和单条发送结果

type OAuthActivateRequest

type OAuthActivateRequest struct {
	ID              int    `uri:"id"`
	Password        string `json:"password"`
	ConfirmPassword string `json:"confirmPassword"`
}

type OAuthLoginRequest

type OAuthLoginRequest struct {
	Code string `form:"code" binding:"required"`
}

type OauthLoginResponse

type OauthLoginResponse struct {
	User  any    `json:"user"`
	Token string `json:"token"`
}

type Pagination

type Pagination struct {
	// Page 从 1 开始, 表示第几页
	Page int `form:"page,default=1" json:"page" binding:"omitempty,min=1"`
	// PageSize 最大值 100,默认值 20, 表示每页多少条数据
	PageSize int `form:"pageSize,default=20" json:"pageSize" binding:"omitempty,min=1,max=100"`
}

type Response

type Response struct {
	Code  int    `json:"code"`
	Msg   string `json:"msg,omitempty"`
	Data  any    `json:"data,omitempty"`
	Error string `json:"error,omitempty"`
}

func NewResponseWithOpts

func NewResponseWithOpts(code int, opts ...ResponseOptions) *Response

type ResponseOptions

type ResponseOptions func(*Response)

func WithData

func WithData(data any) ResponseOptions

func WithError

func WithError(err string) ResponseOptions

func WithMsg

func WithMsg(msg string) ResponseOptions

type RoleCreateRequest

type RoleCreateRequest struct {
	Name        string  `json:"name" binding:"required,ascii"`
	Description string  `json:"description"`
	Apis        []int64 `json:"apis"`
}

type RoleListRequest

type RoleListRequest struct {
	*Pagination
	Name      string `form:"name"`
	Sort      string `form:"sort" binding:"omitempty,oneof=id name created_at updated_at"`
	Direction string `form:"direction" binding:"omitempty,oneof=asc desc"`
}

type RoleListResponse

type RoleListResponse struct {
	*ListResponse
	List []*model.Role `json:"list"`
}

func NewRoleListResponse

func NewRoleListResponse(roles []*model.Role, total int64, pageIndex, pageSize int) *RoleListResponse

type RoleUpdateRequest

type RoleUpdateRequest struct {
	*IDRequest
	Description string  `json:"description"`
	Apis        []int64 `json:"apis"`
}

type ServerApiData

type ServerApiData struct {
	ApiType []string             `json:"apiType"`
	ApiInfo map[string][]ApiInfo `json:"apiInfo"`
}

type SingleSendResult

type SingleSendResult struct {
	Alert   *Alert
	SendErr error
}

SingleSendResult 代表单条告警发送的结果,包含告警详情和发送错误信息

type TenantCount

type TenantCount struct {
	Cluster string `json:"cluster"`
	Count   int64  `json:"count"`
}

type TenantCreateRequest

type TenantCreateRequest struct {
	Name        string `json:"name" binding:"required"`
	Description string `json:"description"`
}

type TenantListRequest

type TenantListRequest struct {
	*Pagination
	Name      string `form:"name"`
	Sort      string `form:"sort" binding:"omitempty,oneof=id name created_at updated_at"`
	Direction string `form:"direction" binding:"omitempty,oneof=asc desc"`
}

type TenantListResponse

type TenantListResponse struct {
	*ListResponse
	List []*model.Tenant `json:"list"`
}

func NewTenantListResponse

func NewTenantListResponse(tenants []*model.Tenant, total int64, pageSize, page int) *TenantListResponse

type TenantOption

type TenantOption struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

type TenantUpdateRequest

type TenantUpdateRequest struct {
	*IDRequest
	Description string `json:"description"`
}

type UserCreateRequest

type UserCreateRequest struct {
	Name     string   `json:"name" binding:"required"`
	NickName string   `json:"nickName"`
	Email    string   `json:"email" binding:"required,email"`
	Password string   `json:"password" binding:"required,min=8"`
	Avatar   string   `json:"avatar"`
	Mobile   string   `json:"mobile" binding:"omitempty,mobile"`
	RolesID  *[]int64 `json:"rolesID"`
}

type UserIdRequest

type UserIdRequest struct {
	ID int64 `uri:"id" binding:"required"`
}

type UserListRequest

type UserListRequest struct {
	*Pagination
	Name       string `form:"name" binding:"user_list"`
	Email      string `form:"email" binding:"omitempty,email"`
	Mobile     string `form:"mobile" binding:"omitempty,mobile"`
	Department string `form:"department"`
	Sort       string `form:"sort" binding:"omitempty,oneof=id name created_at updated_at nick_name email mobile"`
	Direction  string `form:"direction" binding:"omitempty,oneof=asc desc"`
	Status     int    `form:"status" binding:"omitempty,oneof=0 1 2"`
}

type UserListResponse

type UserListResponse struct {
	*ListResponse
	List []*model.User `json:"list"`
}

type UserLoginRequest

type UserLoginRequest struct {
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required,min=8"`
}

type UserLoginResponse

type UserLoginResponse struct {
	User  *model.User `json:"user"`
	Token string      `json:"token"`
}

func NewUserLoginResponse

func NewUserLoginResponse(user *model.User, token string) *UserLoginResponse

type UserUpdateAdminRequest

type UserUpdateAdminRequest struct {
	ID int64 `uri:"id" binding:"required"`
	*UserUpdateSelfRequest
	Status  int      `json:"status" binding:"omitempty,oneof=1 2"`
	RolesID *[]int64 `json:"rolesID" binding:"omitempty"`
}

type UserUpdateRoleRequest

type UserUpdateRoleRequest struct {
	ID      int64   `uri:"id" binding:"required"`
	RolesID []int64 `json:"rolesID" binding:"required"`
}

type UserUpdateSelfRequest

type UserUpdateSelfRequest struct {
	Name        string `json:"name"`
	NickName    string `json:"nickName"`
	Email       string `json:"email" binding:"omitempty,email"`
	OldPassword string `json:"oldPassword" binding:"omitempty,min=8"`
	Password    string `json:"password" binding:"omitempty,min=8"`
	Avatar      string `json:"avatar"`
	Mobile      string `json:"mobile" binding:"omitempty,mobile"`
}

type UserUpdateStatusRequest

type UserUpdateStatusRequest struct {
	ID     int64 `uri:"id" binding:"required"`
	Status int   `json:"status" binding:"required,oneof=1 2"`
}

Jump to

Keyboard shortcuts

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