-
Notifications
You must be signed in to change notification settings - Fork 10
/
types.go
114 lines (101 loc) · 4.21 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2020-present Datadog, Inc.
package v2
// Task represents a task as returned by the ECS metadata API v2.
type Task struct {
ClusterName string `json:"Cluster"`
Containers []Container `json:"Containers"`
KnownStatus string `json:"KnownStatus"`
TaskARN string `json:"TaskARN"`
Family string `json:"Family"`
Version string `json:"Revision"`
Limits map[string]float64 `json:"Limits"`
DesiredStatus string `json:"DesiredStatus"`
AvailabilityZone string `json:"AvailabilityZone"`
ContainerInstanceTags map[string]string `json:"ContainerInstanceTags,omitempty"` // undocumented
TaskTags map[string]string `json:"TaskTags,omitempty"` // undocumented
}
// Container represents a container within a task.
type Container struct {
Name string `json:"Name"`
Limits map[string]uint64 `json:"Limits"`
ImageID string `json:"ImageID,omitempty"`
StartedAt string `json:"StartedAt"` // 2017-11-17T17:14:07.781711848Z
DockerName string `json:"DockerName"`
Type string `json:"Type"`
Image string `json:"Image"`
Labels map[string]string `json:"Labels"`
KnownStatus string `json:"KnownStatus"`
DesiredStatus string `json:"DesiredStatus"`
DockerID string `json:"DockerID"`
CreatedAt string `json:"CreatedAt"`
Networks []Network `json:"Networks"`
Ports []Port `json:"Ports"`
}
// Network represents the network of a container
type Network struct {
NetworkMode string `json:"NetworkMode"` // as of today the only supported mode is awsvpc
IPv4Addresses []string `json:"IPv4Addresses"` // one-element list
}
// Port represents the ports of a container
type Port struct {
ContainerPort uint16 `json:"ContainerPort,omitempty"`
Protocol string `json:"Protocol,omitempty"`
HostPort uint16 `json:"HostPort,omitempty"`
}
// ContainerStats represents the statistics of a container as returned by the
// ECS metadata API v2.
type ContainerStats struct {
CPU CPUStats `json:"cpuStats"`
Memory MemStats `json:"memoryStats"`
IO IOStats `json:"blkioStats"`
Network NetStats `json:"network"`
//Pids []int32 `json:"pidsStats"` // seems to be always empty
}
// CPUStats represents an ECS container CPU usage
type CPUStats struct {
Usage CPUUsage `json:"cpuUsage"`
System uint64 `json:"systemCpuUsage"`
}
// CPUUsage represents the details of ECS container CPU usage
type CPUUsage struct {
Total uint64 `json:"totalUsage"`
Usermode uint64 `json:"usageInUsermode"`
Kernelmode uint64 `json:"usageInKernelmode"`
}
// MemStats represents an ECS container memory usage
type MemStats struct {
Details DetailedMem `json:"stats"`
Limit uint64 `json:"limit"`
MaxUsage uint64 `json:"maxUsage"`
Usage uint64 `json:"usage"`
}
// DetailedMem stores detailed stats about memory usage
type DetailedMem struct {
RSS uint64 `json:"rss"`
Cache uint64 `json:"cache"`
PgFault uint64 `json:"pgfault"`
}
// IOStats represents an ECS container IO throughput
type IOStats struct {
BytesPerDeviceAndKind []OPStat `json:"ioServiceBytesRecursive"`
OPPerDeviceAndKind []OPStat `json:"ioServicedRecursive"`
ReadBytes uint64 // calculated by aggregating OPStats
WriteBytes uint64 // calculated by aggregating OPStats
}
// OPStat stores a value (amount of op or bytes) for a kind of operation and a specific block device.
type OPStat struct {
Major int64 `json:"major"`
Minor int64 `json:"minor"`
Kind string `json:"op"`
Value uint64 `json:"value"`
}
// NetStats represents an ECS container network usage
type NetStats struct {
RxBytes uint64 `json:"rxBytes"`
RxPackets uint64 `json:"rxPackets"`
TxBytes uint64 `json:"txBytes"`
TxPackets uint64 `json:"txPackets"`
}