Documentation
¶
Overview ¶
Package logs collects container output from agents into VictoriaLogs and serves queries and live tails (§9.2).
Index ¶
- Constants
- Variables
- func ServiceIDOfRouter(name string) string
- type Count
- type Filter
- type Line
- type Store
- func (s *Store) Count(ctx context.Context, f Filter, level string, window time.Duration) ([]Count, error)
- func (s *Store) Emit(l Line)
- func (s *Store) OnLogs(node store.Node, b *agentv1.LogBatch)
- func (s *Store) Query(ctx context.Context, f Filter, since time.Duration, limit int) ([]Line, error)
- func (s *Store) Run(ctx context.Context)
- func (s *Store) Tail(f Filter) (<-chan Line, func())
- func (s *Store) UpstreamCounts(ctx context.Context, window time.Duration) ([]UpstreamCount, error)
- type UpstreamCount
Constants ¶
const EdgeTraefikTaskID = "sys-edge-traefik"
EdgeTraefikTaskID is the Traefik replica on edge nodes (§8.5); its access lines carry the edge node.
const StreamAccess = "access"
StreamAccess holds Traefik's access log, one line per request (§5.7).
const StreamFirewall = "firewall"
StreamFirewall holds dropped connection attempts (§8.3).
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 ¶
ErrUnavailable means VictoriaLogs could not be queried.
var FirewallFields = []string{"direction", "src", "src_name", "dst", "dst_name", "protocol", "port", "packets"}
FirewallFields are the fields of a drop line.
Functions ¶
func ServiceIDOfRouter ¶
ServiceIDOfRouter returns the SynCloud service ID in a Traefik router or service name ("svc-svc_ab12-http@http"), or "".
Types ¶
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).
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.
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 (*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) OnLogs ¶
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) UpstreamCounts ¶
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.