Documentation
¶
Overview ¶
Package metrics stores task resource samples from the agents in VictoriaMetrics and reads them back for the dashboard (§9.1).
Index ¶
- Variables
- func Relabel(r io.Reader, names map[string]ServiceName) ([]byte, error)
- type Labeled
- type NetworkResult
- type Result
- type RouteTraffic
- type Sample
- type Scope
- type Series
- type ServiceName
- type ServiceNames
- type Store
- func (s *Store) Add(node string, ms []*agentv1.TaskMetrics)
- func (s *Store) AddNode(node string, hb *agentv1.Heartbeat)
- func (s *Store) Database(ctx context.Context, databaseID string, d time.Duration, now time.Time) (Result, error)
- func (s *Store) Explore(ctx context.Context, q string, start, end time.Time, step int) ([]Labeled, bool, error)
- func (s *Store) Import(ctx context.Context, text string) error
- func (s *Store) Instant(ctx context.Context, q string) ([]Sample, error)
- func (s *Store) MetricNames(ctx context.Context) ([]string, error)
- func (s *Store) Network(ctx context.Context, d time.Duration, now time.Time) (NetworkResult, error)
- func (s *Store) Node(ctx context.Context, node string, d time.Duration, now time.Time) (Result, error)
- func (s *Store) Overview(ctx context.Context, d time.Duration, now time.Time) (Result, error)
- func (s *Store) Query(ctx context.Context, sc Scope, d time.Duration, now time.Time) (Result, error)
- func (s *Store) RecordController(ctx context.Context, heapBytes uint64, goroutines int) error
- func (s *Store) Run(ctx context.Context)
- func (s *Store) Scaling(ctx context.Context, serviceID string, d time.Duration, now time.Time) (Result, error)
- func (s *Store) ScrapeTraefik(ctx context.Context, metricsURL, edge string, names ServiceNames, ...)
- func (s *Store) ScrapeTraefikOnce(ctx context.Context, metricsURL, edge string, names ServiceNames) error
- func (s *Store) Traffic(ctx context.Context, sc TrafficScope, d time.Duration, now time.Time) (Result, error)
- func (s *Store) TrafficSummary(ctx context.Context, sc TrafficScope, window time.Duration) ([]RouteTraffic, error)
- type Talker
- type TrafficScope
Constants ¶
This section is empty.
Variables ¶
var ErrDisabled = errors.New("metrics storage is not configured")
ErrDisabled means no VictoriaMetrics is configured.
var Ranges = map[string]time.Duration{"15m": 15 * time.Minute, "1h": time.Hour, "6h": 6 * time.Hour, "24h": 24 * time.Hour, "7d": 7 * 24 * time.Hour}
Ranges the dashboard offers, with their query step.
Functions ¶
Types ¶
type Labeled ¶
type Labeled struct {
Labels map[string]string `json:"labels"`
Points [][2]float64 `json:"points"` // [unix ms, value]
}
Labeled is a series of an ad-hoc query with all its labels.
type NetworkResult ¶
type NetworkResult struct {
Result
TopServices []Talker `json:"topServices"`
TopTasks []Talker `json:"topTasks"`
}
NetworkResult is the Network › Traffic data (§8.4): per-node throughput on all interfaces and over the mesh, and the busiest services and tasks.
type Result ¶
type Result struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
Step int `json:"stepSeconds"`
Charts map[string][]Series `json:"charts"` // cpu, memory, netRx, netTx, diskRead, diskWrite
}
Result holds the charts of one query.
type RouteTraffic ¶
type RouteTraffic struct {
ServiceID string `json:"serviceId"`
Project string `json:"project"`
Environment string `json:"environment"`
Service string `json:"service"`
RPS float64 `json:"rps"`
Errors4xx float64 `json:"errors4xx"` // per second
Errors5xx float64 `json:"errors5xx"` // per second
P50Ms float64 `json:"p50Ms"`
P95Ms float64 `json:"p95Ms"`
BytesIn float64 `json:"bytesIn"` // per second
BytesOut float64 `json:"bytesOut"` // per second
}
RouteTraffic is one service's traffic over the summary window.
type Scope ¶
type Scope struct {
ServiceID string // one service, a series per task
Project string // or a whole environment, a series per service
Environment string
}
Scope selects the tasks to chart and how to group them.
type Series ¶
type Series struct {
Key string `json:"key"` // task ID or service name
Node string `json:"node"` // per-task series only
Points [][2]float64 `json:"points"` // [unix ms, value]
}
Series is one line on a chart.
type ServiceName ¶ added in v0.1.4
type ServiceName struct{ ID, Project, Environment, Name string }
ServiceName is the service a Traefik service's metrics are labelled with.
type ServiceNames ¶
type ServiceNames func(ctx context.Context) map[string]ServiceName
ServiceNames maps service IDs ("svc_ab12") and custom domains' route names ("dom-xy34") to their service, for labelling Traefik's metrics.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Add ¶
func (s *Store) Add(node string, ms []*agentv1.TaskMetrics)
Add queues samples from a node's heartbeat; it never blocks.
func (*Store) AddNode ¶
AddNode queues a node's own counters from its heartbeat: network traffic on all interfaces and over the mesh (§8.4).
func (*Store) Database ¶
func (s *Store) Database(ctx context.Context, databaseID string, d time.Duration, now time.Time) (Result, error)
Database charts a managed database over the last d (Phase 12): operations, memory against maxmemory, clients, keys, hit rate, evictions and expirations, replication lag, CPU and network, a series per member where it helps.
func (*Store) Explore ¶
func (s *Store) Explore(ctx context.Context, q string, start, end time.Time, step int) ([]Labeled, bool, error)
Explore runs a PromQL range query (Metrics explorer, §9.1). step <= 0 picks one that gives about 240 points.
func (*Store) Instant ¶
Instant runs a MetricsQL instant query; NaN and infinite values are left out.
func (*Store) MetricNames ¶
MetricNames lists the stored metric names (for the explorer's suggestions).
func (*Store) Network ¶
Network charts node and mesh throughput over d and ranks the busiest services and tasks over the last 5 minutes.
func (*Store) Node ¶
func (s *Store) Node(ctx context.Context, node string, d time.Duration, now time.Time) (Result, error)
Node charts one node over the last d for its page: CPU, memory and disk (used and total, bytes), load, network and mesh throughput, running tasks, and the CPU and memory of its tasks by service.
func (*Store) Overview ¶
Overview charts the whole cluster over the last d for the dashboard's Overview (§10.2): per-node CPU, memory, disk, load and task counts, node network throughput, requests and latency over every route, and the controller process. Every chart is a fixed window, so old points fall off.
func (*Store) Query ¶
func (s *Store) Query(ctx context.Context, sc Scope, d time.Duration, now time.Time) (Result, error)
Query returns CPU (percent of one core), memory (bytes) and network and disk throughput (bytes/s) over the last d.
func (*Store) RecordController ¶
RecordController writes the controller process's own gauges.
func (*Store) Scaling ¶
func (s *Store) Scaling(ctx context.Context, serviceID string, d time.Duration, now time.Time) (Result, error)
Scaling charts an autoscaled service: desired and running tasks, and the policy's metric against its target (§5.5).
func (*Store) ScrapeTraefik ¶
func (s *Store) ScrapeTraefik(ctx context.Context, metricsURL, edge string, names ServiceNames, interval time.Duration)
ScrapeTraefik copies Traefik's request metrics (§5.7, §9.1) into VictoriaMetrics every interval until ctx ends. Each series gets the SynCloud labels service_id, project, environment and app, and edge (the node Traefik runs on).
func (*Store) ScrapeTraefikOnce ¶
func (s *Store) ScrapeTraefikOnce(ctx context.Context, metricsURL, edge string, names ServiceNames) error
ScrapeTraefikOnce imports one scrape (edge nodes are scraped by their manager).
func (*Store) Traffic ¶
func (s *Store) Traffic(ctx context.Context, sc TrafficScope, d time.Duration, now time.Time) (Result, error)
Traffic charts requests per second by status class, latency percentiles (ms), bandwidth (bytes/s) and, beyond one service, requests per service, from Traefik's metrics (§5.7).
func (*Store) TrafficSummary ¶
func (s *Store) TrafficSummary(ctx context.Context, sc TrafficScope, window time.Duration) ([]RouteTraffic, error)
TrafficSummary returns every route's traffic over the last window, busiest first.
type Talker ¶
type Talker struct {
Key string `json:"key"` // task ID or project/env/service
Node string `json:"node,omitempty"`
Owner string `json:"owner,omitempty"` // a task's service
RxBps float64 `json:"rxBps"`
TxBps float64 `json:"txBps"`
}
Talker is a task's or service's recent throughput.
type TrafficScope ¶
TrafficScope selects the routes to chart: one service, a project environment, or every service (all fields empty). The platform's own routes (the dashboard and its API, the registry) are never included: the dashboard's polling is not traffic.