Documentation
¶
Index ¶
- Constants
- func CGroupPathForPid(pid uint32) (string, error)
- func WaitForVictoriaLogs(ctx context.Context, address string, timeout time.Duration) bool
- type BatchLogWriter
- type BoundPort
- type DebugLogWriter
- type EntityStatus
- type LogEntry
- type LogReader
- func (l *LogReader) Read(ctx context.Context, id string, opts ...LogReaderOption) ([]LogEntry, error)
- func (l *LogReader) ReadBySandbox(ctx context.Context, sandboxID string, opts ...LogReaderOption) ([]LogEntry, error)
- func (l *LogReader) ReadStream(ctx context.Context, target LogTarget, logCh chan<- LogEntry, ...) error
- func (l *LogReader) TailStream(ctx context.Context, target LogTarget, logCh chan<- LogEntry, ...) error
- type LogReaderOption
- type LogStream
- type LogTarget
- type LogWriter
- type LogsMaintainer
- type PersistentLogReader
- type PersistentLogWriter
- type PortStatus
- type PortTracker
- type ResourcesMonitor
- type StatusMonitor
- type SystemLogHandler
Constants ¶
const DefaultLogReadLimit = 1000
const SystemLogEntityID = "system/miren-server"
SystemLogEntityID is the well-known entity ID for system/server logs.
Variables ¶
This section is empty.
Functions ¶
func CGroupPathForPid ¶
Types ¶
type BatchLogWriter ¶ added in v0.5.0
type BatchLogWriter struct {
// contains filtered or unexported fields
}
BatchLogWriter implements LogWriter by buffering entries and flushing them as a single NDJSON HTTP POST to VictoriaLogs. This reduces write pressure compared to one POST per log record.
func NewBatchLogWriter ¶ added in v0.5.0
func NewBatchLogWriter(writer *PersistentLogWriter) *BatchLogWriter
NewBatchLogWriter wraps a PersistentLogWriter with batching. Entries are buffered and flushed either every 250ms or when 50 entries accumulate, whichever comes first.
func (*BatchLogWriter) Close ¶ added in v0.5.0
func (b *BatchLogWriter) Close()
Close signals the background goroutine to perform a final flush and stop. It is safe to call multiple times.
func (*BatchLogWriter) WriteEntry ¶ added in v0.5.0
func (b *BatchLogWriter) WriteEntry(entity string, le LogEntry) error
WriteEntry marshals the entry to NDJSON and appends it to the internal buffer. It never blocks the caller — writes are best-effort.
type DebugLogWriter ¶
func NewDebugLogWriter ¶ added in v0.3.0
func NewDebugLogWriter(log *slog.Logger) *DebugLogWriter
NewDebugLogWriter creates a new DebugLogWriter.
func (*DebugLogWriter) WriteEntry ¶
func (d *DebugLogWriter) WriteEntry(entity string, le LogEntry) error
type EntityStatus ¶
type EntityStatus struct {
// contains filtered or unexported fields
}
func (*EntityStatus) Id ¶
func (e *EntityStatus) Id() string
type LogReader ¶
type LogReader struct {
Address string
Timeout time.Duration
// contains filtered or unexported fields
}
func NewLogReader ¶ added in v0.3.0
NewLogReader creates a new LogReader.
func (*LogReader) ReadBySandbox ¶
func (*LogReader) ReadStream ¶
func (l *LogReader) ReadStream(ctx context.Context, target LogTarget, logCh chan<- LogEntry, opts ...LogReaderOption) error
ReadStream queries historical logs and sends them to a channel as they're parsed. Unlike Read(), this has no limit and streams results incrementally.
func (*LogReader) TailStream ¶
func (l *LogReader) TailStream(ctx context.Context, target LogTarget, logCh chan<- LogEntry, opts ...LogReaderOption) error
TailStream connects to VictoriaLogs tail endpoint for live tailing. Blocks until context is cancelled.
type LogReaderOption ¶
type LogReaderOption func(*logReadOpts)
func WithFromTime ¶
func WithFromTime(t time.Time) LogReaderOption
func WithLimit ¶
func WithLimit(l int) LogReaderOption
type LogTarget ¶
type LogTarget struct {
EntityID string
SandboxID string
Filter string // Optional LogsQL filter expression (e.g., "error" or ~"regex")
}
LogTarget specifies what logs to query - either by entity ID or sandbox ID.
type LogsMaintainer ¶
type LogsMaintainer struct {
}
func NewLogsMaintainer ¶ added in v0.3.0
func NewLogsMaintainer() *LogsMaintainer
NewLogsMaintainer creates a new LogsMaintainer.
type PersistentLogReader ¶
type PersistentLogReader struct {
Address string
Timeout time.Duration
// contains filtered or unexported fields
}
func NewPersistentLogReader ¶ added in v0.3.0
func NewPersistentLogReader(address string, timeout time.Duration) *PersistentLogReader
NewPersistentLogReader creates a new PersistentLogReader.
type PersistentLogWriter ¶
type PersistentLogWriter struct {
Address string
Timeout time.Duration
// contains filtered or unexported fields
}
func NewPersistentLogWriter ¶ added in v0.3.0
func NewPersistentLogWriter(address string, timeout time.Duration) *PersistentLogWriter
NewPersistentLogWriter creates a new PersistentLogWriter.
func (*PersistentLogWriter) Client ¶
func (l *PersistentLogWriter) Client() *http.Client
func (*PersistentLogWriter) WriteEntry ¶
func (l *PersistentLogWriter) WriteEntry(entity string, le LogEntry) error
type PortStatus ¶
type PortStatus string
const ( PortStatusBound PortStatus = "bound" PortStatusUnbound PortStatus = "unbound" PortStatusActive PortStatus = "active" )
type PortTracker ¶
type PortTracker interface {
SetPortStatus(containerID string, bp BoundPort, status PortStatus)
}
type ResourcesMonitor ¶
type ResourcesMonitor struct {
Log *slog.Logger
Writer *metrics.VictoriaMetricsWriter
Reader *metrics.VictoriaMetricsReader
}
func NewResourcesMonitor ¶ added in v0.3.0
func NewResourcesMonitor(log *slog.Logger, writer *metrics.VictoriaMetricsWriter, reader *metrics.VictoriaMetricsReader) *ResourcesMonitor
NewResourcesMonitor creates a new ResourcesMonitor.
func (*ResourcesMonitor) LastestUsage ¶
func (m *ResourcesMonitor) LastestUsage(id string) (float64, uint64, error)
type StatusMonitor ¶
func NewStatusMonitor ¶ added in v0.3.0
func NewStatusMonitor(log *slog.Logger) *StatusMonitor
NewStatusMonitor creates a new StatusMonitor.
func (*StatusMonitor) EntityBoundPorts ¶
func (s *StatusMonitor) EntityBoundPorts(entity string) ([]BoundPort, error)
func (*StatusMonitor) FindBoundPort ¶
func (s *StatusMonitor) FindBoundPort(bp BoundPort) ([]*EntityStatus, error)
func (*StatusMonitor) SetPortStatus ¶
func (s *StatusMonitor) SetPortStatus(entity string, port BoundPort, status PortStatus)
type SystemLogHandler ¶ added in v0.5.0
type SystemLogHandler struct {
// contains filtered or unexported fields
}
SystemLogHandler is an slog.Handler that tees log records to both an underlying handler (typically stderr) and a VictoriaLogs log writer. This enables querying server logs through the same `miren logs system` interface used for application and sandbox logs.
func NewSystemLogHandler ¶ added in v0.5.0
func NewSystemLogHandler(inner slog.Handler, writer LogWriter) *SystemLogHandler
NewSystemLogHandler wraps an existing handler, adding a tee to the given log writer. All log records are written to VictoriaLogs under the SystemLogEntityID entity with source:"system".