/
index.ts
257 lines (213 loc) · 6.04 KB
/
index.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
256
257
import {
DataQuery,
DataSourceInstanceSettings,
DataSourceJsonData,
DataSourceSettings,
TableData,
} from '@grafana/data';
import Datasource from '../datasource';
export type AzureDataSourceSettings = DataSourceSettings<AzureDataSourceJsonData, AzureDataSourceSecureJsonData>;
export type AzureDataSourceInstanceSettings = DataSourceInstanceSettings<AzureDataSourceJsonData>;
export interface DatasourceValidationResult {
status: 'success' | 'error';
message: string;
title?: string;
}
export type AzureResultFormat = 'time_series' | 'table';
export enum AzureQueryType {
AzureMonitor = 'Azure Monitor',
ApplicationInsights = 'Application Insights',
InsightsAnalytics = 'Insights Analytics',
LogAnalytics = 'Azure Log Analytics',
AzureResourceGraph = 'Azure Resource Graph',
}
export interface AzureMonitorQuery extends DataQuery {
queryType: AzureQueryType;
format: string;
subscription: string;
subscriptions: string[];
azureMonitor: AzureMetricQuery;
azureLogAnalytics: AzureLogsQuery;
appInsights?: ApplicationInsightsQuery;
insightsAnalytics: InsightsAnalyticsQuery;
azureResourceGraph: AzureResourceGraphQuery;
}
/**
* Azure clouds known to Azure Monitor.
*/
export enum AzureCloud {
Public = 'AzureCloud',
China = 'AzureChinaCloud',
USGovernment = 'AzureUSGovernment',
Germany = 'AzureGermanCloud',
None = '',
}
export type AzureAuthType = 'msi' | 'clientsecret';
export type ConcealedSecret = symbol;
interface AzureCredentialsBase {
authType: AzureAuthType;
defaultSubscriptionId?: string;
}
export interface AzureManagedIdentityCredentials extends AzureCredentialsBase {
authType: 'msi';
}
export interface AzureClientSecretCredentials extends AzureCredentialsBase {
authType: 'clientsecret';
azureCloud?: string;
tenantId?: string;
clientId?: string;
clientSecret?: string | ConcealedSecret;
}
export type AzureCredentials = AzureManagedIdentityCredentials | AzureClientSecretCredentials;
export interface AzureDataSourceJsonData extends DataSourceJsonData {
cloudName: string;
azureAuthType?: AzureAuthType;
// monitor
tenantId?: string;
clientId?: string;
subscriptionId?: string;
// logs
azureLogAnalyticsSameAs?: boolean;
logAnalyticsTenantId?: string;
logAnalyticsClientId?: string;
logAnalyticsSubscriptionId?: string;
logAnalyticsDefaultWorkspace?: string;
// App Insights
appInsightsAppId?: string;
}
export interface AzureDataSourceSecureJsonData {
clientSecret?: string;
logAnalyticsClientSecret?: string;
appInsightsApiKey?: string;
}
export interface AzureMetricDimension {
dimension: string;
operator: 'eq'; // future proof
filter?: string; // *
}
export interface AzureMetricQuery {
resourceGroup: string | undefined;
resourceName: string | undefined;
metricDefinition: string | undefined;
metricNamespace: string | undefined;
metricName: string | undefined;
timeGrainUnit?: string;
timeGrain: string;
allowedTimeGrainsMs: number[];
aggregation: string | undefined;
dimensionFilters: AzureMetricDimension[];
alias: string;
top: string;
}
export interface AzureLogsQuery {
query: string;
resultFormat: string;
resource?: string;
/** @deprecated Queries should be migrated to use Resource instead */
workspace?: string;
}
export interface AzureResourceGraphQuery {
query: string;
resultFormat: string;
}
export interface ApplicationInsightsQuery {
metricName: string;
timeGrain: string;
timeGrainCount: string;
timeGrainType: string;
timeGrainUnit: string;
aggregation: string;
dimension: string[]; // Was string before 7.1
// dimensions: string[]; why is this metadata stored on the object!
dimensionFilter: string;
alias: string;
}
export interface InsightsAnalyticsQuery {
query: string;
resultFormat: string;
}
// Represents an errors that come back from frontend requests.
// Not totally sure how accurate this type is.
export type AzureMonitorErrorish = Error;
// Azure Monitor API Types
export interface AzureMonitorMetricsMetadataResponse {
value: AzureMonitorMetricMetadataItem[];
}
export interface AzureMonitorMetricMetadataItem {
id: string;
resourceId: string;
primaryAggregationType: string;
supportedAggregationTypes: string[];
name: AzureMonitorLocalizedValue;
dimensions?: AzureMonitorLocalizedValue[];
metricAvailabilities?: AzureMonitorMetricAvailabilityMetadata[];
}
export interface AzureMonitorMetricAvailabilityMetadata {
timeGrain: string;
retention: string;
}
export interface AzureMonitorLocalizedValue {
value: string;
localizedValue: string;
}
export interface AzureMonitorMetricDefinitionsResponse {
data: {
value: Array<{ name: string; type: string; location?: string }>;
};
status: number;
statusText: string;
}
export interface AzureMonitorResourceGroupsResponse {
data: {
value: Array<{ name: string }>;
};
status: number;
statusText: string;
}
export interface AzureLogsVariable {
text: string;
value: string;
}
export interface AzureLogsTableData extends TableData {
columns: AzureLogsTableColumn[];
rows: any[];
type: string;
}
export interface AzureLogsTableColumn {
text: string;
type: string;
}
export interface AzureMonitorOption<T = string> {
label: string;
value: T;
}
export interface AzureQueryEditorFieldProps {
query: AzureMonitorQuery;
datasource: Datasource;
subscriptionId: string;
variableOptionGroup: { label: string; options: AzureMonitorOption[] };
onQueryChange: (newQuery: AzureMonitorQuery) => void;
setError: (source: string, error: AzureMonitorErrorish | undefined) => void;
}
export interface AzureResourceSummaryItem {
subscriptionName: string;
resourceGroupName: string | undefined;
resourceName: string | undefined;
}
export interface RawAzureResourceGroupItem {
subscriptionURI: string;
subscriptionName: string;
resourceGroupURI: string;
resourceGroupName: string;
}
export interface RawAzureResourceItem {
id: string;
name: string;
subscriptionId: string;
resourceGroup: string;
type: string;
location: string;
}
export interface AzureGraphResponse<T = unknown> {
data: T;
}