feat: Create VictoriaLogs HTTP Client (Issue #11)

- 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>
This commit is contained in:
Claude Code
2026-02-05 00:56:23 +03:00
parent 672cafb528
commit 158b9a1630
2 changed files with 362 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
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"`
}