awsecscontainermetrics

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributeECSDockerName        = "aws.ecs.docker.name"
	AttributeECSCluster           = "aws.ecs.cluster.name"
	AttributeECSTaskARN           = "aws.ecs.task.arn"
	AttributeECSTaskID            = "aws.ecs.task.id"
	AttributeECSTaskFamily        = "aws.ecs.task.family"
	AttributeECSTaskRevision      = "aws.ecs.task.version"
	AttributeECSServiceName       = "aws.ecs.service.name"
	AttributeECSTaskPullStartedAt = "aws.ecs.task.pull_started_at"
	AttributeECSTaskPullStoppedAt = "aws.ecs.task.pull_stopped_at"
	AttributeECSTaskKnownStatus   = "aws.ecs.task.known_status"
	AttributeECSTaskLaunchType    = "aws.ecs.task.launch_type"
	AttributeContainerImageID     = "aws.ecs.container.image.id"
	AttributeContainerCreatedAt   = "aws.ecs.container.created_at"
	AttributeContainerStartedAt   = "aws.ecs.container.started_at"
	AttributeContainerFinishedAt  = "aws.ecs.container.finished_at"
	AttributeContainerKnownStatus = "aws.ecs.container.know_status"
	AttributeContainerExitCode    = "aws.ecs.container.exit_code"

	CPUsInVCpu = 1024
	BytesInMiB = 1024 * 1024

	TaskPrefix      = "ecs.task."
	ContainerPrefix = "container."

	EndpointEnvKey   = "ECS_CONTAINER_METADATA_URI_V4"
	TaskStatsPath    = "/task/stats"
	TaskMetadataPath = "/task"

	AttributeMemoryUsage    = "memory.usage"
	AttributeMemoryMaxUsage = "memory.usage.max"
	AttributeMemoryLimit    = "memory.usage.limit"
	AttributeMemoryReserved = "memory.reserved"
	AttributeMemoryUtilized = "memory.utilized"

	AttributeCPUTotalUsage      = "cpu.usage.total"
	AttributeCPUKernelModeUsage = "cpu.usage.kernelmode"
	AttributeCPUUserModeUsage   = "cpu.usage.usermode"
	AttributeCPUSystemUsage     = "cpu.usage.system"
	AttributeCPUCores           = "cpu.cores"
	AttributeCPUOnlines         = "cpu.onlines"
	AttributeCPUReserved        = "cpu.reserved"
	AttributeCPUUtilized        = "cpu.utilized"
	AttributeCPUUsageInVCPU     = "cpu.usage.vcpu"

	AttributeNetworkRateRx = "network.rate.rx"
	AttributeNetworkRateTx = "network.rate.tx"

	AttributeNetworkRxBytes   = "network.io.usage.rx_bytes"
	AttributeNetworkRxPackets = "network.io.usage.rx_packets"
	AttributeNetworkRxErrors  = "network.io.usage.rx_errors"
	AttributeNetworkRxDropped = "network.io.usage.rx_dropped"
	AttributeNetworkTxBytes   = "network.io.usage.tx_bytes"
	AttributeNetworkTxPackets = "network.io.usage.tx_packets"
	AttributeNetworkTxErrors  = "network.io.usage.tx_errors"
	AttributeNetworkTxDropped = "network.io.usage.tx_dropped"

	AttributeStorageRead  = "storage.read_bytes"
	AttributeStorageWrite = "storage.write_bytes"

	AttributeDuration = "duration"

	UnitBytes       = "Bytes"
	UnitMegaBytes   = "Megabytes"
	UnitNanoSecond  = "Nanoseconds"
	UnitBytesPerSec = "Bytes/Second"
	UnitCount       = "Count"
	UnitVCpu        = "vCPU"
	UnitPercent     = "Percent"
	UnitSecond      = "Seconds"
)

Constant attributes for aws ecs container metrics.

Variables

This section is empty.

Functions

func GenerateDummyMetrics

func GenerateDummyMetrics() *agentmetricspb.ExportMetricsServiceRequest

GenerateDummyMetrics generates two dummy metrics TODO: Remove once this is replaced with actuall metrics generation code

func MetricsData added in v0.12.0

func MetricsData(containerStatsMap map[string]*ContainerStats, metadata TaskMetadata, logger *zap.Logger) []pdata.Metrics

MetricsData generates OTLP metrics from endpoint raw data

Types

