/
types.ts
255 lines (227 loc) · 6.86 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
import { AwsAuthDataSourceJsonData, AwsAuthDataSourceSecureJsonData } from '@grafana/aws-sdk';
import { DataFrame, DataSourceRef } from '@grafana/data';
import { DataQuery } from '@grafana/schema';
import * as raw from './dataquery.gen';
export * from './dataquery.gen';
export type CloudWatchQuery =
| raw.CloudWatchMetricsQuery
| raw.CloudWatchLogsQuery
| raw.CloudWatchAnnotationQuery
| CloudWatchDefaultQuery;
// We want to allow setting defaults for both Logs and Metrics queries
export type CloudWatchDefaultQuery = Omit<raw.CloudWatchLogsQuery, 'queryMode'> & raw.CloudWatchMetricsQuery;
export interface MultiFilters {
[key: string]: string[];
}
export type Direction = 'ASC' | 'DESC';
export type LogAction = 'GetQueryResults' | 'GetLogEvents' | 'StartQuery' | 'StopQuery';
export enum CloudWatchLogsQueryStatus {
Scheduled = 'Scheduled',
Running = 'Running',
Complete = 'Complete',
Failed = 'Failed',
Cancelled = 'Cancelled',
Timeout = 'Timeout',
}
export interface CloudWatchJsonData extends AwsAuthDataSourceJsonData {
timeField?: string;
database?: string;
customMetricsNamespaces?: string;
endpoint?: string;
// Time string like 15s, 10m etc, see rangeUtils.intervalToMs.
logsTimeout?: string;
// Used to create links if logs contain traceId.
tracingDatasourceUid?: string;
logGroups?: raw.LogGroup[];
/**
* @deprecated use logGroups
*/
defaultLogGroups?: string[];
}
export interface CloudWatchSecureJsonData extends AwsAuthDataSourceSecureJsonData {
accessKey?: string;
secretKey?: string;
}
export type CloudWatchLogsRequest = GetLogEventsRequest | StartQueryRequest | QueryParam;
export interface GetLogEventsRequest extends DataQuery {
/**
* The name of the log group.
*/
logGroupName: string;
/**
* The name of the log stream.
*/
logStreamName: string;
/**
* The start of the time range, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC. Events with a timestamp equal to this time or later than this time are included. Events with a timestamp earlier than this time are not included.
*/
startTime?: number;
/**
* The end of the time range, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC. Events with a timestamp equal to or later than this time are not included.
*/
endTime?: number;
/**
* The token for the next set of items to return. (You received this token from a previous call.) Using this token works only when you specify true for startFromHead.
*/
nextToken?: string;
/**
* The maximum number of log events returned. If you don't specify a value, the maximum is as many log events as can fit in a response size of 1 MB, up to 10,000 log events.
*/
limit?: number;
/**
* If the value is true, the earliest log events are returned first. If the value is false, the latest log events are returned first. The default value is false. If you are using nextToken in this operation, you must specify true for startFromHead.
*/
startFromHead?: boolean;
region: string;
}
export interface TSDBResponse<T = any> {
results: Record<string, TSDBQueryResult<T>>;
message?: string;
}
export interface TSDBQueryResult<T = any> {
refId: string;
series: TSDBTimeSeries[];
tables: Array<TSDBTable<T>>;
frames: DataFrame[];
error?: string;
meta?: any;
}
export interface TSDBTable<T = any> {
columns: Array<{ text: string }>;
rows: T[];
}
export interface DataQueryError<CloudWatchMetricsQuery> {
data?: {
message?: string;
error?: string;
results: Record<string, TSDBQueryResult<CloudWatchMetricsQuery>>;
};
message?: string;
}
export interface TSDBTimeSeries {
name: string;
points: TSDBTimePoint[];
tags?: Record<string, string>;
}
export type TSDBTimePoint = [number, number];
export interface LogGroupField {
/**
* The name of a log field.
*/
name: string;
/**
* The percentage of log events queried that contained the field.
*/
percent?: number;
}
export interface StartQueryRequest extends DataQuery {
/**
* The log group on which to perform the query. A StartQuery operation must include a logGroupNames or a logGroupName parameter, but not both.
*/
logGroupName?: string;
/**
* The list of log groups to be queried. You can include up to 20 log groups. A StartQuery operation must include a logGroupNames or a logGroupName parameter, but not both.
*/
logGroupNames?: string[] /* not quite deprecated yet, but will be soon */;
logGroups?: raw.LogGroup[];
/**
* The query string to use. For more information, see CloudWatch Logs Insights Query Syntax.
*/
queryString: string;
/**
* The maximum number of log events to return in the query. If the query string uses the fields command, only the specified fields and their values are returned. The default is 1000.
*/
limit?: number;
refId: string;
region: string;
}
export interface QueryParam extends DataQuery {
queryId: string;
refId: string;
limit?: number;
region: string;
statsGroups?: string[];
}
export interface MetricRequest {
from: string;
to: string;
queries: MetricQuery[];
debug?: boolean;
}
export interface MetricQuery {
[key: string]: any;
datasource?: DataSourceRef;
refId?: string;
maxDataPoints?: number;
intervalMs?: number;
}
export enum VariableQueryType {
Regions = 'regions',
Namespaces = 'namespaces',
Metrics = 'metrics',
DimensionKeys = 'dimensionKeys',
DimensionValues = 'dimensionValues',
EBSVolumeIDs = 'ebsVolumeIDs',
EC2InstanceAttributes = 'ec2InstanceAttributes',
ResourceArns = 'resourceARNs',
Statistics = 'statistics',
LogGroups = 'logGroups',
Accounts = 'accounts',
}
export interface OldVariableQuery extends DataQuery {
queryType: VariableQueryType;
namespace: string;
region: string;
metricName: string;
dimensionKey: string;
dimensionFilters: string;
ec2Filters: string;
instanceID: string;
attributeName: string;
resourceType: string;
tags: string;
}
export interface VariableQuery extends DataQuery {
queryType: VariableQueryType;
namespace: string;
region: string;
metricName: string;
dimensionKey: string;
dimensionFilters?: raw.Dimensions;
ec2Filters?: MultiFilters;
instanceID: string;
attributeName: string;
resourceType: string;
tags?: MultiFilters;
logGroupPrefix?: string;
accountId?: string;
}
export interface LegacyAnnotationQuery extends raw.MetricStat, DataQuery {
actionPrefix: string;
alarmNamePrefix: string;
alias: string;
builtIn: number;
datasource: any;
dimensions: raw.Dimensions;
enable: boolean;
expression: string;
hide: boolean;
iconColor: string;
id: string;
matchExact: boolean;
metricName: string;
name: string;
namespace: string;
period: string;
prefixMatching: boolean;
region: string;
statistic: string;
statistics: string[];
target: {
limit: number;
matchAny: boolean;
tags: any[];
type: string;
};
type: string;
}