Documentation
¶
Overview ¶
Package raw fetches raw system-level metrics as they are presented by the operating system
Package raw fetches raw system-level metrics as they are presented by the operating system
Index ¶
- Constants
- Variables
- func CanAccessDir(dir string) bool
- func DetectHostRoot(hostRoot string, pathExists func(string) bool) (string, error)
- func ParseStatFileContentUint64(filePath string) (uint64, error)
- type Blkio
- type BlkioEntry
- type CPU
- type CachedInfoDockerClient
- type CgroupInfo
- type CgroupV1Detector
- type CgroupV1PathParser
- type CgroupV2Detector
- type CgroupV2PathGetter
- type CgroupV2PathParser
- type CgroupsV1Fetcher
- type CgroupsV1PathGetter
- type CgroupsV2Fetcher
- type DockerClient
- type DockerInformer
- type DockerInspector
- type Fetcher
- type Memory
- type Metrics
- type NetDevNetworkStatsGetter
- type Network
- type NetworkStatsGetter
- type Pids
- type PosixSystemCPUReader
- type SystemCPUReader
- type V2MountPoint
Constants ¶
const ( CgroupV1 = "1" CgroupV2 = "2" )
const ( CgroupSystemd = "systemd" CgroupGroupfs = "cgroupfs" )
Variables ¶
var ( ErrInvalidProcStatNumCPUFields = errors.New("invalid number of cpu fields") ErrInvalidProcStatFormat = errors.New("invalid stat format. Error trying to parse the '/proc/stat' file") )
Functions ¶
func CanAccessDir ¶ added in v1.3.0
CanAccessDir returns true if the the dir is accessible.
func DetectHostRoot ¶ added in v1.3.0
DetectHostRoot returns a path that is located on the hostRoot folder of the host and the `/host` folder on the integrations. If they existed in both hostRoot and /host, returns the /host path, assuming the integration is running in a container
func ParseStatFileContentUint64 ¶ added in v1.6.0
Gets uint64 parsed content of single value cgroup stat file This func has been extracted from utils.go on the cgroup repo since is unexported
Types ¶
type Blkio ¶
type Blkio struct { IoServiceBytesRecursive []BlkioEntry IoServicedRecursive []BlkioEntry }
Blkio stores multiple entries of the Block I/O stats
type BlkioEntry ¶
BlkioEntry stores basic information of a simple blkio operation
type CPU ¶
type CPU struct { TotalUsage uint64 UsageInUsermode uint64 UsageInKernelmode uint64 PercpuUsage []uint64 ThrottledPeriods uint64 ThrottledTimeNS uint64 SystemUsage uint64 OnlineCPUs uint }
CPU usage snapshot
func (*CPU) OnlineCPUsWithFallback ¶ added in v1.7.0
OnlineCPUsWithFallback gets onlineCPUs value falling back to percpuUsage length in case OnlineCPUs is not defined
type CachedInfoDockerClient ¶ added in v1.7.0
type CachedInfoDockerClient struct { DockerClient // contains filtered or unexported fields }
CachedInfoDockerClient Wraps a DockerClient indefinitely caching Info method first call.
func NewCachedInfoDockerClient ¶ added in v1.7.0
func NewCachedInfoDockerClient(c DockerClient) *CachedInfoDockerClient
NewCachedInfoDockerClient returns a client wrapper using the provided one.
type CgroupInfo ¶ added in v1.7.0
func GetCgroupInfo ¶ added in v1.7.0
func GetCgroupInfo(ctx context.Context, informer DockerInformer) (*CgroupInfo, error)
type CgroupV1Detector ¶ added in v1.7.0
type CgroupV1Detector interface {
Paths(hostRoot string, pid int) (CgroupsV1PathGetter, error)
}
type CgroupV1PathParser ¶ added in v1.7.0
type CgroupV1PathParser struct {
// contains filtered or unexported fields
}
func NewCgroupV1PathParser ¶ added in v1.7.0
func NewCgroupV1PathParser() *CgroupV1PathParser
func (*CgroupV1PathParser) Paths ¶ added in v1.7.0
func (cgd *CgroupV1PathParser) Paths(hostRoot string, pid int) (CgroupsV1PathGetter, error)
type CgroupV2Detector ¶ added in v1.7.0
type CgroupV2Detector interface {
Paths(hostRoot string, pid int) (CgroupV2PathGetter, error)
}
type CgroupV2PathGetter ¶ added in v1.7.0
type CgroupV2PathGetter interface {
// contains filtered or unexported methods
}
type CgroupV2PathParser ¶ added in v1.7.0
type CgroupV2PathParser struct {
// contains filtered or unexported fields
}
func NewCgroupV2PathParser ¶ added in v1.7.0
func NewCgroupV2PathParser() *CgroupV2PathParser
func (*CgroupV2PathParser) Paths ¶ added in v1.7.0
func (cgd *CgroupV2PathParser) Paths(hostRoot string, pid int) (CgroupV2PathGetter, error)
type CgroupsV1Fetcher ¶ added in v1.7.0
type CgroupsV1Fetcher struct {
// contains filtered or unexported fields
}
CgroupsV1Fetcher fetches the metrics that can be found in cgroups (v1) file system
func NewCgroupsV1Fetcher ¶ added in v1.7.0
func NewCgroupsV1Fetcher( hostRoot string, cgroupDetector CgroupV1Detector, systemCPUReader SystemCPUReader, networkStatsGetter NetworkStatsGetter, ) (*CgroupsV1Fetcher, error)
func (*CgroupsV1Fetcher) Fetch ¶ added in v1.7.0
func (cg *CgroupsV1Fetcher) Fetch(c types.ContainerJSON) (Metrics, error)
Fetch get the metrics that can be found in cgroups file system: TODO: populate also network from libcgroups
type CgroupsV1PathGetter ¶ added in v1.7.0
type CgroupsV1PathGetter interface {
// contains filtered or unexported methods
}
type CgroupsV2Fetcher ¶ added in v1.7.0
type CgroupsV2Fetcher struct {
// contains filtered or unexported fields
}
CgroupsV2Fetcher fetches the metrics that can be found in cgroups (v2) file system
func NewCgroupsV2Fetcher ¶ added in v1.7.0
func NewCgroupsV2Fetcher( hostRoot string, cgroupDriver string, cgroupDetector CgroupV2Detector, systemCPUReader SystemCPUReader, networkStatsGetter NetworkStatsGetter, ) (*CgroupsV2Fetcher, error)
NewCgroupsV2Fetcher creates a new cgroups data fetcher.
func (*CgroupsV2Fetcher) Fetch ¶ added in v1.7.0
func (cg *CgroupsV2Fetcher) Fetch(c types.ContainerJSON) (Metrics, error)
Fetch get the metrics that can be found in cgroups v2 file system Unlike v1, cgroup v2 has only single hierarchy.
type DockerClient ¶ added in v1.7.0
type DockerClient interface { DockerInspector ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) }
DockerClient defines the required methods to query docker.
type DockerInformer ¶ added in v1.7.0
Infomer implements a way to get system-wide information regarding to docker.
type DockerInspector ¶ added in v1.7.0
type DockerInspector interface { DockerInformer ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) }
DockerInspector includes `Informer` and a method to inspect a specific container.
type Fetcher ¶
type Fetcher interface {
Fetch(types.ContainerJSON) (Metrics, error)
}
Fetcher is the minimal abstraction of any raw metrics fetcher implementation
func NewCgroupsFetcher ¶ added in v1.3.0
func NewCgroupsFetcher( hostRoot string, cgroupInfo *CgroupInfo, systemCPUReader SystemCPUReader, networkStatsGetter NetworkStatsGetter, ) (Fetcher, error)
NewCgroupsFetcher creates the proper metrics fetcher for the used cgroups version.
type Memory ¶
type Memory struct { UsageLimit uint64 Cache uint64 RSS uint64 SwapUsage uint64 FuzzUsage uint64 KernelMemoryUsage uint64 SwapLimit uint64 SoftLimit uint64 }
Memory usage snapshot
type Metrics ¶
type Metrics struct { Time time.Time ContainerID string Memory Memory Network Network CPU CPU Pids Pids Blkio Blkio }
Metrics holds containers raw metric values as they are extracted from the system
type NetDevNetworkStatsGetter ¶ added in v1.7.0
type NetDevNetworkStatsGetter struct {
// contains filtered or unexported fields
}
func NewNetDevNetworkStatsGetter ¶ added in v1.7.0
func NewNetDevNetworkStatsGetter() *NetDevNetworkStatsGetter
func (*NetDevNetworkStatsGetter) GetForContainer ¶ added in v1.7.0
func (cd *NetDevNetworkStatsGetter) GetForContainer(hostRoot, pid, containerID string) (Network, error)
type Network ¶
type Network struct { RxBytes int64 RxDropped int64 RxErrors int64 RxPackets int64 TxBytes int64 TxDropped int64 TxErrors int64 TxPackets int64 }
Network transmission and receive metrics
type NetworkStatsGetter ¶ added in v1.7.0
type PosixSystemCPUReader ¶ added in v1.7.0
type PosixSystemCPUReader struct {
// contains filtered or unexported fields
}
func NewPosixSystemCPUReader ¶ added in v1.7.0
func NewPosixSystemCPUReader() PosixSystemCPUReader
func (PosixSystemCPUReader) ReadUsage ¶ added in v1.7.0
func (r PosixSystemCPUReader) ReadUsage() (uint64, error)
ReadUsage returns the host system's cpu usage in nanoseconds. An error is returned if the format of the underlying file does not match.
Uses /proc/stat defined by POSIX. Looks for the cpu statistics line and then sums up the first seven fields provided. See `man 5 proc` for details on specific field information.
type SystemCPUReader ¶ added in v1.7.0
type V2MountPoint ¶ added in v1.7.0
type V2MountPoint string