{"modulePath":"github.com/dockerstack/amazon-ecs-agent","version":"v1.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package stats\n\n## Constants\n\n```go\nconst (\n\t// DockerExecDriverPath points to the docker exec driver path.\n\tDockerExecDriverPath = \"execdriver/native\"\n\n\t// SleepBetweenUsageDataCollection is the sleep duration between collecting usage data for a container.\n\tSleepBetweenUsageDataCollection = 500 * time.Millisecond\n\n\t// ContainerStatsBufferLength is the number of usage metrics stored in memory for a container. It is calculated as\n\t// Number of usage metrics gathered in a second (2) * 60 * Time duration in minutes to store the data for (2)\n\tContainerStatsBufferLength = 240\n)\n```\n\n```go\nconst (\n\t// BytesInMiB is the number of bytes in a MebiByte.\n\tBytesInMiB = 1024 * 1024\n)\n```\n\n## Types\n\n```go\ntype ContainerMetadata struct {\n\tDockerID *string `json:\"-\"`\n}\n```\nContainerMetadata contains meta-data information for a container.\n\n```go\ntype ContainerStats struct {\n\t// contains filtered or unexported fields\n}\n```\nContainerStats encapsulates the raw CPU and memory utilization from cgroup fs.\n\n```go\ntype ContainerStatsCollector interface {\n\t// contains filtered or unexported methods\n}\n```\nContainerStatsCollector defines methods to get container stats. This interface is defined to make testing easier.\n\n```go\ntype CronContainer struct {\n\t// contains filtered or unexported fields\n}\n```\nCronContainer abstracts methods to gather and aggregate utilization data for a container.\n\n```go\nfunc (container *CronContainer) StartStatsCron()\n```\nStartStatsCron starts a go routine to periodically pull usage data for the container.\n\n```go\nfunc (container *CronContainer) StopStatsCron()\n```\nStopStatsCron stops the periodic collection of usage data for the container..\n\n```go\ntype DockerContainerMetadataResolver struct {\n\t// contains filtered or unexported fields\n}\n```\nDockerContainerMetadataResolver implements ContainerMetadataResolver for DockerTaskEngine.\n\n```go\nfunc (resolver *DockerContainerMetadataResolver) ResolveTask(dockerID string) (*api.Task, error)\n```\nResolveTask resolves the task arn, given container id.\n\n```go\ntype DockerStatsEngine struct {\n\t// contains filtered or unexported fields\n}\n```\nDockerStatsEngine is used to monitor docker container events and to report utlization metrics of the same.\n\n```go\nfunc NewDockerStatsEngine(cfg *config.Config) *DockerStatsEngine\n```\nNewDockerStatsEngine creates a new instance of the DockerStatsEngine object. MustInit() must be called to initialize the fields of the new event listener.\n\n```go\nfunc (engine *DockerStatsEngine) GetInstanceMetrics() (*ecstcs.MetricsMetadata, []*ecstcs.TaskMetric, error)\n```\nGetInstanceMetrics gets all task metrics and instance metadata from stats engine.\n\n```go\nfunc (engine *DockerStatsEngine) Init() error\n```\nInit initializes the docker client's event engine. This must be called to subscribe to the docker's event stream.\n\n```go\nfunc (engine *DockerStatsEngine) MustInit(taskEngine ecsengine.TaskEngine, md *ecstcs.MetricsMetadata) error\n```\nMustInit initializes fields of the DockerStatsEngine object.\n\n```go\ntype Engine interface {\n\tGetInstanceMetrics() (*ecstcs.MetricsMetadata, []*ecstcs.TaskMetric, error)\n}\n```\nEngine defines methods to be implemented by the engine struct. It is defined to make testing easier.\n\n```go\ntype LibcontainerStatsCollector struct{}\n```\nLibcontainerStatsCollector implements ContainerStatsCollector.\n\n```go\ntype Queue struct {\n\t// contains filtered or unexported fields\n}\n```\nQueue abstracts a queue using UsageStats slice.\n\n```go\nfunc NewQueue(maxSize int) *Queue\n```\nNewQueue creates a queue.\n\n```go\nfunc (queue *Queue) Add(rawStat *ContainerStats)\n```\nAdd adds a new set of container stats to the queue.\n\n```go\nfunc (queue *Queue) GetCPUStatsSet() (*ecstcs.CWStatsSet, error)\n```\nGetCPUStatsSet gets the stats set for CPU utilization.\n\n```go\nfunc (queue *Queue) GetMemoryStatsSet() (*ecstcs.CWStatsSet, error)\n```\nGetMemoryStatsSet gets the stats set for memory utilization.\n\n```go\nfunc (queue *Queue) GetRawUsageStats(numStats int) ([]UsageStats, error)\n```\nGetRawUsageStats gets the array of most recent raw UsageStats, in descending order of timestamps.\n\n```go\nfunc (queue *Queue) Reset()\n```\nReset resets the stats queue.\n\n```go\ntype UsageStats struct {\n\tCPUUsagePerc      float32   `json:\"cpuUsagePerc\"`\n\tMemoryUsageInMegs uint32    `json:\"memoryUsageInMegs\"`\n\tTimestamp         time.Time `json:\"timestamp\"`\n\t// contains filtered or unexported fields\n}\n```\nUsageStats abstracts the format in which the queue stores data.\n\n","path":"github.com/dockerstack/amazon-ecs-agent/agent/stats","name":"stats","synopsis":"","isRedistributable":true}
