Documentation
¶
Overview ¶
Package metrics collects watchtower scan statistics and exports them via prometheus counters/gauges consumed by the /v1/metrics API.
Index ¶
- func ObservePollDuration(d time.Duration)
- func RegisterAPIRequest(endpoint, status string)
- func RegisterAuthCacheHit()
- func RegisterAuthCacheMiss()
- func RegisterDockerAPIError(operation string)
- func RegisterDockerAPIRetry(operation string)
- func RegisterEventReceived(action string)
- func RegisterEventReconnect()
- func RegisterEventTriggeredScan()
- func RegisterImageFallback()
- func RegisterRegistryRequest(host, operation, outcome string)
- func RegisterRegistryRetry(host string)
- func RegisterRollback()
- func RegisterScan(metric *Metric)
- func SetAuditCounts(managed, excluded, unmanaged, infrastructure int)
- func SetContainersInCooldown(count int)
- func SetLastScanTimestamp(t time.Time)
- func SetPollInterval(d time.Duration)
- type Metric
- type Metrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ObservePollDuration ¶ added in v1.11.0
ObservePollDuration records the duration of a full scan cycle.
func RegisterAPIRequest ¶ added in v1.11.0
func RegisterAPIRequest(endpoint, status string)
RegisterAPIRequest increments watchtower_api_requests_total. status is the HTTP response status code as a decimal string ("200", "401", …) — kept as a label so cardinality stays bounded to the codes we actually emit.
func RegisterAuthCacheHit ¶ added in v1.11.0
func RegisterAuthCacheHit()
RegisterAuthCacheHit increments watchtower_auth_cache_hits_total. Hit rate is the primary signal for whether the v1.9 bearer-token cache is earning its keep.
func RegisterAuthCacheMiss ¶ added in v1.11.0
func RegisterAuthCacheMiss()
RegisterAuthCacheMiss increments watchtower_auth_cache_misses_total. Each miss triggers an oauth exchange against the registry.
func RegisterDockerAPIError ¶ added in v1.11.0
func RegisterDockerAPIError(operation string)
RegisterDockerAPIError increments watchtower_docker_api_errors_total for a failed call into the Docker engine API.
func RegisterDockerAPIRetry ¶ added in v1.12.2
func RegisterDockerAPIRetry(operation string)
RegisterDockerAPIRetry increments watchtower_docker_api_retries_total. One increment per retry attempt (not per failed call), so a 3-attempt run that eventually succeeds adds 2.
func RegisterEventReceived ¶ added in v1.12.1
func RegisterEventReceived(action string)
RegisterEventReceived increments watchtower_events_received_total for one image event observed on the Docker engine event stream.
func RegisterEventReconnect ¶ added in v1.12.1
func RegisterEventReconnect()
RegisterEventReconnect increments watchtower_events_reconnects_total after the event stream has been re-established following a transient failure.
func RegisterEventTriggeredScan ¶ added in v1.12.1
func RegisterEventTriggeredScan()
RegisterEventTriggeredScan increments watchtower_events_triggered_scans_total each time a debounced burst of events fires a targeted scan.
func RegisterImageFallback ¶ added in v1.11.0
func RegisterImageFallback()
RegisterImageFallback increments watchtower_image_fallback_total. Fires when GetContainer fell back to inspecting by image reference because the source image ID was missing locally.
func RegisterRegistryRequest ¶ added in v1.11.0
func RegisterRegistryRequest(host, operation, outcome string)
RegisterRegistryRequest increments watchtower_registry_requests_total. operation is one of "challenge", "token", "digest" (from pkg/registry); outcome is one of "success", "error", "retried".
func RegisterRegistryRetry ¶ added in v1.11.0
func RegisterRegistryRetry(host string)
RegisterRegistryRetry increments watchtower_registry_retries_total.
func RegisterRollback ¶ added in v1.10.0
func RegisterRollback()
RegisterRollback increments watchtower_rollbacks_total. Called by the health gating flow when a replacement container was stopped and the previous image was restored.
func RegisterScan ¶
func RegisterScan(metric *Metric)
RegisterScan fetches a metric handler and enqueues a metric
func SetAuditCounts ¶ added in v1.11.0
func SetAuditCounts(managed, excluded, unmanaged, infrastructure int)
SetAuditCounts updates the managed / excluded / unmanaged / infrastructure container gauges. Called from the audit pass so a Grafana panel can show the watch-status breakdown without operators having to hit /v1/audit manually.
func SetContainersInCooldown ¶ added in v1.12.0
func SetContainersInCooldown(count int)
SetContainersInCooldown reports how many containers are currently awaiting their --image-cooldown window to elapse.
func SetLastScanTimestamp ¶ added in v1.11.0
SetLastScanTimestamp records the completion time of the latest scan cycle.
func SetPollInterval ¶ added in v1.11.0
SetPollInterval records the configured seconds between scheduled scans, derived from the active cron expression at startup.
Types ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics is the handler processing all individual scan metrics
func Default ¶
func Default() *Metrics
Default creates a new metrics handler if none exists, otherwise returns the existing one
func (*Metrics) HandleUpdate ¶
HandleUpdate dequeue the metric channel and processes it
func (*Metrics) QueueIsEmpty ¶
QueueIsEmpty checks whether any messages are enqueued in the channel