-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathmonitor.py
More file actions
180 lines (139 loc) · 3.68 KB
/
monitor.py
File metadata and controls
180 lines (139 loc) · 3.68 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
__all__ = [
"MonitorDashboard",
"MonitorMetricsDefinition",
"MonitorService",
"MonitorServiceToken",
]
from dataclasses import dataclass, field
from typing import List, Optional
from linode_api4.objects import Base, JSONObject, Property, StrEnum
class AggregateFunction(StrEnum):
"""
Enum for supported aggregate functions.
"""
min = "min"
max = "max"
avg = "avg"
sum = "sum"
count = "count"
rate = "rate"
increase = "increase"
last = "last"
class ChartType(StrEnum):
"""
Enum for supported chart types.
"""
line = "line"
area = "area"
class ServiceType(StrEnum):
"""
Enum for supported service types.
"""
dbaas = "dbaas"
linode = "linode"
lke = "lke"
vpc = "vpc"
nodebalancer = "nodebalancer"
firewall = "firewall"
object_storage = "object_storage"
aclb = "aclb"
class MetricType(StrEnum):
"""
Enum for supported metric type
"""
gauge = "gauge"
counter = "counter"
histogram = "histogram"
summary = "summary"
class MetricUnit(StrEnum):
"""
Enum for supported metric units.
"""
COUNT = "count"
PERCENT = "percent"
BYTE = "byte"
SECOND = "second"
BITS_PER_SECOND = "bits_per_second"
MILLISECOND = "millisecond"
KB = "KB"
MB = "MB"
GB = "GB"
RATE = "rate"
BYTES_PER_SECOND = "bytes_per_second"
PERCENTILE = "percentile"
RATIO = "ratio"
OPS_PER_SECOND = "ops_per_second"
IOPS = "iops"
class DashboardType(StrEnum):
"""
Enum for supported dashboard types.
"""
standard = "standard"
custom = "custom"
@dataclass
class DashboardWidget(JSONObject):
"""
Represents a single widget in the widgets list.
"""
metric: str = ""
unit: MetricUnit = ""
label: str = ""
color: str = ""
size: int = 0
chart_type: ChartType = ""
y_label: str = ""
aggregate_function: AggregateFunction = ""
@dataclass
class Dimension(JSONObject):
"""
Represents a single dimension in the dimensions list.
"""
dimension_label: Optional[str] = None
label: Optional[str] = None
values: Optional[List[str]] = None
@dataclass
class MonitorMetricsDefinition(JSONObject):
"""
Represents a single metric definition in the metrics definition list.
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-information
"""
metric: str = ""
label: str = ""
metric_type: MetricType = ""
unit: MetricUnit = ""
scrape_interval: int = 0
is_alertable: bool = False
dimensions: Optional[List[Dimension]] = None
available_aggregate_functions: List[AggregateFunction] = field(
default_factory=list
)
class MonitorDashboard(Base):
"""
Dashboard details.
List dashboards: https://techdocs.akamai.com/linode-api/get-dashboards-all
"""
api_endpoint = "/monitor/dashboards/{id}"
properties = {
"id": Property(identifier=True),
"created": Property(is_datetime=True),
"label": Property(),
"service_type": Property(ServiceType),
"type": Property(DashboardType),
"widgets": Property(List[DashboardWidget]),
"updated": Property(is_datetime=True),
}
@dataclass
class MonitorService(JSONObject):
"""
Represents a single service type.
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-monitor-services
"""
service_type: ServiceType = ""
label: str = ""
@dataclass
class MonitorServiceToken(JSONObject):
"""
A token for the requested service_type.
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-get-token
"""
token: str = ""