logs

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logs collects container output from agents into VictoriaLogs and serves queries and live tails (§9.2).

Index

Constants

View Source
const EdgeTraefikTaskID = "sys-edge-traefik"

EdgeTraefikTaskID is the Traefik replica on edge nodes (§8.5); its access lines carry the edge node.

View Source
const PlatformProject = "syncloud"

PlatformProject is the project of SynCloud's own components' lines.

View Source
const StreamAccess = "access"

StreamAccess holds Traefik's access log, one line per request (§5.7).

View Source
const StreamFirewall = "firewall"

StreamFirewall holds dropped connection attempts (§8.3).

View Source
const TraefikTaskID = "sys-traefik"

TraefikTaskID is the edge proxy's system task; its JSON access log becomes request lines of the services it routes to (§5.7).

Variables

View Source
var ErrUnavailable = errors.New("log store unavailable")

ErrUnavailable means VictoriaLogs could not be queried.

View Source
var FirewallFields = []string{"direction", "src", "src_name", "dst", "dst_name", "protocol", "port", "packets"}

FirewallFields are the fields of a drop line.

Functions

func ServiceIDOfRouter

func ServiceIDOfRouter(name string) string

ServiceIDOfRouter returns the SynCloud service ID in a Traefik router or service name ("svc-svc_ab12-http@http"), or "".

Types

type Count

type Count struct {
	Project, Environment, Service string
	Lines                         int
}

Count is how many lines one service wrote.

type Filter

type Filter struct {
	Project, Environment, Service, TaskID, Node string
	// Text is a plain substring search (never interpreted as a query).
	Text string
	// Stream "access" selects request lines and "firewall" drop lines; ""
	// means application logs (both are left out). Request lines of the
	// platform itself (the dashboard and its API, the registry) are left out
	// unless Project is PlatformProject.
	Stream string
	// Status is a status class of request lines: "2", "3", "4" or "5".
	Status string
	// Client selects request lines from one client IP.
	Client string
	// NoProject selects only lines outside any project (standalone
	// databases); Project must be "".
	NoProject bool
	// Before pages back (§14): the window then ends just before it
	// instead of now.
	Before time.Time
}

Filter selects lines; empty fields match everything.

func (Filter) LogsQL

func (f Filter) LogsQL(since time.Duration) string

LogsQL builds the query for f over the last `since`.

type Line

type Line struct {
	Time        time.Time `json:"time"`
	Project     string    `json:"project"`
	Environment string    `json:"environment"`
	Service     string    `json:"service"`
	TaskID      string    `json:"taskId"`
	Revision    string    `json:"revision,omitempty"`
	Node        string    `json:"node"`
	Stream      string    `json:"stream"`
	Level       string    `json:"level,omitempty"`
	Message     string    `json:"message"`
	// Fields of an access log line (stream "access"): method, host, path,
	// status, duration_ms, bytes, client, upstream, service_id.
	Fields map[string]string `json:"fields,omitempty"`
}

Line is one log line with its labels.

type Store

type Store struct {

	// OnIngest counts log volume per project and environment (metering).
	OnIngest func(project, environment string, bytes int)
	// contains filtered or unexported fields
}

func New

func New(st *store.Store, vlURL string, log *slog.Logger) *Store

func (*Store) Count

func (s *Store) Count(ctx context.Context, f Filter, level string, window time.Duration) ([]Count, error)

Count counts lines matching f (and level, when set) per service over the last window, for log-based alerts.

func (*Store) Emit

func (s *Store) Emit(l Line)

Emit stores a line produced by the controller itself (not an agent).

func (*Store) OnLogs

func (s *Store) OnLogs(node store.Node, b *agentv1.LogBatch)

OnLogs handles a batch from an agent: label, fan out to tails, queue for storage.

func (*Store) Query

func (s *Store) Query(ctx context.Context, f Filter, since time.Duration, limit int) ([]Line, error)

Query returns up to limit lines (newest last) matching f within since.

func (*Store) Run

func (s *Store) Run(ctx context.Context)

Run writes queued lines to VictoriaLogs in batches until ctx ends.

func (*Store) Tail

func (s *Store) Tail(f Filter) (<-chan Line, func())

Tail returns new lines matching f until cancel is called.

func (*Store) UpstreamCounts

func (s *Store) UpstreamCounts(ctx context.Context, window time.Duration) ([]UpstreamCount, error)

UpstreamCounts counts request lines per service and task over the last window: Traefik's metrics stop at the service, the access log names the task that answered.

type UpstreamCount

type UpstreamCount struct {
	ServiceID string `json:"serviceId"`
	Upstream  string `json:"upstream"`
	Requests  int    `json:"requests"`
}

UpstreamCount is how many requests one task (upstream address) of a service answered.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL