Documentation
¶
Index ¶
- type LogEvent
- type LogEvents
- type LogEventsMessageType
- type LogMetadata
- type LokiDirection
- type LokiLabelName
- type LokiLogHTTPOptions
- type LokiLogQuerier
- type LokiLogStreamOptions
- type LokiQueryData
- type LokiQueryResponse
- type LokiStreamResponse
- type MatrixSample
- type MatrixValue
- type Stream
- type StreamValue
- type VectorSample
- type VectorValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogEvent ¶
type LogEvent struct {
PodName string `json:"pod_name"`
Timestamp time.Time `json:"timestamp,omitempty"`
Message string `json:"message"`
Metadata LogMetadata `json:"metadata"`
}
LogEvent represents a log line event sent via SSE
func ParseLokiResponse ¶
func ParseLokiResponse(resp *http.Response, opts LokiLogHTTPOptions) ([]LogEvent, error)
ParseLokiResponse parses a Loki HTTP API response and returns LogEvents
type LogEvents ¶
type LogEvents struct {
MessageType LogEventsMessageType `json:"type"`
// LogEvents is a slice of log events
Logs []LogEvent `json:"logs"`
// Error message
ErrorMessage string `json:"error_message,omitempty"`
}
type LogEventsMessageType ¶
type LogEventsMessageType string
const ( LogEventsMessageTypeLog LogEventsMessageType = "log" LogEventsMessageTypeHeartbeat LogEventsMessageType = "heartbeat" LogEventsMessageTypeError LogEventsMessageType = "error" )
func (LogEventsMessageType) Schema ¶
func (u LogEventsMessageType) Schema(r huma.Registry) *huma.Schema
Register enum in OpenAPI specification https://github.com/danielgtaylor/huma/issues/621
type LogMetadata ¶
type LokiDirection ¶
type LokiDirection string
LokiDirection represents the direction in which to return logs, loki defaults to backward
const ( LokiDirectionForward LokiDirection = "forward" LokiDirectionBackward LokiDirection = "backward" )
func (LokiDirection) Schema ¶
func (u LokiDirection) Schema(r huma.Registry) *huma.Schema
Register enum in OpenAPI specification https://github.com/danielgtaylor/huma/issues/621
func (LokiDirection) Values ¶
func (LokiDirection) Values() (kinds []string)
Values provides list valid values for Enum.
type LokiLabelName ¶
type LokiLabelName string
const ( LokiLabelTeam LokiLabelName = "unbind_team" LokiLabelProject LokiLabelName = "unbind_project" LokiLabelEnvironment LokiLabelName = "unbind_environment" LokiLabelService LokiLabelName = "unbind_service" LokiLabelDeployment LokiLabelName = "unbind_deployment" LokiLabelBuild LokiLabelName = "unbind_deployment_build" )
type LokiLogHTTPOptions ¶
type LokiLogHTTPOptions struct {
Label LokiLabelName // Label to filter logs by
LabelValue string // Value of the label to filter logs by
RawFilter string // Raw logql filter string
// * Query range options
Start *time.Time // Start time for the query
End *time.Time // End time for the query
Since *time.Duration // Get logs from this time ago
// * Query options
Time *time.Time // Time for the query
// * Shared options
Limit *int // Number of log lines to get
Direction *LokiDirection // Direction of the logs (forward or backward)
}
LokiLogOptions represents options for querying logs from Loki query and query_range APIs
type LokiLogQuerier ¶
type LokiLogQuerier struct {
// contains filtered or unexported fields
}
func NewLokiLogger ¶
func NewLokiLogger(cfg *config.Config) (*LokiLogQuerier, error)
func (*LokiLogQuerier) QueryLokiLogs ¶
func (self *LokiLogQuerier) QueryLokiLogs( ctx context.Context, opts LokiLogHTTPOptions, ) ([]LogEvent, error)
QueryLokiLogs handles both instant queries (query) and range queries (query_range) based on the provided options
func (*LokiLogQuerier) StreamLokiPodLogs ¶
func (self *LokiLogQuerier) StreamLokiPodLogs( ctx context.Context, opts LokiLogStreamOptions, eventChan chan<- LogEvents, ) error
StreamLokiPodLogs streams logs from Loki tail API using WebSocket for multiple pods using a single connection
type LokiLogStreamOptions ¶
type LokiLogStreamOptions struct {
Label LokiLabelName // Label to filter logs by
LabelValue string // Value of the label to filter logs by
RawFilter string // Raw logql filter string
Since time.Duration // Get logs from this time ago
Limit int // Number of log lines to get
Start time.Time // Get logs from a specific time
}
LokiLogStreamOptions represents options for filtering and streaming logs from Loki
type LokiQueryData ¶
type LokiQueryData struct {
ResultType string `json:"resultType"`
Result json.RawMessage `json:"result"`
Stats json.RawMessage `json:"stats,omitempty"`
}
LokiQueryData contains the query result data
type LokiQueryResponse ¶
type LokiQueryResponse struct {
Status string `json:"status"`
Data LokiQueryData `json:"data"`
ErrorType string `json:"errorType,omitempty"`
Error string `json:"error,omitempty"`
}
* HTTP API Responses LokiQueryResponse represents the response structure from Loki HTTP API
type LokiStreamResponse ¶
type LokiStreamResponse struct {
Streams []struct {
Stream map[string]string `json:"stream"`
Values [][2]string `json:"values"` // [timestamp, message]
} `json:"streams"`
}
LokiStreamResponse represents the format of a Loki log stream response
type MatrixSample ¶
MatrixSample represents a sample in a matrix result
type MatrixValue ¶
type MatrixValue struct {
Metric map[string]string `json:"metric"`
Values []MatrixSample `json:"values"`
}
MatrixValue represents a series in a matrix result
type Stream ¶
type Stream struct {
Stream map[string]string `json:"stream"`
Values []StreamValue `json:"values"`
}
Stream represents a stream of logs for a specific set of labels
type StreamValue ¶
type StreamValue []string // [timestamp, message]
StreamValue represents a single log entry in a stream
type VectorSample ¶
VectorSample represents a sample in a vector result
type VectorValue ¶
type VectorValue struct {
Metric map[string]string `json:"metric"`
Value VectorSample `json:"value"`
}
VectorValue represents an instant vector sample