/
types.ts
233 lines (200 loc) · 4.2 KB
/
types.ts
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import { DataSourceApi } from '@grafana/data';
import { SMDataSource } from 'datasource/DataSource';
// App Settings
export interface GlobalSettings {
// anything?
}
export enum IpVersion {
Any = 'Any',
V4 = 'V4',
V6 = 'V6',
}
export interface PingSettings {
ipVersion: IpVersion;
dontFragment: boolean;
}
export enum HttpMethod {
GET = 'GET',
HEAD = 'HEAD',
POST = 'POST',
PUT = 'PUT',
OPTIONS = 'OPTIONS',
DELETE = 'DELETE',
}
export enum HttpVersion {
HTTP1_0 = 'HTTP/1.0',
HTTP1_1 = 'HTTP/1.1',
HTTP2_0 = 'HTTP/2',
}
export enum DnsRecordType {
A = 'A',
AAAA = 'AAAA',
CNAME = 'CNAME',
MX = 'MX',
NS = 'NS',
PTR = 'PTR',
SOA = 'SOA',
SRV = 'SRV',
TXT = 'TXT',
}
export enum DnsProtocol {
TCP = 'TCP',
UDP = 'UDP',
}
export interface HeaderMatch {
header: string;
regexp: string;
allowMissing: boolean;
}
// HttpSettings provides the settings for a HTTP check.
export interface HttpSettings {
method: HttpMethod;
headers?: string[];
body?: string;
ipVersion: IpVersion;
noFollowRedirects: boolean;
tlsConfig?: TLSConfig;
// Authentication
bearerToken?: string;
basicAuth?: BasicAuth;
// validations
failIfSSL?: boolean;
failIfNotSSL?: boolean;
validStatusCodes?: number[];
validHTTPVersions?: HttpVersion[];
failIfBodyMatchesRegexp?: string[];
failIfBodyNotMatchesRegexp?: string[];
failIfHeaderMatchesRegexp?: HeaderMatch[];
failIfHeaderNotMatchesRegexp?: HeaderMatch[];
cacheBustingQueryParamName?: string;
}
export interface TLSConfig {
insecureSkipVerify: boolean;
caCert: string;
clientCert: string;
clientKey: string;
serverName: string;
}
export interface BasicAuth {
username: string;
password: string;
}
export interface DNSRRValidator {
failIfMatchesRegexp: string[];
failIfNotMatchesRegexp: string[];
}
// DnsSettings provides the settings for a DNS check.
export interface DnsSettings {
recordType: DnsRecordType;
server: string;
ipVersion: IpVersion;
protocol: DnsProtocol;
port: number;
// validation
validRCodes?: string[];
validateAnswerRRS?: DNSRRValidator;
validateAuthorityRRS?: DNSRRValidator;
validateAdditionalRRS?: DNSRRValidator;
}
export interface TcpSettings {
ipVersion: IpVersion;
tls: boolean;
tlsConfig?: TLSConfig;
queryResponse?: TCPQueryResponse[];
}
export interface TCPQueryResponse {
send: string;
expect: string;
startTLS: boolean;
}
export interface BaseObject {
id?: number;
tenantId?: number;
created?: number; // seconds
updated?: number; // seconds
}
export interface Label {
name: string;
value: string;
}
export interface Probe extends BaseObject {
name: string;
public: boolean;
latitude: number;
longitude: number;
region: string;
online: boolean;
onlineChange: number;
labels: Label[];
}
export interface Check extends BaseObject {
job: string;
target: string;
frequency: number;
offset?: number;
timeout: number;
enabled: boolean;
labels: Label[]; // Currently list of [name:value]... can it be Labels?
settings: Settings; //
// Link to probes
probes: number[];
}
export interface Settings {
http?: HttpSettings;
ping?: PingSettings;
dns?: DnsSettings;
tcp?: TcpSettings;
}
export enum CheckType {
HTTP = 'http',
PING = 'ping',
DNS = 'dns',
TCP = 'tcp',
}
export interface HostedInstance {
id: number;
orgSlug: string;
orgName: string;
clusterSlug: string;
clusterName: string;
type: string; // "prometheus" "logs",
name: string;
url: string;
description: string;
status: string;
currentActiveSeries: number;
currentDpm: number;
currentUsage: number;
}
export interface RegistrationInfo {
accessToken: string;
tenantInfo: {
id: number;
metricInstance: HostedInstance;
logInstance: HostedInstance;
};
instances: HostedInstance[];
}
export interface GrafanaInstances {
api: SMDataSource;
metrics?: DataSourceApi;
logs?: DataSourceApi;
}
export interface User {
email: string;
id: number;
isGrafanaAdmin: boolean;
isSignedIn: boolean;
orgId: number;
orgName: string;
orgRole: OrgRole;
}
export enum OrgRole {
ADMIN = 'Admin',
EDITOR = 'Editor',
VIEWER = 'Viewer',
}
export interface APIError {
status: number;
message: string;
}