Documentation
¶
Overview ¶
Package models defines the core data structures used throughout Logchef. It includes database entity models, API request/response structures, and validation rules for ensuring data integrity across the application.
Index ¶
- Constants
- Variables
- func ValidateQueryTimeout(timeout *int) error
- type APIHistogramRequest
- type APIQueryRequest
- type APIToken
- type Alert
- type AlertHistoryEntry
- type AlertID
- type AlertQueryType
- type AlertSeverity
- type AlertState
- type AlertStatus
- type AlertThresholdOperator
- type ColumnInfo
- type ConnectionInfo
- type ConnectionInfoResponse
- type ConnectionValidationResult
- type CreateAPITokenRequest
- type CreateAPITokenResponse
- type CreateAlertRequest
- type CreateSourceRequest
- type CreateTeamQueryRequest
- type CreateUserRequest
- type DisplayModePreference
- type ErrInvalidTimeout
- type ErrorResponse
- type ErrorType
- type GenerateSQLRequest
- type GenerateSQLResponse
- type HealthStatus
- type LogContextRequest
- type LogContextResponse
- type LogQueryResult
- type QueryResult
- type QueryStats
- type ResolveAlertRequest
- type SavedQuery
- type SavedQueryContent
- type SavedQueryTab
- type SavedQueryTimeRange
- type SavedQueryType
- type SavedQueryVariable
- type SavedQueryVariableOption
- type SavedTeamQuery
- type Session
- type SessionID
- type Source
- type SourceHealth
- type SourceID
- type SourceResponse
- type SourceWithTeams
- type TableSchema
- type Team
- type TeamGroupedQuery
- type TeamID
- type TeamMember
- type TeamQuery
- type TeamRole
- type TemplateVariable
- type TestAlertQueryRequest
- type TestAlertQueryResponse
- type ThemePreference
- type Timestamps
- type TimezonePreference
- type UpdateAlertRequest
- type UpdateSourceRequest
- type UpdateTeamQueryRequest
- type UpdateUserPreferencesRequest
- type UpdateUserRequest
- type User
- type UserID
- type UserPreferences
- type UserRole
- type UserStatus
- type UserTeamDetails
- type ValidateConnectionRequest
Constants ¶
const ( // DefaultQueryTimeoutSeconds is the default max_execution_time if not specified DefaultQueryTimeoutSeconds = 60 // MaxQueryTimeoutSeconds is the maximum allowed timeout to prevent resource abuse MaxQueryTimeoutSeconds = 3600 // 1 hour )
Timeout constants for query execution
const ( // OTELLogsTableSchema is the schema for OpenTelemetry logs OTELLogsTableSchema = `` /* 1124-byte string literal not displayed */ // HTTPLogsTableSchema is the schema for HTTP logs table HTTPLogsTableSchema = `` /* 869-byte string literal not displayed */ )
Schema Constants
const DefaultAlertHistoryLimit = 100
DefaultAlertHistoryLimit controls the number of history entries returned when unspecified.
Variables ¶
var ( // ErrUserNotFound is returned when a user is not found ErrUserNotFound = errors.New("user not found") // ErrTeamNotFound is returned when a team is not found ErrTeamNotFound = errors.New("team not found") // ErrNotFound is returned when a resource is not found ErrNotFound = errors.New("not found") )
Error definitions
Functions ¶
func ValidateQueryTimeout ¶ added in v0.2.2
ValidateQueryTimeout validates that a query timeout is within acceptable bounds
Types ¶
type APIHistogramRequest ¶
type APIHistogramRequest struct {
StartTimestamp int64 `json:"start_timestamp,omitempty"` // Legacy - Unix timestamp in milliseconds
EndTimestamp int64 `json:"end_timestamp,omitempty"` // Legacy - Unix timestamp in milliseconds
Limit int `json:"limit"` // Limit might influence histogram sampling/performance
RawSQL string `json:"raw_sql"` // Contains non-time filters
Window string `json:"window,omitempty"` // For histogram queries: time window size like "1m", "5m", "1h"
GroupBy string `json:"group_by,omitempty"` // For histogram queries: field to group by
Timezone string `json:"timezone,omitempty"` // Kept for histogram, optional otherwise
// Variables for template substitution in the SQL query.
Variables []TemplateVariable `json:"variables,omitempty"`
// Query execution timeout in seconds. If not specified, uses default timeout.
QueryTimeout *int `json:"query_timeout,omitempty"`
}
APIHistogramRequest represents the request payload for the histogram endpoint.
type APIQueryRequest ¶
type APIQueryRequest struct {
Limit int `json:"limit"`
RawSQL string `json:"raw_sql"`
// Variables for template substitution in the SQL query.
// Example: {"name": "from_date", "type": "date", "value": "2026-01-01T00:00:00Z"}
Variables []TemplateVariable `json:"variables,omitempty"`
// Query execution timeout in seconds. If not specified, uses default timeout.
QueryTimeout *int `json:"query_timeout,omitempty"`
}
APIQueryRequest represents the request payload for the standard log querying endpoint.
type APIToken ¶ added in v0.2.2
type APIToken struct {
ID int `json:"id" db:"id"`
UserID UserID `json:"user_id" db:"user_id"`
Name string `json:"name" db:"name"`
TokenHash string `json:"-" db:"token_hash"` // Never expose in JSON
Prefix string `json:"prefix" db:"prefix"`
LastUsedAt *time.Time `json:"last_used_at,omitempty" db:"last_used_at"`
ExpiresAt *time.Time `json:"expires_at,omitempty" db:"expires_at"`
Timestamps
}
APIToken represents an API token for authentication
type Alert ¶ added in v0.6.0
type Alert struct {
ID AlertID `json:"id"`
TeamID TeamID `json:"team_id"`
SourceID SourceID `json:"source_id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
QueryType AlertQueryType `json:"query_type"`
Query string `json:"query"`
ConditionJSON string `json:"condition_json,omitempty"`
LookbackSeconds int `json:"lookback_seconds"`
ThresholdOperator AlertThresholdOperator `json:"threshold_operator"`
ThresholdValue float64 `json:"threshold_value"`
FrequencySeconds int `json:"frequency_seconds"`
Severity AlertSeverity `json:"severity"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
RecipientUserIDs []UserID `json:"recipient_user_ids,omitempty"`
WebhookURLs []string `json:"webhook_urls,omitempty"`
GeneratorURL string `json:"generator_url,omitempty"`
IsActive bool `json:"is_active"`
LastState AlertState `json:"last_state"`
LastEvaluatedAt *time.Time `json:"last_evaluated_at,omitempty"`
LastTriggeredAt *time.Time `json:"last_triggered_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Alert encapsulates a rule that is continuously evaluated against log data.
type AlertHistoryEntry ¶ added in v0.6.0
type AlertHistoryEntry struct {
ID int64 `json:"id"`
AlertID AlertID `json:"alert_id"`
Status AlertStatus `json:"status"`
TriggeredAt time.Time `json:"triggered_at"`
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
Value *float64 `json:"value,omitempty"`
Message string `json:"message,omitempty"`
Payload map[string]any `json:"payload,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AlertHistoryEntry captures individual trigger or resolution events for an alert.
type AlertQueryType ¶ added in v0.6.0
type AlertQueryType string
AlertQueryType represents the underlying evaluation strategy.
const ( AlertQueryTypeSQL AlertQueryType = "sql" AlertQueryTypeCondition AlertQueryType = "condition" )
type AlertSeverity ¶ added in v0.6.0
type AlertSeverity string
AlertSeverity is a lightweight severity indicator for routing and display.
const ( AlertSeverityInfo AlertSeverity = "info" AlertSeverityWarning AlertSeverity = "warning" AlertSeverityCritical AlertSeverity = "critical" )
type AlertState ¶ added in v0.6.0
type AlertState string
AlertState captures the persisted lifecycle state of an alert rule.
const ( AlertStateFiring AlertState = "firing" AlertStateResolved AlertState = "resolved" )
type AlertStatus ¶ added in v0.6.0
type AlertStatus string
AlertStatus captures the lifecycle state of an alert history entry.
const ( AlertStatusTriggered AlertStatus = "triggered" AlertStatusResolved AlertStatus = "resolved" AlertStatusError AlertStatus = "error" )
type AlertThresholdOperator ¶ added in v0.6.0
type AlertThresholdOperator string
AlertThresholdOperator represents the comparison operator used when checking the evaluated value.
const ( AlertThresholdGreaterThan AlertThresholdOperator = "gt" AlertThresholdGreaterThanOrEqual AlertThresholdOperator = "gte" AlertThresholdLessThan AlertThresholdOperator = "lt" AlertThresholdLessThanOrEqual AlertThresholdOperator = "lte" AlertThresholdEqual AlertThresholdOperator = "eq" AlertThresholdNotEqual AlertThresholdOperator = "neq" )
type ColumnInfo ¶
ColumnInfo represents column metadata from ClickHouse
type ConnectionInfo ¶
type ConnectionInfo struct {
Host string `json:"host"`
Username string `json:"username"`
Password string `json:"password"`
Database string `json:"database"`
TableName string `json:"table_name"`
}
ConnectionInfo represents the connection details for a ClickHouse database
type ConnectionInfoResponse ¶
type ConnectionInfoResponse struct {
Host string `json:"host"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Database string `json:"database"`
TableName string `json:"table_name"`
}
ConnectionInfoResponse represents the connection details for API responses
type ConnectionValidationResult ¶
type ConnectionValidationResult struct {
Message string `json:"message"`
}
ConnectionValidationResult represents the result of a connection validation
type CreateAPITokenRequest ¶ added in v0.2.2
type CreateAPITokenRequest struct {
Name string `json:"name"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
CreateAPITokenRequest represents a request to create a new API token
type CreateAPITokenResponse ¶ added in v0.2.2
type CreateAPITokenResponse struct {
Token string `json:"token"` // Full token (only shown once)
APIToken *APIToken `json:"api_token"` // Token metadata
}
CreateAPITokenResponse represents the response when creating an API token
type CreateAlertRequest ¶ added in v0.6.0
type CreateAlertRequest struct {
Name string `json:"name"`
Description string `json:"description"`
QueryType AlertQueryType `json:"query_type"`
Query string `json:"query"`
ConditionJSON string `json:"condition_json"`
LookbackSeconds int `json:"lookback_seconds"`
ThresholdOperator AlertThresholdOperator `json:"threshold_operator"`
ThresholdValue float64 `json:"threshold_value"`
FrequencySeconds int `json:"frequency_seconds"`
Severity AlertSeverity `json:"severity"`
Labels map[string]string `json:"labels"`
Annotations map[string]string `json:"annotations"`
RecipientUserIDs []UserID `json:"recipient_user_ids"`
WebhookURLs []string `json:"webhook_urls"`
GeneratorURL string `json:"generator_url"`
IsActive bool `json:"is_active"`
}
CreateAlertRequest defines the payload required to create a new alert rule.
type CreateSourceRequest ¶
type CreateSourceRequest struct {
Name string `json:"name"`
MetaIsAutoCreated bool `json:"meta_is_auto_created"`
MetaTSField string `json:"meta_ts_field"`
MetaSeverityField string `json:"meta_severity_field"`
Connection ConnectionInfo `json:"connection"`
Description string `json:"description"`
TTLDays int `json:"ttl_days"`
Schema string `json:"schema,omitempty"`
}
CreateSourceRequest represents a request to create a new data source
type CreateTeamQueryRequest ¶
type CreateTeamQueryRequest struct {
Name string `json:"name" validate:"required"`
Description string `json:"description"`
SourceID SourceID `json:"source_id" validate:"required"`
QueryType SavedQueryType `json:"query_type" validate:"required"`
QueryContent string `json:"query_content" validate:"required"`
}
CreateTeamQueryRequest represents a request to create a team query
type CreateUserRequest ¶
type CreateUserRequest struct {
Email string `json:"email"`
FullName string `json:"full_name"`
Role UserRole `json:"role"`
}
CreateUserRequest represents a request to create a new user
type DisplayModePreference ¶ added in v1.3.0
type DisplayModePreference string
DisplayModePreference represents the preferred log display mode.
const ( DisplayModeTable DisplayModePreference = "table" DisplayModeCompact DisplayModePreference = "compact" )
type ErrInvalidTimeout ¶ added in v0.2.2
type ErrInvalidTimeout struct {
Message string
}
ErrInvalidTimeout represents a query timeout validation error
func (ErrInvalidTimeout) Error ¶ added in v0.2.2
func (e ErrInvalidTimeout) Error() string
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
Type ErrorType `json:"error_type"`
Details any `json:"details,omitempty"`
}
ErrorResponse represents a standardized error response
func NewErrorResponse ¶
func NewErrorResponse(message string, errorType ErrorType, details any) ErrorResponse
NewErrorResponse creates a new error response
type ErrorType ¶
type ErrorType string
ErrorType represents the type of error that occurred
const ( // ValidationErrorType indicates a validation error ValidationErrorType ErrorType = "ValidationError" // NotFoundErrorType indicates a resource was not found NotFoundErrorType ErrorType = "NotFoundError" // AuthenticationErrorType indicates an authentication error AuthenticationErrorType ErrorType = "AuthenticationError" // AuthorizationErrorType indicates an authorization error AuthorizationErrorType ErrorType = "AuthorizationError" // ConflictErrorType indicates a resource conflict (e.g., already exists) ConflictErrorType ErrorType = "ConflictError" // DatabaseErrorType indicates a database error DatabaseErrorType ErrorType = "DatabaseError" // ExternalServiceErrorType indicates an error with an external service ExternalServiceErrorType ErrorType = "ExternalServiceError" // GeneralErrorType is a fallback for general errors GeneralErrorType ErrorType = "GeneralError" // DemoInstanceErrorType indicates an operation not permitted in demo mode DemoInstanceErrorType ErrorType = "DEMO_INSTANCE" // ManagedResourceErrorType indicates a mutation attempted on a config-managed resource ManagedResourceErrorType ErrorType = "ManagedResourceError" )
Common error types
type GenerateSQLRequest ¶ added in v0.2.2
type GenerateSQLRequest struct {
NaturalLanguageQuery string `json:"natural_language_query" validate:"required"`
CurrentQuery string `json:"current_query,omitempty"` // Optional current query for context
}
GenerateSQLRequest defines the request body for SQL generation from natural language.
type GenerateSQLResponse ¶ added in v0.2.2
type GenerateSQLResponse struct {
SQLQuery string `json:"sql_query"`
}
GenerateSQLResponse defines the successful response for SQL generation.
type HealthStatus ¶
type HealthStatus string
HealthStatus represents the health status of a resource
const ( // HealthStatusHealthy indicates the resource is healthy HealthStatusHealthy HealthStatus = "healthy" // HealthStatusUnhealthy indicates the resource is unhealthy HealthStatusUnhealthy HealthStatus = "unhealthy" )
type LogContextRequest ¶
type LogContextRequest struct {
SourceID SourceID `json:"source_id"`
Timestamp int64 `json:"timestamp"` // Target timestamp in milliseconds
BeforeLimit int `json:"before_limit"` // Optional, defaults to 10
AfterLimit int `json:"after_limit"` // Optional, defaults to 10
BeforeOffset int `json:"before_offset"` // Offset for before query (for pagination)
AfterOffset int `json:"after_offset"` // Offset for after query (for pagination)
ExcludeBoundary bool `json:"exclude_boundary"` // When true, excludes logs at exact timestamp (for pagination)
}
LogContextRequest represents a request to get temporal context around a log
type LogContextResponse ¶
type LogContextResponse struct {
TargetTimestamp int64 `json:"target_timestamp"`
BeforeLogs []map[string]interface{} `json:"before_logs"`
TargetLogs []map[string]interface{} `json:"target_logs"` // Multiple logs might have the same timestamp
AfterLogs []map[string]interface{} `json:"after_logs"`
Stats QueryStats `json:"stats"`
}
LogContextResponse represents temporal context query results
type LogQueryResult ¶
type LogQueryResult struct {
Data []map[string]interface{} `json:"data"`
Stats QueryStats `json:"stats"`
Columns []ColumnInfo `json:"columns"`
}
LogQueryResult represents the result of a log query
type QueryResult ¶
type QueryResult struct {
Logs []map[string]interface{} `json:"logs"`
Stats QueryStats `json:"stats"`
Columns []ColumnInfo `json:"columns"`
}
QueryResult represents the result of a query
type QueryStats ¶
type QueryStats struct {
ExecutionTimeMs float64 `json:"execution_time_ms"`
RowsRead int `json:"rows_read"`
BytesRead int `json:"bytes_read,omitempty"`
}
QueryStats represents statistics about query execution
type ResolveAlertRequest ¶ added in v0.6.0
type ResolveAlertRequest struct {
Message string `json:"message"`
}
ResolveAlertRequest allows callers to provide context when manually resolving an alert.
type SavedQuery ¶
type SavedQuery struct {
ID int `json:"id" db:"id"`
TeamID string `json:"team_id" db:"team_id"`
SourceID string `json:"source_id" db:"source_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
QuerySQL string `json:"query_sql" db:"query_sql"`
CreatedBy UserID `json:"created_by" db:"created_by"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
SavedQuery represents a generic saved query
type SavedQueryContent ¶
type SavedQueryContent struct {
Version int `json:"version"`
SourceID SourceID `json:"sourceId"`
TimeRange SavedQueryTimeRange `json:"timeRange"`
Limit int `json:"limit"`
Content string `json:"content"`
Variables []SavedQueryVariable `json:"variables"`
}
type SavedQueryTab ¶
type SavedQueryTab string
SavedQueryTab represents the active tab in the explorer
const ( // SavedQueryTabFilters represents the filters tab SavedQueryTabFilters SavedQueryTab = "filters" // SavedQueryTabRawSQL represents the raw SQL tab SavedQueryTabRawSQL SavedQueryTab = "raw_sql" )
type SavedQueryTimeRange ¶
type SavedQueryTimeRange struct {
Relative string `json:"relative,omitempty"` // Relative time string like "15m", "1h", "7d"
Absolute struct {
Start int64 `json:"start"` // Unix timestamp in milliseconds
End int64 `json:"end"` // Unix timestamp in milliseconds
} `json:"absolute"`
}
SavedQueryTimeRange represents a time range for a saved query Either Relative OR Absolute should be set, not both. If Relative is set, it takes precedence (e.g., "15m", "1h", "24h", "7d")
type SavedQueryType ¶
type SavedQueryType string
SavedQueryType represents the type of saved query
const ( // SavedQueryTypeLogchefQL represents a query saved in LogchefQL format SavedQueryTypeLogchefQL SavedQueryType = "logchefql" // SavedQueryTypeSQL represents a query saved in SQL format SavedQueryTypeSQL SavedQueryType = "sql" )
type SavedQueryVariable ¶ added in v1.2.0
type SavedQueryVariable struct {
Name string `json:"name"`
Type string `json:"type"`
Label string `json:"label"`
InputType string `json:"inputType"`
Value interface{} `json:"value"`
DefaultValue interface{} `json:"defaultValue,omitempty"`
IsOptional bool `json:"isOptional,omitempty"`
IsRequired bool `json:"isRequired,omitempty"`
Options []SavedQueryVariableOption `json:"options,omitempty"`
}
type SavedQueryVariableOption ¶ added in v1.2.0
type SavedTeamQuery ¶
type SavedTeamQuery struct {
ID int `json:"id" db:"id"`
TeamID TeamID `json:"team_id" db:"team_id"`
SourceID SourceID `json:"source_id" db:"source_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
QueryType SavedQueryType `json:"query_type" db:"query_type"`
QueryContent string `json:"query_content" db:"query_content"` // JSON string of SavedQueryContent
IsBookmarked bool `json:"is_bookmarked" db:"is_bookmarked"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
TeamName string `json:"team_name,omitempty"`
SourceName string `json:"source_name,omitempty"`
}
SavedTeamQuery represents a saved query associated with a team
type Session ¶
type Session struct {
ID SessionID `db:"id" json:"id"`
UserID UserID `db:"user_id" json:"user_id"`
ExpiresAt time.Time `db:"expires_at" json:"expires_at"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
}
Session represents a user session
type SessionID ¶
type SessionID string
SessionID represents a unique session identifier (redacted in logs for security)
type Source ¶
type Source struct {
ID SourceID `db:"id" json:"id"`
Name string `db:"name" json:"name"`
MetaIsAutoCreated bool `db:"_meta_is_auto_created" json:"_meta_is_auto_created"`
MetaTSField string `db:"_meta_ts_field" json:"_meta_ts_field"`
MetaSeverityField string `db:"_meta_severity_field" json:"_meta_severity_field"`
Connection ConnectionInfo `db:"connection" json:"connection"`
Description string `db:"description" json:"description,omitempty"`
TTLDays int `db:"ttl_days" json:"ttl_days"`
Timestamps
IsConnected bool `db:"-" json:"is_connected"`
Schema string `db:"-" json:"schema,omitempty"`
Columns []ColumnInfo `db:"-" json:"columns,omitempty"`
// Enhanced schema information
Engine string `db:"-" json:"engine,omitempty"`
EngineParams []string `db:"-" json:"engine_params,omitempty"`
SortKeys []string `db:"-" json:"sort_keys,omitempty"`
// Provisioning
Managed bool `db:"managed" json:"managed"`
SecretRef string `db:"secret_ref" json:"secret_ref,omitempty"`
}
Source represents a ClickHouse data source in our system
func (*Source) GetFullTableName ¶
GetFullTableName returns the fully qualified table name (database.table)
func (*Source) ToResponse ¶
func (s *Source) ToResponse() *SourceResponse
ToResponse converts a Source to a SourceResponse, removing sensitive information
type SourceHealth ¶
type SourceHealth struct {
SourceID SourceID `json:"source_id"`
Status HealthStatus `json:"status"`
Error string `json:"error,omitempty"`
LastChecked time.Time `json:"last_checked"`
}
SourceHealth represents the health status of a source
type SourceResponse ¶
type SourceResponse struct {
ID SourceID `json:"id"`
Name string `json:"name"`
MetaIsAutoCreated bool `json:"_meta_is_auto_created"`
MetaTSField string `json:"_meta_ts_field"`
MetaSeverityField string `json:"_meta_severity_field"`
Connection ConnectionInfoResponse `json:"connection"`
Description string `json:"description,omitempty"`
TTLDays int `json:"ttl_days"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
IsConnected bool `json:"is_connected"`
Schema string `json:"schema,omitempty"`
Columns []ColumnInfo `json:"columns,omitempty"`
// Enhanced schema information
Engine string `json:"engine,omitempty"`
EngineParams []string `json:"engine_params,omitempty"`
SortKeys []string `json:"sort_keys,omitempty"`
}
SourceResponse represents a Source for API responses, with sensitive information removed
type SourceWithTeams ¶
type SourceWithTeams struct {
Source *SourceResponse `json:"source"`
Teams []*Team `json:"teams"`
}
SourceWithTeams represents a source along with the teams that have access to it
type TableSchema ¶
type TableSchema struct {
Columns []ColumnInfo `json:"columns"`
}
TableSchema represents a table's schema information
type Team ¶
type Team struct {
ID TeamID `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
MemberCount int `db:"-" json:"member_count"`
Timestamps
Managed bool `db:"managed" json:"managed"`
}
Team represents a team in the system
type TeamGroupedQuery ¶
type TeamGroupedQuery struct {
TeamID TeamID `json:"team_id"`
TeamName string `json:"team_name"`
Queries []*SavedTeamQuery `json:"queries"`
}
TeamGroupedQuery represents a query grouped by team
type TeamMember ¶
type TeamMember struct {
TeamID TeamID `db:"team_id" json:"team_id"`
UserID UserID `db:"user_id" json:"user_id"`
Role TeamRole `db:"role" json:"role"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
Email string `db:"email" json:"email,omitempty"`
FullName string `db:"full_name" json:"full_name,omitempty"`
}
TeamMember represents a user's membership in a team
type TeamQuery ¶
type TeamQuery struct {
ID int `json:"id" db:"id"`
TeamID TeamID `json:"team_id" db:"team_id"`
SourceID SourceID `json:"source_id" db:"source_id"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
QueryType SavedQueryType `json:"query_type" db:"query_type"`
QueryContent string `json:"query_content" db:"query_content"`
Timestamps
}
TeamQuery represents a saved query in a team
type TeamRole ¶
type TeamRole string
TeamRole represents the possible team member roles
const ( // TeamRoleOwner represents the owner of a team TeamRoleOwner TeamRole = "owner" // TeamRoleAdmin represents a team admin TeamRoleAdmin TeamRole = "admin" // TeamRoleEditor represents a team editor with collection management permissions TeamRoleEditor TeamRole = "editor" // TeamRoleMember represents a regular team member TeamRoleMember TeamRole = "member" )
type TemplateVariable ¶ added in v1.2.0
type TemplateVariable struct {
Name string `json:"name"` // Variable name (without braces)
Type string `json:"type"` // "string", "text", "number", or "date"
Value interface{} `json:"value"` // The value to substitute
}
TemplateVariable represents a variable for SQL template substitution. Variables in the SQL query (e.g., {{from_date}}) will be replaced with their values.
type TestAlertQueryRequest ¶ added in v0.6.0
type TestAlertQueryRequest struct {
QueryType AlertQueryType `json:"query_type"`
Query string `json:"query"`
ConditionJSON string `json:"condition_json"`
LookbackSeconds int `json:"lookback_seconds"`
ThresholdOperator AlertThresholdOperator `json:"threshold_operator"`
ThresholdValue float64 `json:"threshold_value"`
}
TestAlertQueryRequest allows testing an alert query before saving.
type TestAlertQueryResponse ¶ added in v0.6.0
type TestAlertQueryResponse struct {
Value float64 `json:"value"`
ThresholdMet bool `json:"threshold_met"`
ExecutionTimeMs int64 `json:"execution_time_ms"`
RowsReturned int `json:"rows_returned"`
Warnings []string `json:"warnings"`
}
TestAlertQueryResponse returns the result of a test query execution with performance metrics.
type ThemePreference ¶ added in v1.3.0
type ThemePreference string
ThemePreference represents the UI theme preference.
const ( ThemePreferenceLight ThemePreference = "light" ThemePreferenceDark ThemePreference = "dark" ThemePreferenceAuto ThemePreference = "auto" )
type Timestamps ¶
type Timestamps struct {
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
Timestamps provides common timestamp fields used across multiple models
type TimezonePreference ¶ added in v1.3.0
type TimezonePreference string
TimezonePreference represents the preferred timezone display.
const ( TimezonePreferenceLocal TimezonePreference = "local" TimezonePreferenceUTC TimezonePreference = "utc" )
type UpdateAlertRequest ¶ added in v0.6.0
type UpdateAlertRequest struct {
Name *string `json:"name"`
Description *string `json:"description"`
QueryType *AlertQueryType `json:"query_type"`
Query *string `json:"query"`
ConditionJSON *string `json:"condition_json"`
LookbackSeconds *int `json:"lookback_seconds"`
ThresholdOperator *AlertThresholdOperator `json:"threshold_operator"`
ThresholdValue *float64 `json:"threshold_value"`
FrequencySeconds *int `json:"frequency_seconds"`
Severity *AlertSeverity `json:"severity"`
Labels *map[string]string `json:"labels"`
Annotations *map[string]string `json:"annotations"`
RecipientUserIDs *[]UserID `json:"recipient_user_ids"`
WebhookURLs *[]string `json:"webhook_urls"`
GeneratorURL *string `json:"generator_url"`
IsActive *bool `json:"is_active"`
}
UpdateAlertRequest defines updatable fields for an alert rule.
type UpdateSourceRequest ¶ added in v1.3.0
type UpdateSourceRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
TTLDays *int `json:"ttl_days,omitempty"`
Host *string `json:"host,omitempty"`
Username *string `json:"username,omitempty"`
Password *string `json:"password,omitempty"`
Database *string `json:"database,omitempty"`
TableName *string `json:"table_name,omitempty"`
}
UpdateSourceRequest represents a request to update a data source. All fields are pointers to allow partial updates - nil means "don't change".
func (*UpdateSourceRequest) HasConnectionChanges ¶ added in v1.3.0
func (r *UpdateSourceRequest) HasConnectionChanges() bool
HasConnectionChanges returns true if any connection-related fields are being updated. When connection changes, re-validation is required.
type UpdateTeamQueryRequest ¶
type UpdateTeamQueryRequest struct {
Name string `json:"name"`
Description string `json:"description"`
SourceID SourceID `json:"source_id"`
QueryType SavedQueryType `json:"query_type"`
QueryContent string `json:"query_content"`
}
UpdateTeamQueryRequest represents a request to update a team query
type UpdateUserPreferencesRequest ¶ added in v1.3.0
type UpdateUserPreferencesRequest struct {
Theme *ThemePreference `json:"theme,omitempty"`
Timezone *TimezonePreference `json:"timezone,omitempty"`
DisplayMode *DisplayModePreference `json:"display_mode,omitempty"`
FieldsPanelOpen *bool `json:"fields_panel_open,omitempty"`
}
UpdateUserPreferencesRequest represents a partial update to user preferences.
type UpdateUserRequest ¶
type UpdateUserRequest struct {
Email string `json:"email,omitempty"`
FullName string `json:"full_name,omitempty"`
Role UserRole `json:"role,omitempty"`
Status UserStatus `json:"status,omitempty"`
}
UpdateUserRequest represents a request to update a user
type User ¶
type User struct {
ID UserID `json:"id" db:"id"`
Email string `json:"email" db:"email"`
FullName string `json:"full_name" db:"full_name"`
Role UserRole `json:"role" db:"role"`
Status UserStatus `json:"status" db:"status"`
LastLoginAt *time.Time `json:"last_login_at,omitempty" db:"last_login_at"`
LastActiveAt *time.Time `json:"last_active_at,omitempty" db:"last_active_at"`
Timestamps
Managed bool `json:"managed" db:"managed"`
}
User represents a user in the system
type UserPreferences ¶ added in v1.3.0
type UserPreferences struct {
Theme ThemePreference `json:"theme"`
Timezone TimezonePreference `json:"timezone"`
DisplayMode DisplayModePreference `json:"display_mode"`
FieldsPanelOpen bool `json:"fields_panel_open"`
}
UserPreferences represents persisted user preferences.
type UserStatus ¶
type UserStatus string
UserStatus represents the possible user statuses
const ( // UserStatusActive represents an active user account UserStatusActive UserStatus = "active" // UserStatusInactive represents an inactive/suspended user account UserStatusInactive UserStatus = "inactive" )
type UserTeamDetails ¶ added in v0.2.2
type UserTeamDetails struct {
ID TeamID `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
MemberCount int `json:"member_count"`
Role TeamRole `json:"role"`
}
UserTeamDetails represents the details of a team a user is part of, including their role.
type ValidateConnectionRequest ¶
type ValidateConnectionRequest struct {
ConnectionInfo
TimestampField string `json:"timestamp_field"`
SeverityField string `json:"severity_field"`
}
ValidateConnectionRequest represents a request to validate a connection