ecsmetadata

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ecsmetadata queries ECS Metadata Server for ECS task metrics. This package is currently experimental and is subject to change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// HTTClient is the client to use when making HTTP requests when set.
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string) *Client

NewClient returns a new Client. endpoint is the metadata server endpoint.

func NewClientFromEnvironment added in v0.1.1

func NewClientFromEnvironment() (*Client, error)

NewClientFromEnvironment is like NewClient but endpoint is discovered from the environment.

func (*Client) RetrieveTaskMetadata

func (c *Client) RetrieveTaskMetadata(ctx context.Context) (*TaskMetadata, error)

func (*Client) RetrieveTaskStats

func (c *Client) RetrieveTaskStats(ctx context.Context) (map[string]*ContainerStats, error)

type ContainerStats

type ContainerStats struct {
	Name     string  `json:"name"`
	ID       string  `json:"id"`
	NumProcs float64 `json:"num_procs"`

	CPUStats    dockertypes.CPUStats    `json:"cpu_stats"`
	PreCPUStats dockertypes.CPUStats    `json:"precpu_stats"`
	MemoryStats dockertypes.MemoryStats `json:"memory_stats"`

	Networks map[string]struct {
		RxBytes   float64 `json:"rx_bytes"`
		RxPackets float64 `json:"rx_packets"`
		RxErrors  float64 `json:"rx_errors"`
		RxDropped float64 `json:"rx_dropped"`
		TxBytes   float64 `json:"tx_bytes"`
		TxPackets float64 `json:"tx_packets"`
		TxErrors  float64 `json:"tx_errors"`
		TxDropped float64 `json:"tx_dropped"`
	} `json:"networks"`

	NetworkRateStats struct {
		RxBytesPerSec float64 `json:"rx_bytes_per_sec"`
		TxBytesPerSec float64 `json:"tx_bytes_per_sec"`
	} `json:"network_rate_stats"`
}

type TaskMetadata

type TaskMetadata struct {
	Cluster          string `json:"Cluster"`
	TaskARN          string `json:"TaskARN"`
	Family           string `json:"Family"`
	Revision         string `json:"Revision"`
	DesiredStatus    string `json:"DesiredStatus"`
	KnownStatus      string `json:"KnownStatus"`
	AvailabilityZone string `json:"AvailabilityZone"`
	LaunchType       string `json:"LaunchType"`
	Containers       []struct {
		DockerID      string            `json:"DockerId"`
		Name          string            `json:"Name"`
		DockerName    string            `json:"DockerName"`
		Image         string            `json:"Image"`
		ImageID       string            `json:"ImageID"`
		Labels        map[string]string `json:"Labels"`
		DesiredStatus string            `json:"DesiredStatus"`
		KnownStatus   string            `json:"KnownStatus"`
		Type          string            `json:"Type"`
		ContainerARN  string            `json:"ContainerARN"`
	} `json:"Containers"`
}

Jump to

Keyboard shortcuts

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