Documentation
¶
Index ¶
- func ConvertToModel(tenantKey string, a *Alert, channelID int) (*model.AlertHistory, error)
- func NewApi(req *ApiCreateRequest) *model.Api
- type AggregationSendResult
- type Alert
- type AlertArry
- type AlertChannelCreateRequest
- type AlertChannelListRequest
- type AlertChannelListResponse
- type AlertChannelUpdateRequest
- type AlertHistoryListRequest
- type AlertHistoryListResponse
- type AlertHistoryUpdateRequest
- type AlertMap
- type AlertReceiveReq
- type AlertSilenceCreateRequest
- type AlertSilenceListRequest
- type AlertSilenceListResponse
- type AlertTemplateCreateRequest
- type AlertTemplateListRequest
- type AlertTemplateListResponse
- type AlertTemplateUpdateRequest
- type ApiCreateRequest
- type ApiInfo
- type ApiListRequest
- type ApiListResponse
- type ApiUpdateRequest
- type IDRequest
- type ListResponse
- type NotifyAlerts
- type NotifyReq
- type NotifySendResult
- type OAuthActivateRequest
- type OAuthLoginRequest
- type OauthLoginResponse
- type Pagination
- type Response
- type ResponseOptions
- type RoleCreateRequest
- type RoleListRequest
- type RoleListResponse
- type RoleUpdateRequest
- type ServerApiData
- type SingleSendResult
- type TenantCount
- type TenantCreateRequest
- type TenantListRequest
- type TenantListResponse
- type TenantOption
- type TenantUpdateRequest
- type UserCreateRequest
- type UserIdRequest
- type UserListRequest
- type UserListResponse
- type UserLoginRequest
- type UserLoginResponse
- type UserUpdateAdminRequest
- type UserUpdateRoleRequest
- type UserUpdateSelfRequest
- type UserUpdateStatusRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToModel ¶
辅助函数:将业务 Alert 转换为 DB Model
func NewApi ¶
func NewApi(req *ApiCreateRequest) *model.Api
Types ¶
type AggregationSendResult ¶
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 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 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 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 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 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 ListResponse ¶
type ListResponse struct {
*Pagination
Total int64 `json:"total"`
}
type NotifyAlerts ¶
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 OAuthLoginRequest ¶
type OAuthLoginRequest struct {
Code string `form:"code" binding:"required"`
}
type OauthLoginResponse ¶
type Pagination ¶
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 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 ServerApiData ¶
type SingleSendResult ¶
SingleSendResult 代表单条告警发送的结果,包含告警详情和发送错误信息
type TenantCount ¶
type TenantCreateRequest ¶
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 TenantUpdateRequest ¶
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 UserLoginResponse ¶
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 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 ¶
Click to show internal directories.
Click to hide internal directories.