type CPUStats added in v0.11.0

type CPUStats struct {
	CPUUsage       *CPUUsage `json:"cpu_usage,omitempty"`
	OnlineCpus     *uint64   `json:"online_cpus,omitempty"`
	SystemCPUUsage *uint64   `json:"system_cpu_usage,omitempty"`
	CPUUtilized    *uint64
	CPUReserved    *uint64
}

CPUStats defines Cpu stats

type CPUUsage added in v0.11.0

type CPUUsage struct {
	TotalUsage        *uint64   `json:"total_usage,omitempty"`
	UsageInKernelmode *uint64   `json:"usage_in_kernelmode,omitempty"`
	UsageInUserMode   *uint64   `json:"usage_in_usermode,omitempty"`
	PerCPUUsage       []*uint64 `json:"percpu_usage,omitempty"`
}

CPUUsage defines raw Cpu usage

type Client added in v0.12.0

type Client interface {
	Get(path string) ([]byte, error)
}

Client defines the rest client interface

type ClientProvider added in v0.12.0

type ClientProvider interface {
	BuildClient() Client
}

ClientProvider defines

func NewClientProvider added in v0.12.0

func NewClientProvider(endpoint url.URL, logger *zap.Logger) ClientProvider

NewClientProvider creates the default rest client provider

type ContainerMetadata added in v0.11.0

type ContainerMetadata struct {
	DockerID      string            `json:"DockerId,omitempty"`
	ContainerName string            `json:"Name,omitempty"`
	DockerName    string            `json:"DockerName,omitempty"`
	Image         string            `json:"Image,omitempty"`
	Labels        map[string]string `json:"Labels,omitempty"`
	Limits        Limit             `json:"Limits,omitempty"`
	ImageID       string            `json:"ImageID,omitempty"`
	CreatedAt     string            `json:"CreatedAt,omitempty"`
	StartedAt     string            `json:"StartedAt,omitempty"`
	FinishedAt    string            `json:"FinishedAt,omitempty"`
	KnownStatus   string            `json:"KnownStatus,omitempty"`
	ExitCode      *int64            `json:"ExitCode,omitempty"`
}

ContainerMetadata defines container metadata for a container

type ContainerStats added in v0.11.0

type ContainerStats struct {
	Name         string    `json:"name"`
	ID           string    `json:"id"`
	Read         time.Time `json:"read"`
	PreviousRead time.Time `json:"preread"`

	Memory      *MemoryStats            `json:"memory_stats,omitempty"`
	Disk        *DiskStats              `json:"blkio_stats,omitempty"`
	Network     map[string]NetworkStats `json:"networks,omitempty"`
	NetworkRate *NetworkRateStats       `json:"network_rate_stats,omitempty"`
	CPU         *CPUStats               `json:"cpu_stats,omitempty"`
	PreviousCPU *CPUStats               `json:"precpu_stats,omitempty"`
}

ContainerStats defines the structure for container stats

type DiskStats added in v0.11.0

type DiskStats struct {
	IoServiceBytesRecursives []IoServiceBytesRecursive `json:"io_service_bytes_recursive,omitempty"`
}

DiskStats defines the storage stats

type ECSMetrics added in v0.11.0

type ECSMetrics struct {
	MemoryUsage    uint64
	MemoryMaxUsage uint64
	MemoryLimit    uint64
	MemoryUtilized uint64
	MemoryReserved uint64

	CPUTotalUsage        uint64
	CPUUsageInKernelmode uint64
	CPUUsageInUserMode   uint64
	CPUOnlineCpus        uint64
	SystemCPUUsage       uint64
	NumOfCPUCores        uint64
	CPUReserved          float64
	CPUUtilized          float64
	CPUUsageInVCPU       float64

	NetworkRateRxBytesPerSecond float64
	NetworkRateTxBytesPerSecond float64

	NetworkRxBytes   uint64
	NetworkRxPackets uint64
	NetworkRxErrors  uint64
	NetworkRxDropped uint64
	NetworkTxBytes   uint64
	NetworkTxPackets uint64
	NetworkTxErrors  uint64
	NetworkTxDropped uint64

	StorageReadBytes  uint64
	StorageWriteBytes uint64
}

ECSMetrics defines the structure container/task level metrics

type HTTPRestClient added in v0.12.0

type HTTPRestClient struct {
	// contains filtered or unexported fields
}

