Documentation
¶
Index ¶
- Constants
- type AuditLog
- type AuditLogForm
- type AuditLogQueryOptions
- type AuditLogQueryParam
- type AuditLogQueryResult
- type AuditLogs
- type EventLog
- type EventLogs
- type EventQueryOptions
- type EventQueryParam
- type EventQueryResult
- type EventStatistics
- type EventTypeCount
- type RankingItem
- type TrendPoint
Constants ¶
const ( AuditActionCreate = "create" AuditActionUpdate = "update" AuditActionDelete = "delete" AuditActionEnable = "enable" AuditActionDisable = "disable" AuditActionPublish = "publish" AuditActionLogin = "login" AuditActionLogout = "logout" )
AuditAction 常用审计动作常量
const ( AuditResourceTypeModel = "model" AuditResourceTypeEndpoint = "endpoint" AuditResourceTypeProvider = "provider" AuditResourceTypeModelCatalog = "model_catalog" AuditResourceTypePriceVersion = "price_version" AuditResourceTypePolicy = "policy" AuditResourceTypeTenant = "tenant" AuditResourceTypeUser = "user" AuditResourceTypeAPIKey = "api_key" AuditResourceTypeWorkspace = "workspace" AuditResourceTypePolicyBinding = "policy_binding" AuditResourceTypeTenantModel = "tenant_model" AuditResourceTypeTenantEndpoint = "tenant_endpoint" AuditResourceTypeRole = "role" )
AuditResourceType 常用资源类型常量
const ( EventTypeCircuitBreak = "circuit_break" EventTypeRateLimit = "rate_limit" EventTypeInvocationFail = "invocation_fail" EventTypeLBSwitch = "lb_switch" )
Event types
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditLog ¶
type AuditLog struct {
ID string `json:"id" gorm:"type:char(20);primaryKey;<-:create;comment:主键ID (XID);"`
TenantCode string `json:"tenant_code" gorm:"type:varchar(64);default:null;index:idx_al_tenant_created,priority:1;comment:租户编码;"`
ActorUserID string `json:"actor_user_id" gorm:"type:varchar(20);default:null;index:idx_al_actor_created,priority:1;comment:操作人用户ID;"`
ActorName string `json:"actor_name" gorm:"type:varchar(128);default:null;comment:操作人名称(冗余快照);"`
Action string `` /* 134-byte string literal not displayed */
ResourceType string `` /* 148-byte string literal not displayed */
ResourceID string `json:"resource_id" gorm:"type:varchar(64);not null;index:idx_al_resource,priority:2;comment:资源ID;"`
ResourceName string `json:"resource_name" gorm:"type:varchar(255);default:null;comment:资源名称(冗余快照);"`
BeforeData *string `json:"before_data,omitempty" gorm:"type:json;default:null;comment:变更前数据快照;"`
AfterData *string `json:"after_data,omitempty" gorm:"type:json;default:null;comment:变更后数据快照;"`
IP string `json:"ip" gorm:"type:varchar(64);not null;default:'';comment:请求IP;"`
UserAgent string `json:"user_agent" gorm:"type:varchar(512);not null;default:'';comment:User-Agent;"`
TraceID string `json:"trace_id" gorm:"type:varchar(64);default:null;index:idx_al_trace_id;comment:链路追踪ID;"`
Message string `json:"message" gorm:"type:varchar(1024);default:null;comment:可读描述;"`
CreatedAt time.Time `` /* 188-byte string literal not displayed */
}
AuditLog 结构化审计日志表,记录业务操作的变更前后数据。 与现有 Logger 表互补:Logger 偏开发调试(level, stack, message),AuditLog 偏业务审计(action, resource, before/after)。
type AuditLogForm ¶
type AuditLogForm struct {
TenantCode string `json:"tenant_code" binding:"max=64"` // Tenant code
ActorUserID string `json:"actor_user_id" binding:"max=20"` // Actor user ID
ActorName string `json:"actor_name" binding:"max=128"` // Actor name
Action string `json:"action" binding:"required,max=96"` // Action
ResourceType string `json:"resource_type" binding:"required,max=64"` // Resource type
ResourceID string `json:"resource_id" binding:"required,max=64"` // Resource ID
ResourceName string `json:"resource_name" binding:"max=255"` // Resource name
BeforeData *string `json:"before_data"` // Before data
AfterData *string `json:"after_data"` // After data
IP string `json:"ip" binding:"max=64"` // IP
UserAgent string `json:"user_agent" binding:"max=512"` // User agent
TraceID string `json:"trace_id" binding:"max=64"` // Trace ID
Message string `json:"message" binding:"max=1024"` // Message
}
AuditLogForm defines the form for creating an AuditLog.
func (*AuditLogForm) FillTo ¶
func (a *AuditLogForm) FillTo(log *AuditLog) error
func (*AuditLogForm) Validate ¶
func (a *AuditLogForm) Validate() error
type AuditLogQueryOptions ¶
type AuditLogQueryOptions struct {
util.QueryOptions
}
AuditLogQueryOptions defines the query options for AuditLog.
type AuditLogQueryParam ¶
type AuditLogQueryParam struct {
util.PaginationParam
TenantCode string `form:"tenant_code"` // Filter by tenant
ActorUserID string `form:"actor_user_id"` // Filter by actor
Action string `form:"action"` // Filter by action
ResourceType string `form:"resource_type"` // Filter by resource type
ResourceID string `form:"resource_id"` // Filter by resource ID
TraceID string `form:"trace_id"` // Filter by trace ID
StartTime string `form:"start_time"` // Filter by start time
EndTime string `form:"end_time"` // Filter by end time
}
AuditLogQueryParam defines the query parameters for AuditLog.
type AuditLogQueryResult ¶
type AuditLogQueryResult struct {
Data AuditLogs
PageResult *util.PaginationResult
}
AuditLogQueryResult defines the query result for AuditLog.
type EventLog ¶
type EventLog struct {
ID string `json:"id" gorm:"size:20;primaryKey;<-:create;comment:Unique ID;"`
EventType string `json:"event_type" gorm:"size:32;not null;index:idx_el_event_type;comment:Event type;"`
TenantCode string `json:"tenant_code" gorm:"size:64;not null;default:'';index:idx_el_tenant;comment:Tenant code;"`
ModelCode string `json:"model_code" gorm:"size:64;not null;default:'';index:idx_el_model;comment:Model code;"`
EndpointID string `json:"endpoint_id" gorm:"size:20;not null;default:'';index:idx_el_endpoint;comment:Endpoint ID;"`
EndpointCode string `json:"endpoint_code" gorm:"size:128;not null;default:'';index:idx_el_endpoint_code;comment:Endpoint code;"`
ProviderName string `json:"provider_name" gorm:"size:128;not null;default:'';comment:Provider name;"`
PolicyID string `json:"policy_id" gorm:"size:20;not null;default:'';index:idx_el_policy;comment:Policy ID;"`
PolicyName string `json:"policy_name" gorm:"size:128;not null;default:'';comment:Policy name;"`
Threshold *float64 `json:"threshold" gorm:"type:decimal(10,2);comment:Threshold value;"`
CurrentValue *float64 `json:"current_value" gorm:"type:decimal(10,2);comment:Current value at trigger;"`
RequestID string `json:"request_id" gorm:"size:64;not null;default:'';comment:Request ID;"`
TraceID string `json:"trace_id" gorm:"size:64;not null;default:'';comment:Trace ID;"`
Message string `json:"message" gorm:"size:10240;not null;default:'';comment:Human-readable message;"`
EventTime time.Time `json:"event_time" gorm:"type:datetime;not null;index:idx_el_time;comment:Event timestamp from gateway;"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime;comment:Ingest time;"`
}
EventLog records policy execution events from the AI Gateway.
type EventQueryOptions ¶
type EventQueryOptions struct {
util.QueryOptions
}
EventQueryOptions defines query options.
type EventQueryParam ¶
type EventQueryParam struct {
util.PaginationParam
EventType string `form:"event_type"` // Filter by event type
TenantCode string `form:"tenant_code"` // Filter by tenant code
ModelCode string `form:"model_code"` // Filter by model code
ProviderName string `form:"provider_name"` // Filter by provider name
EndpointID string `form:"endpoint_id"` // Filter by endpoint ID
EndpointCode string `form:"endpoint_code"` // Filter by endpoint code
PolicyID string `form:"policy_id"` // Filter by policy ID
StartTime string `form:"start_time"` // Filter by start time (ISO 8601 / unix)
EndTime string `form:"end_time"` // Filter by end time (ISO 8601 / unix)
}
EventQueryParam defines query parameters for event list.
type EventQueryResult ¶
type EventQueryResult struct {
Data EventLogs
PageResult *util.PaginationResult
}
EventQueryResult defines query result.
type EventStatistics ¶
type EventStatistics struct {
TotalEvents int64 `json:"total_events"`
CircuitBreakCount int64 `json:"circuit_break_count"`
RateLimitCount int64 `json:"rate_limit_count"`
InvocationFailCount int64 `json:"invocation_fail_count"`
LBSwitchCount int64 `json:"lb_switch_count"`
Trend []TrendPoint `json:"trend"`
TenantRanking []RankingItem `json:"tenant_ranking"`
ModelRanking []RankingItem `json:"model_ranking"`
}
EventStatistics represents the full statistics response.
type EventTypeCount ¶
EventTypeCount represents event count by type.
type RankingItem ¶
RankingItem represents an item in tenant/model ranking.