Documentation
¶
Overview ¶
Package scrape is the agent's own scrape loop with per-node budgets, staleness, and coverage status.
Index ¶
Constants ¶
const ( ReasonTargetBudget = "target_budget" ReasonInvalid = "invalid_target" ReasonUnreachable = "unreachable" ReasonTimeout = "timeout" ReasonTLS = "tls" ReasonHTTPStatus = "http_status" ReasonParse = "parse" ReasonBodyLimit = "body_limit" ReasonCredentials = "credentials" ReasonError = "error" )
Reasons classify the last failure or drop of a target for coverage reporting.
const ( ServiceAccountTokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token" //nolint:gosec // a file path, not a credential ServiceAccountCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" )
Default in-pod credential paths used for kubelet scraping.
const ( AnnotationScrape = "prometheus.io/scrape" AnnotationPort = "prometheus.io/port" AnnotationPath = "prometheus.io/path" AnnotationScheme = "prometheus.io/scheme" )
Pod annotations for scrape discovery.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KubeletOptions ¶
type KubeletOptions struct {
Node string
// TokenFile and CAFile default to the pod ServiceAccount mount.
TokenFile string
CAFile string
InsecureSkipVerify bool
}
KubeletOptions configures KubeletTargets.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager runs one loop per accepted target.
func NewManager ¶
NewManager returns a Manager with defaults applied.
func (*Manager) ActiveSeries ¶
ActiveSeries is the number of scraped series currently held against the node budget.
func (*Manager) Status ¶
func (m *Manager) Status() []TargetStatus
Status returns every known target, dropped ones included, ordered by key.
type Options ¶
type Options struct {
Appendable storage.Appendable
Budgets Budgets
DefaultInterval time.Duration
DefaultTimeout time.Duration
MaxBodyBytes int64
Logger *slog.Logger
}
Options configures a Manager.
type Pod ¶
type Pod struct {
Namespace string
Name string
UID string
Node string
IP string
Phase string
Annotations map[string]string
Ports []PodPort
}
Pod is the subset of a pod needed for annotation discovery.
type Target ¶
type Target struct {
URL string
Labels map[string]string
BearerTokenFile string
TLS TLSConfig
Interval time.Duration
Timeout time.Duration
}
Target is one scrape endpoint; job and instance labels default to "scrape" and the URL host.
func KubeletTargets ¶
func KubeletTargets(nodeIP string, port int, o KubeletOptions) []Target
KubeletTargets returns the kubelet /metrics and /metrics/cadvisor targets for a node.
func PodTargets ¶
PodTargets returns targets for running annotated pods, one per declared TCP port without a port annotation.
type TargetStatus ¶
type TargetStatus struct {
Key string
URL string
Labels map[string]string
Health Health
Reason string
LastError string
LastScrape time.Time
LastDuration time.Duration
Samples int
Series int
SeriesDropped uint64
SamplesDropped uint64
AppendErrors uint64
}
TargetStatus reports one target for coverage.