HTTPRestClient is a thin wrapper around an ecs task metadata client, encapsulating endpoints and their corresponding http methods.

func NewRestClient added in v0.12.0

func NewRestClient(client Client) *HTTPRestClient

NewRestClient creates a new copy of the Rest Client

func (*HTTPRestClient) EndpointResponse added in v0.12.0

func (c *HTTPRestClient) EndpointResponse() ([]byte, []byte, error)

EndpointResponse gets the task metadata and docker stats from ECS Task Metadata Endpoint

type IoServiceBytesRecursive added in v0.11.0

type IoServiceBytesRecursive struct {
	Major *uint64 `json:"major,omitempty"`
	Minor *uint64 `json:"minor,omitempty"`
	Op    string  `json:"op,omitempty"`
	Value *uint64 `json:"value,omitempty"`
}

IoServiceBytesRecursive defines the IO device stats

type Limit added in v0.11.0

type Limit struct {
	CPU    *float64 `json:"CPU,omitempty"`
	Memory *uint64  `json:"Memory,omitempty"`
}

Limit defines the Cpu and Memory limts

type MemoryStats added in v0.11.0

type MemoryStats struct {
	Usage          *uint64 `json:"usage,omitempty"`
	MaxUsage       *uint64 `json:"max_usage,omitempty"`
	Limit          *uint64 `json:"limit,omitempty"`
	MemoryUtilized *uint64
	MemoryReserved *uint64
	Stats          map[string]uint64 `json:"stats,omitempty"`
}

MemoryStats defines the memory stats

type NetworkRateStats added in v0.11.0

type NetworkRateStats struct {
	RxBytesPerSecond *float64 `json:"rx_bytes_per_sec,omitempty"`
	TxBytesPerSecond *float64 `json:"tx_bytes_per_sec,omitempty"`
}

NetworkRateStats doesn't come from docker stat. The rates are being calculated in ECS agent

type NetworkStats added in v0.11.0

type NetworkStats struct {
	RxBytes   *uint64 `json:"rx_bytes,omitempty"`
	RxPackets *uint64 `json:"rx_packets,omitempty"`
	RxErrors  *uint64 `json:"rx_errors,omitempty"`
	RxDropped *uint64 `json:"rx_dropped,omitempty"`
	TxBytes   *uint64 `json:"tx_bytes,omitempty"`
	TxPackets *uint64 `json:"tx_packets,omitempty"`
	TxErrors  *uint64 `json:"tx_errors,omitempty"`
	TxDropped *uint64 `json:"tx_dropped,omitempty"`
}

NetworkStats defines the network stats

type RestClient added in v0.12.0

type RestClient interface {
	EndpointResponse() ([]byte, []byte, error)
}

RestClient is swappable for testing.

type StatsProvider added in v0.12.0

type StatsProvider struct {
	// contains filtered or unexported fields
}

StatsProvider wraps a RestClient, returning an unmarshaled metadata and docker stats

func NewStatsProvider added in v0.12.0

func NewStatsProvider(rc RestClient) *StatsProvider

NewStatsProvider returns a new stats provider

func (*StatsProvider) GetStats added in v0.12.0

func (p *StatsProvider) GetStats() (map[string]*ContainerStats, TaskMetadata, error)

GetStats calls the ecs task metadata endpoint and unmarshals the data

type TaskMetadata added in v0.11.0

type TaskMetadata struct {
	Cluster          string `json:"Cluster,omitempty"`
	TaskARN          string `json:"TaskARN,omitempty"`
	Family           string `json:"Family,omitempty"`
	Revision         string `json:"Revision,omitempty"`
	AvailabilityZone string `json:"AvailabilityZone,omitempty"`
	PullStartedAt    string `json:"PullStartedAt,omitempty"`
	PullStoppedAt    string `json:"PullStoppedAt,omitempty"`
	KnownStatus      string `json:"KnownStatus,omitempty"`
	LaunchType       string `json:"LaunchType,omitempty"`

	Limits     Limit               `json:"Limits,omitempty"`
	Containers []ContainerMetadata `json:"Containers,omitempty"`
}

TaskMetadata defines task metadata for a task

type TaskStats added in v0.11.0

type TaskStats struct {
	Memory            MemoryStats
	NetworkRate       NetworkRateStats
	Network           NetworkStats
	CPU               CPUStats
	StorageReadBytes  *uint64
	StorageWriteBytes *uint64
}

TaskStats defines the stats for a task

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL