- Create VictoriaLogs client package - Implement Query method for LogsQL queries - Implement StatsQuery for time-series stats - Implement GetFacets for field facets - Implement GetStreamIDs for stream identification - Implement Tail for real-time log streaming - Add Ingest method for testing - Define all data models (LogEntry, QueryResult, etc.) - Add comprehensive error handling Closes #11 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
84 lines
2.2 KiB
Go
84 lines
2.2 KiB
Go
package vlogs
|
|
|
|
import "time"
|
|
|
|
// QueryParams represents parameters for a LogsQL query
|
|
type QueryParams struct {
|
|
Query string `json:"query"`
|
|
Start time.Time `json:"start,omitempty"`
|
|
End time.Time `json:"end,omitempty"`
|
|
Limit int `json:"limit,omitempty"`
|
|
Offset int `json:"offset,omitempty"`
|
|
}
|
|
|
|
// LogEntry represents a single log entry
|
|
type LogEntry struct {
|
|
Timestamp time.Time `json:"_time"`
|
|
StreamID string `json:"_stream_id,omitempty"`
|
|
Message string `json:"_msg"`
|
|
Fields map[string]interface{} `json:"fields,omitempty"`
|
|
}
|
|
|
|
// QueryResult represents the result of a query
|
|
type QueryResult struct {
|
|
Logs []LogEntry `json:"logs"`
|
|
TotalCount int `json:"total_count"`
|
|
Took int `json:"took_ms"`
|
|
}
|
|
|
|
// StatsParams represents parameters for a stats query
|
|
type StatsParams struct {
|
|
Query string `json:"query"`
|
|
Start time.Time `json:"start"`
|
|
End time.Time `json:"end"`
|
|
Step string `json:"step,omitempty"` // e.g., "5m", "1h"
|
|
}
|
|
|
|
// StatsResult represents the result of a stats query
|
|
type StatsResult struct {
|
|
Data []StatsDataPoint `json:"data"`
|
|
}
|
|
|
|
// StatsDataPoint represents a single data point in stats
|
|
type StatsDataPoint struct {
|
|
Timestamp time.Time `json:"timestamp"`
|
|
Values map[string]interface{} `json:"values"`
|
|
}
|
|
|
|
// FacetsParams represents parameters for getting facets
|
|
type FacetsParams struct {
|
|
Query string `json:"query"`
|
|
Start time.Time `json:"start"`
|
|
End time.Time `json:"end"`
|
|
Field string `json:"field,omitempty"`
|
|
}
|
|
|
|
// FacetsResult represents the result of a facets query
|
|
type FacetsResult struct {
|
|
Facets []Facet `json:"facets"`
|
|
}
|
|
|
|
// Facet represents a facet value with count
|
|
type Facet struct {
|
|
Value string `json:"value"`
|
|
Count int `json:"count"`
|
|
}
|
|
|
|
// StreamIDsParams represents parameters for getting stream IDs
|
|
type StreamIDsParams struct {
|
|
Query string `json:"query"`
|
|
Start time.Time `json:"start"`
|
|
End time.Time `json:"end"`
|
|
}
|
|
|
|
// StreamIDsResult represents the result of stream IDs query
|
|
type StreamIDsResult struct {
|
|
StreamIDs []string `json:"stream_ids"`
|
|
}
|
|
|
|
// TailParams represents parameters for tailing logs
|
|
type TailParams struct {
|
|
Query string `json:"query"`
|
|
Limit int `json:"limit,omitempty"`
|
|
}
|