@dipseth/opensearch-logs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +14 -0
- package/alerts/langfuse-usage.yaml +142 -0
- package/alerts/production-incidents.yaml +280 -0
- package/alerts/service-health.yaml +98 -0
- package/dashboards/langfuse-usage.yaml +57 -0
- package/dist/create-dashboards.d.ts +10 -0
- package/dist/create-dashboards.js +38 -0
- package/dist/create-dashboards.js.map +1 -0
- package/dist/interfaces/alert.interfaces.d.ts +323 -0
- package/dist/interfaces/alert.interfaces.js +6 -0
- package/dist/interfaces/alert.interfaces.js.map +1 -0
- package/dist/interfaces/dashboard-gen.interfaces.d.ts +33 -0
- package/dist/interfaces/dashboard-gen.interfaces.js +3 -0
- package/dist/interfaces/dashboard-gen.interfaces.js.map +1 -0
- package/dist/interfaces/interfaces.d.ts +312 -0
- package/dist/interfaces/interfaces.js +3 -0
- package/dist/interfaces/interfaces.js.map +1 -0
- package/dist/interfaces/playbook.interfaces.d.ts +140 -0
- package/dist/interfaces/playbook.interfaces.js +3 -0
- package/dist/interfaces/playbook.interfaces.js.map +1 -0
- package/dist/os-alert.d.ts +17 -0
- package/dist/os-alert.js +245 -0
- package/dist/os-alert.js.map +1 -0
- package/dist/os-dash.d.ts +9 -0
- package/dist/os-dash.js +53 -0
- package/dist/os-dash.js.map +1 -0
- package/dist/os-monitor.d.ts +12 -0
- package/dist/os-monitor.js +59 -0
- package/dist/os-monitor.js.map +1 -0
- package/dist/os-playbook.d.ts +9 -0
- package/dist/os-playbook.js +71 -0
- package/dist/os-playbook.js.map +1 -0
- package/dist/os-search.d.ts +11 -0
- package/dist/os-search.js +84 -0
- package/dist/os-search.js.map +1 -0
- package/dist/repositories/index.d.ts +1 -0
- package/dist/repositories/index.js +2 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/opensearch.repository.d.ts +51 -0
- package/dist/repositories/opensearch.repository.js +167 -0
- package/dist/repositories/opensearch.repository.js.map +1 -0
- package/dist/services/alert.service.d.ts +73 -0
- package/dist/services/alert.service.js +503 -0
- package/dist/services/alert.service.js.map +1 -0
- package/dist/services/dashboard-gen.service.d.ts +36 -0
- package/dist/services/dashboard-gen.service.js +162 -0
- package/dist/services/dashboard-gen.service.js.map +1 -0
- package/dist/services/dashboard.service.d.ts +33 -0
- package/dist/services/dashboard.service.js +428 -0
- package/dist/services/dashboard.service.js.map +1 -0
- package/dist/services/gchat.service.d.ts +45 -0
- package/dist/services/gchat.service.js +228 -0
- package/dist/services/gchat.service.js.map +1 -0
- package/dist/services/index.d.ts +8 -0
- package/dist/services/index.js +9 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/monitor.service.d.ts +18 -0
- package/dist/services/monitor.service.js +342 -0
- package/dist/services/monitor.service.js.map +1 -0
- package/dist/services/panel-layout.d.ts +21 -0
- package/dist/services/panel-layout.js +33 -0
- package/dist/services/panel-layout.js.map +1 -0
- package/dist/services/playbook-dashboard.service.d.ts +19 -0
- package/dist/services/playbook-dashboard.service.js +434 -0
- package/dist/services/playbook-dashboard.service.js.map +1 -0
- package/dist/services/playbook.service.d.ts +13 -0
- package/dist/services/playbook.service.js +621 -0
- package/dist/services/playbook.service.js.map +1 -0
- package/dist/services/search.service.d.ts +30 -0
- package/dist/services/search.service.js +885 -0
- package/dist/services/search.service.js.map +1 -0
- package/dist/utils/cli.d.ts +14 -0
- package/dist/utils/cli.js +90 -0
- package/dist/utils/cli.js.map +1 -0
- package/dist/utils/config.d.ts +20 -0
- package/dist/utils/config.js +104 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/service-registry.d.ts +15 -0
- package/dist/utils/service-registry.js +56 -0
- package/dist/utils/service-registry.js.map +1 -0
- package/dist/utils/template.d.ts +18 -0
- package/dist/utils/template.js +66 -0
- package/dist/utils/template.js.map +1 -0
- package/package.json +76 -0
- package/playbooks/error-investigation.yaml +45 -0
- package/playbooks/incident-triage.yaml +32 -0
- package/playbooks/post-deploy-validation.yaml +24 -0
- package/playbooks/service-deep-dive.yaml +42 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alert system types — OSD monitors, Google Chat Card v2, YAML profiles,
|
|
3
|
+
* health report structures, and CLI arguments.
|
|
4
|
+
*/
|
|
5
|
+
import type { AggFilter, TermsAgg, DateHistBucket, ScriptedMetric, ParsedLatency, TopHitsAgg } from "./interfaces.js";
|
|
6
|
+
export interface AlertProfile {
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
destination: DestinationDef;
|
|
10
|
+
card_templates: Record<string, string>;
|
|
11
|
+
monitors: Record<string, MonitorDef>;
|
|
12
|
+
thresholds?: Record<string, number | string>;
|
|
13
|
+
defaults?: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
export interface DestinationDef {
|
|
16
|
+
name: string;
|
|
17
|
+
type: "gchat" | "custom_webhook";
|
|
18
|
+
}
|
|
19
|
+
export interface MonitorDef {
|
|
20
|
+
description?: string;
|
|
21
|
+
schedule: ScheduleDef;
|
|
22
|
+
query: Record<string, unknown>;
|
|
23
|
+
index_pattern?: string;
|
|
24
|
+
trigger: TriggerDef;
|
|
25
|
+
card_template: string;
|
|
26
|
+
throttle?: ThrottleDef;
|
|
27
|
+
}
|
|
28
|
+
export interface ScheduleDef {
|
|
29
|
+
interval: number;
|
|
30
|
+
unit: "MINUTES" | "HOURS" | "DAYS";
|
|
31
|
+
}
|
|
32
|
+
export interface TriggerDef {
|
|
33
|
+
name: string;
|
|
34
|
+
severity: 1 | 2 | 3 | 4 | 5;
|
|
35
|
+
condition: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ThrottleDef {
|
|
38
|
+
value: number;
|
|
39
|
+
unit: "MINUTES" | "HOURS" | "DAYS";
|
|
40
|
+
}
|
|
41
|
+
/** Flat context for pre-flight template resolution. */
|
|
42
|
+
export interface TemplateContext {
|
|
43
|
+
thresholds: Record<string, number | string>;
|
|
44
|
+
defaults: Record<string, string>;
|
|
45
|
+
}
|
|
46
|
+
export interface OsdMonitorPayload {
|
|
47
|
+
type: "monitor";
|
|
48
|
+
name: string;
|
|
49
|
+
monitor_type: "query_level_monitor";
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
schedule: {
|
|
52
|
+
period: {
|
|
53
|
+
interval: number;
|
|
54
|
+
unit: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
inputs: OsdMonitorInput[];
|
|
58
|
+
triggers: OsdTriggerPayload[];
|
|
59
|
+
}
|
|
60
|
+
export interface OsdMonitorInput {
|
|
61
|
+
search: {
|
|
62
|
+
indices: string[];
|
|
63
|
+
query: Record<string, unknown>;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface OsdTriggerPayload {
|
|
67
|
+
name: string;
|
|
68
|
+
severity: string;
|
|
69
|
+
condition: {
|
|
70
|
+
script: {
|
|
71
|
+
source: string;
|
|
72
|
+
lang: "painless";
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
actions: OsdAction[];
|
|
76
|
+
}
|
|
77
|
+
export interface OsdAction {
|
|
78
|
+
name: string;
|
|
79
|
+
destination_id: string;
|
|
80
|
+
message_template: {
|
|
81
|
+
source: string;
|
|
82
|
+
lang: "mustache";
|
|
83
|
+
};
|
|
84
|
+
throttle_enabled: boolean;
|
|
85
|
+
throttle?: {
|
|
86
|
+
value: number;
|
|
87
|
+
unit: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export interface OsdDestinationPayload {
|
|
91
|
+
type: "custom_webhook";
|
|
92
|
+
name: string;
|
|
93
|
+
custom_webhook: {
|
|
94
|
+
scheme: string;
|
|
95
|
+
host: string;
|
|
96
|
+
port: number;
|
|
97
|
+
path: string;
|
|
98
|
+
query_params: Record<string, string>;
|
|
99
|
+
header_params: Record<string, string>;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Payload for POST _plugins/_notifications/configs (webhook channel). */
|
|
103
|
+
export interface NotificationChannelPayload {
|
|
104
|
+
config_id?: string;
|
|
105
|
+
config: {
|
|
106
|
+
name: string;
|
|
107
|
+
description: string;
|
|
108
|
+
config_type: "webhook";
|
|
109
|
+
is_enabled: boolean;
|
|
110
|
+
webhook: {
|
|
111
|
+
url: string;
|
|
112
|
+
header_params: Record<string, string>;
|
|
113
|
+
method: "POST";
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** Response from POST _plugins/_notifications/configs. */
|
|
118
|
+
export interface NotificationChannelResponse {
|
|
119
|
+
config_id: string;
|
|
120
|
+
}
|
|
121
|
+
/** Single channel entry from GET _plugins/_notifications/configs. */
|
|
122
|
+
export interface NotificationChannelEntry {
|
|
123
|
+
config_id: string;
|
|
124
|
+
last_updated_time_ms: number;
|
|
125
|
+
created_time_ms: number;
|
|
126
|
+
config: {
|
|
127
|
+
name: string;
|
|
128
|
+
description: string;
|
|
129
|
+
config_type: string;
|
|
130
|
+
is_enabled: boolean;
|
|
131
|
+
webhook?: {
|
|
132
|
+
url: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** Response from GET _plugins/_notifications/configs. */
|
|
137
|
+
export interface NotificationChannelListResponse {
|
|
138
|
+
start_index: number;
|
|
139
|
+
total_hits: number;
|
|
140
|
+
total_hit_relation: string;
|
|
141
|
+
config_list: NotificationChannelEntry[];
|
|
142
|
+
}
|
|
143
|
+
export interface OsdMonitorResponse {
|
|
144
|
+
_id: string;
|
|
145
|
+
_version: number;
|
|
146
|
+
monitor: OsdMonitorPayload & {
|
|
147
|
+
name: string;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Response from POST /_plugins/_alerting/monitors/_search.
|
|
151
|
+
* Note: _source contains the monitor fields directly (not nested under a "monitor" key). */
|
|
152
|
+
export interface OsdSearchMonitorsResponse {
|
|
153
|
+
hits: {
|
|
154
|
+
total: {
|
|
155
|
+
value: number;
|
|
156
|
+
};
|
|
157
|
+
hits: Array<{
|
|
158
|
+
_id: string;
|
|
159
|
+
_source: {
|
|
160
|
+
type: string;
|
|
161
|
+
name: string;
|
|
162
|
+
monitor_type: string;
|
|
163
|
+
enabled: boolean;
|
|
164
|
+
schedule: {
|
|
165
|
+
period: {
|
|
166
|
+
interval: number;
|
|
167
|
+
unit: string;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
}>;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export interface OsdExecuteResponse {
|
|
175
|
+
input_results: {
|
|
176
|
+
results: Array<{
|
|
177
|
+
query: Record<string, unknown>;
|
|
178
|
+
}>;
|
|
179
|
+
};
|
|
180
|
+
trigger_results: Record<string, {
|
|
181
|
+
triggered: boolean;
|
|
182
|
+
}>;
|
|
183
|
+
}
|
|
184
|
+
/** Structured result from listMonitors. */
|
|
185
|
+
export interface MonitorListItem {
|
|
186
|
+
id: string;
|
|
187
|
+
name: string;
|
|
188
|
+
enabled: boolean;
|
|
189
|
+
}
|
|
190
|
+
/** Top-level Google Chat message payload containing Card v2 cards. */
|
|
191
|
+
export interface GChatMessage {
|
|
192
|
+
cardsV2: GChatCardWrapper[];
|
|
193
|
+
}
|
|
194
|
+
export interface GChatCardWrapper {
|
|
195
|
+
cardId: string;
|
|
196
|
+
card: GChatCard;
|
|
197
|
+
}
|
|
198
|
+
export interface GChatCard {
|
|
199
|
+
header: GChatCardHeader;
|
|
200
|
+
sections: GChatSection[];
|
|
201
|
+
}
|
|
202
|
+
export interface GChatCardHeader {
|
|
203
|
+
title: string;
|
|
204
|
+
subtitle?: string;
|
|
205
|
+
imageUrl?: string;
|
|
206
|
+
imageType?: "CIRCLE" | "SQUARE";
|
|
207
|
+
}
|
|
208
|
+
export interface GChatSection {
|
|
209
|
+
header?: string;
|
|
210
|
+
widgets: GChatWidget[];
|
|
211
|
+
}
|
|
212
|
+
/** Union of all Google Chat Card v2 widget types we use. */
|
|
213
|
+
export type GChatWidget = GChatDecoratedTextWidget | GChatButtonListWidget | GChatColumnsWidget;
|
|
214
|
+
export interface GChatDecoratedTextWidget {
|
|
215
|
+
decoratedText: {
|
|
216
|
+
topLabel: string;
|
|
217
|
+
text: string;
|
|
218
|
+
wrapText?: boolean;
|
|
219
|
+
icon?: {
|
|
220
|
+
knownIcon: string;
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export interface GChatButtonListWidget {
|
|
225
|
+
buttonList: {
|
|
226
|
+
buttons: GChatButton[];
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
export interface GChatButton {
|
|
230
|
+
text: string;
|
|
231
|
+
onClick: {
|
|
232
|
+
openLink: {
|
|
233
|
+
url: string;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
color?: GChatColor;
|
|
237
|
+
}
|
|
238
|
+
export interface GChatColor {
|
|
239
|
+
red: number;
|
|
240
|
+
green: number;
|
|
241
|
+
blue: number;
|
|
242
|
+
alpha: number;
|
|
243
|
+
}
|
|
244
|
+
export interface GChatColumnsWidget {
|
|
245
|
+
columns: {
|
|
246
|
+
columnItems: GChatColumnItem[];
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
export interface GChatColumnItem {
|
|
250
|
+
horizontalSizeStyle: "FILL_AVAILABLE_SPACE" | "FILL_MINIMUM_SPACE";
|
|
251
|
+
horizontalAlignment: "START" | "CENTER" | "END";
|
|
252
|
+
verticalAlignment: "START" | "CENTER" | "END";
|
|
253
|
+
widgets: GChatWidget[];
|
|
254
|
+
}
|
|
255
|
+
export interface HealthReport {
|
|
256
|
+
env: string;
|
|
257
|
+
periodStart: string;
|
|
258
|
+
periodEnd: string;
|
|
259
|
+
totalLogs: number;
|
|
260
|
+
totalErrors: number;
|
|
261
|
+
status: HealthStatus;
|
|
262
|
+
patterns: HealthReportPattern[];
|
|
263
|
+
serviceErrors: HealthReportServiceError[];
|
|
264
|
+
latency: HealthReportLatency | null;
|
|
265
|
+
errorTrend: HealthReportTrendBucket[];
|
|
266
|
+
recentErrors: HealthReportError[];
|
|
267
|
+
dashboardUrl: string;
|
|
268
|
+
discoverUrl: string;
|
|
269
|
+
}
|
|
270
|
+
export type HealthStatus = "HEALTHY" | "WARNING" | "DEGRADED";
|
|
271
|
+
export interface HealthReportPattern {
|
|
272
|
+
name: string;
|
|
273
|
+
count: number;
|
|
274
|
+
}
|
|
275
|
+
export interface HealthReportServiceError {
|
|
276
|
+
service: string;
|
|
277
|
+
count: number;
|
|
278
|
+
description: string;
|
|
279
|
+
}
|
|
280
|
+
export interface HealthReportLatency {
|
|
281
|
+
tracked: number;
|
|
282
|
+
avg: number;
|
|
283
|
+
p50: number;
|
|
284
|
+
p95: number;
|
|
285
|
+
p99: number;
|
|
286
|
+
}
|
|
287
|
+
export interface HealthReportTrendBucket {
|
|
288
|
+
time: string;
|
|
289
|
+
count: number;
|
|
290
|
+
}
|
|
291
|
+
export interface HealthReportError {
|
|
292
|
+
timestamp: string;
|
|
293
|
+
service: string;
|
|
294
|
+
message: string;
|
|
295
|
+
}
|
|
296
|
+
/** Aggregation shape returned by the health report query. */
|
|
297
|
+
export interface HealthReportAggs {
|
|
298
|
+
total_requests: AggFilter;
|
|
299
|
+
latency_stats: AggFilter & {
|
|
300
|
+
parsed: ScriptedMetric<ParsedLatency>;
|
|
301
|
+
};
|
|
302
|
+
error_trend: AggFilter & {
|
|
303
|
+
over_time: TermsAgg<DateHistBucket>;
|
|
304
|
+
};
|
|
305
|
+
recent_errors: AggFilter & {
|
|
306
|
+
samples: TopHitsAgg;
|
|
307
|
+
};
|
|
308
|
+
/** Dynamic keys: pattern checks (e.g. HTTP_500s) and svc_5xx_{alias}. */
|
|
309
|
+
[key: string]: AggFilter | (AggFilter & Record<string, unknown>);
|
|
310
|
+
}
|
|
311
|
+
export type AlertMode = "create" | "list" | "test" | "delete" | "report";
|
|
312
|
+
export interface AlertArgs {
|
|
313
|
+
mode: AlertMode;
|
|
314
|
+
profile?: string;
|
|
315
|
+
monitor?: string;
|
|
316
|
+
service?: string;
|
|
317
|
+
dashboardUrl?: string;
|
|
318
|
+
webhookUrl?: string;
|
|
319
|
+
env: string;
|
|
320
|
+
hours: number;
|
|
321
|
+
dryRun: boolean;
|
|
322
|
+
json: boolean;
|
|
323
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.interfaces.js","sourceRoot":"","sources":["../../src/interfaces/alert.interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** YAML-driven dashboard generator types. */
|
|
2
|
+
export interface DashboardConfig {
|
|
3
|
+
name: string;
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
time_from?: string;
|
|
7
|
+
time_to?: string;
|
|
8
|
+
refresh_interval?: number;
|
|
9
|
+
header?: string;
|
|
10
|
+
metrics?: DashboardMetricDef[];
|
|
11
|
+
charts?: DashboardChartDef[];
|
|
12
|
+
markdown?: DashboardMarkdownDef[];
|
|
13
|
+
}
|
|
14
|
+
export interface DashboardMetricDef {
|
|
15
|
+
title: string;
|
|
16
|
+
query: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DashboardChartDef {
|
|
20
|
+
title: string;
|
|
21
|
+
width?: "half" | "full";
|
|
22
|
+
interval?: string;
|
|
23
|
+
series: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
export interface DashboardMarkdownDef {
|
|
26
|
+
title: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}
|
|
29
|
+
export interface DashboardGenArgs {
|
|
30
|
+
mode: "create" | "validate" | "delete";
|
|
31
|
+
config: string;
|
|
32
|
+
dryRun: boolean;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-gen.interfaces.js","sourceRoot":"","sources":["../../src/interfaces/dashboard-gen.interfaces.ts"],"names":[],"mappings":"AAAA,6CAA6C"}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/** Shared TypeScript interfaces for OpenSearch log tools. */
|
|
2
|
+
export interface OpenSearchConfig {
|
|
3
|
+
host: string;
|
|
4
|
+
port: string;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
/** Port for the data API (search, alerting). Defaults to 25060 (DO-managed). AWS uses 443. */
|
|
8
|
+
dataPort?: number;
|
|
9
|
+
/** Port for the Dashboards API (saved objects, Kibana UI). Defaults to 443. */
|
|
10
|
+
dashboardsPort?: number;
|
|
11
|
+
/** Index name prefix. Defaults to "python-services". Override for non-Python services. */
|
|
12
|
+
indexPrefix?: string;
|
|
13
|
+
/** Security tenant for dashboards API. Defaults to "global". */
|
|
14
|
+
tenant?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ServiceInfo {
|
|
17
|
+
logName: string;
|
|
18
|
+
nginxPrefix: string;
|
|
19
|
+
port: number;
|
|
20
|
+
description: string;
|
|
21
|
+
}
|
|
22
|
+
/** Any OpenSearch query DSL clause (bool, term, range, query_string, etc.). */
|
|
23
|
+
export type QueryClause = Record<string, unknown>;
|
|
24
|
+
/** Fields available on log documents in the _source. All optional because
|
|
25
|
+
* unstructured nginx logs only have @timestamp, log, environment, droplet_id. */
|
|
26
|
+
export interface LogSource {
|
|
27
|
+
"@timestamp"?: string;
|
|
28
|
+
log?: string;
|
|
29
|
+
service?: string;
|
|
30
|
+
level?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
message?: string;
|
|
33
|
+
timestamp?: string;
|
|
34
|
+
host?: string;
|
|
35
|
+
droplet_id?: string;
|
|
36
|
+
environment?: string;
|
|
37
|
+
status_code?: number;
|
|
38
|
+
duration_ms?: number;
|
|
39
|
+
endpoint?: string;
|
|
40
|
+
correlation_id?: string;
|
|
41
|
+
error_type?: string;
|
|
42
|
+
method?: string;
|
|
43
|
+
user_agent?: string;
|
|
44
|
+
client_ip?: string;
|
|
45
|
+
exc_info?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface SearchHit {
|
|
48
|
+
_id: string;
|
|
49
|
+
_source: LogSource;
|
|
50
|
+
}
|
|
51
|
+
export interface SearchResult<TAggs = Record<string, unknown>> {
|
|
52
|
+
hits: {
|
|
53
|
+
total: {
|
|
54
|
+
value: number;
|
|
55
|
+
relation: string;
|
|
56
|
+
};
|
|
57
|
+
hits: SearchHit[];
|
|
58
|
+
};
|
|
59
|
+
aggregations?: TAggs;
|
|
60
|
+
}
|
|
61
|
+
export interface CountResult {
|
|
62
|
+
count: number;
|
|
63
|
+
}
|
|
64
|
+
export interface ApiResponse {
|
|
65
|
+
_conflict?: boolean;
|
|
66
|
+
_not_found?: boolean;
|
|
67
|
+
_error?: boolean;
|
|
68
|
+
_code?: number;
|
|
69
|
+
_body?: string;
|
|
70
|
+
_reason?: string;
|
|
71
|
+
[key: string]: unknown;
|
|
72
|
+
}
|
|
73
|
+
/** Base result from any filter aggregation. */
|
|
74
|
+
export interface AggFilter {
|
|
75
|
+
doc_count: number;
|
|
76
|
+
}
|
|
77
|
+
/** Bucket from a terms aggregation. */
|
|
78
|
+
export interface TermsBucket<K extends string | number = string> {
|
|
79
|
+
key: K;
|
|
80
|
+
doc_count: number;
|
|
81
|
+
}
|
|
82
|
+
/** Bucket from a date_histogram aggregation. */
|
|
83
|
+
export interface DateHistBucket {
|
|
84
|
+
key: number;
|
|
85
|
+
key_as_string: string;
|
|
86
|
+
doc_count: number;
|
|
87
|
+
}
|
|
88
|
+
/** Result shape for a terms aggregation. */
|
|
89
|
+
export interface TermsAgg<B = TermsBucket> {
|
|
90
|
+
buckets: B[];
|
|
91
|
+
}
|
|
92
|
+
/** Result shape for a scripted_metric aggregation. */
|
|
93
|
+
export interface ScriptedMetric<V> {
|
|
94
|
+
value: V;
|
|
95
|
+
}
|
|
96
|
+
/** Result shape for a top_hits aggregation. */
|
|
97
|
+
export interface TopHitsAgg {
|
|
98
|
+
hits: SearchResult["hits"];
|
|
99
|
+
}
|
|
100
|
+
export interface ParsedLatency {
|
|
101
|
+
count: number;
|
|
102
|
+
avg: number;
|
|
103
|
+
p50: number;
|
|
104
|
+
p95: number;
|
|
105
|
+
p99: number;
|
|
106
|
+
}
|
|
107
|
+
/** Per-service bucket used by modeServices. */
|
|
108
|
+
export interface ServiceBucket extends TermsBucket {
|
|
109
|
+
errors: AggFilter;
|
|
110
|
+
client_errors: AggFilter;
|
|
111
|
+
latency: AggFilter & {
|
|
112
|
+
parsed: ScriptedMetric<ParsedLatency>;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** Per-service bucket used by modeReport (uses errors_5xx/errors_4xx names). */
|
|
116
|
+
export interface ReportServiceBucket extends TermsBucket {
|
|
117
|
+
errors_5xx: AggFilter;
|
|
118
|
+
errors_4xx: AggFilter;
|
|
119
|
+
latency: AggFilter & {
|
|
120
|
+
parsed: ScriptedMetric<ParsedLatency>;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/** Per-service bucket in modeErrors with status sub-aggregation. */
|
|
124
|
+
export interface ErrorServiceBucket extends TermsBucket {
|
|
125
|
+
by_status: TermsAgg<TermsBucket<number>>;
|
|
126
|
+
}
|
|
127
|
+
/** Per-service bucket in modeLatency with parsed latency. */
|
|
128
|
+
export interface LatencyServiceBucket extends TermsBucket {
|
|
129
|
+
parsed: ScriptedMetric<ParsedLatency>;
|
|
130
|
+
}
|
|
131
|
+
/** Date histogram bucket with parsed latency. */
|
|
132
|
+
export interface LatencyTimeBucket extends DateHistBucket {
|
|
133
|
+
parsed: ScriptedMetric<ParsedLatency>;
|
|
134
|
+
}
|
|
135
|
+
/** Date histogram bucket with p95_parsed latency (Phase 2 naming). */
|
|
136
|
+
export interface P95TimeBucket extends DateHistBucket {
|
|
137
|
+
p95_parsed: ScriptedMetric<ParsedLatency>;
|
|
138
|
+
}
|
|
139
|
+
/** modeDashboard aggregation results. */
|
|
140
|
+
export interface DashboardAggs {
|
|
141
|
+
total_requests: AggFilter;
|
|
142
|
+
latency_stats: AggFilter & {
|
|
143
|
+
parsed: ScriptedMetric<ParsedLatency>;
|
|
144
|
+
};
|
|
145
|
+
[key: string]: AggFilter;
|
|
146
|
+
}
|
|
147
|
+
/** modeLatency aggregation results. */
|
|
148
|
+
export interface LatencyAggs {
|
|
149
|
+
overall: ScriptedMetric<ParsedLatency>;
|
|
150
|
+
by_service: TermsAgg<LatencyServiceBucket>;
|
|
151
|
+
over_time: TermsAgg<LatencyTimeBucket>;
|
|
152
|
+
}
|
|
153
|
+
/** modeErrors aggregation results. */
|
|
154
|
+
export interface ErrorsAggs {
|
|
155
|
+
by_service: TermsAgg<ErrorServiceBucket>;
|
|
156
|
+
by_status_code: TermsAgg<TermsBucket<number>>;
|
|
157
|
+
by_endpoint: TermsAgg<TermsBucket>;
|
|
158
|
+
by_error_type: TermsAgg<TermsBucket>;
|
|
159
|
+
over_time: TermsAgg<DateHistBucket>;
|
|
160
|
+
recent_errors: TopHitsAgg;
|
|
161
|
+
}
|
|
162
|
+
/** modeReport Phase 1 aggregation results. */
|
|
163
|
+
export interface ReportP1Aggs {
|
|
164
|
+
total: AggFilter;
|
|
165
|
+
by_service: AggFilter & {
|
|
166
|
+
services: TermsAgg<ReportServiceBucket>;
|
|
167
|
+
};
|
|
168
|
+
error_total: AggFilter & {
|
|
169
|
+
over_time: TermsAgg<DateHistBucket>;
|
|
170
|
+
};
|
|
171
|
+
latency_overview: AggFilter & {
|
|
172
|
+
parsed: ScriptedMetric<ParsedLatency>;
|
|
173
|
+
};
|
|
174
|
+
[key: string]: unknown;
|
|
175
|
+
}
|
|
176
|
+
/** modeReport Phase 2 error detail. */
|
|
177
|
+
export interface ReportErrorDetail extends AggFilter {
|
|
178
|
+
by_status_code: TermsAgg<TermsBucket<number>>;
|
|
179
|
+
by_error_type: TermsAgg<TermsBucket>;
|
|
180
|
+
by_endpoint: TermsAgg<TermsBucket>;
|
|
181
|
+
recent: TopHitsAgg;
|
|
182
|
+
}
|
|
183
|
+
/** modeReport Phase 2 latency detail. */
|
|
184
|
+
export interface ReportLatencyDetail extends AggFilter {
|
|
185
|
+
p95_over_time: TermsAgg<P95TimeBucket>;
|
|
186
|
+
}
|
|
187
|
+
/** modeReport Phase 2 aggregation results. */
|
|
188
|
+
export interface ReportP2Aggs {
|
|
189
|
+
error_detail?: ReportErrorDetail;
|
|
190
|
+
latency_detail?: ReportLatencyDetail;
|
|
191
|
+
}
|
|
192
|
+
/** modeReport Phase 3 pattern sample aggregation. */
|
|
193
|
+
export interface PatternSampleAgg extends AggFilter {
|
|
194
|
+
samples: TopHitsAgg;
|
|
195
|
+
}
|
|
196
|
+
export interface SavedObjectAttributes {
|
|
197
|
+
title?: string;
|
|
198
|
+
description?: string;
|
|
199
|
+
visState?: string;
|
|
200
|
+
uiStateJSON?: string;
|
|
201
|
+
panelsJSON?: string;
|
|
202
|
+
optionsJSON?: string;
|
|
203
|
+
fields?: string;
|
|
204
|
+
kibanaSavedObjectMeta?: {
|
|
205
|
+
searchSourceJSON: string;
|
|
206
|
+
};
|
|
207
|
+
[key: string]: unknown;
|
|
208
|
+
}
|
|
209
|
+
export interface SavedObjectResponse {
|
|
210
|
+
attributes?: SavedObjectAttributes;
|
|
211
|
+
references?: SavedObjectRef[];
|
|
212
|
+
}
|
|
213
|
+
export interface SavedObjectRef {
|
|
214
|
+
name: string;
|
|
215
|
+
type: string;
|
|
216
|
+
id: string;
|
|
217
|
+
}
|
|
218
|
+
export type VisDef = [
|
|
219
|
+
string,
|
|
220
|
+
{
|
|
221
|
+
attributes: Record<string, unknown>;
|
|
222
|
+
references: SavedObjectRef[];
|
|
223
|
+
}
|
|
224
|
+
];
|
|
225
|
+
export interface FieldDefinition {
|
|
226
|
+
name: string;
|
|
227
|
+
type: string;
|
|
228
|
+
esTypes: string[];
|
|
229
|
+
searchable: boolean;
|
|
230
|
+
aggregatable: boolean;
|
|
231
|
+
readFromDocValues: boolean;
|
|
232
|
+
}
|
|
233
|
+
export interface FieldMapping {
|
|
234
|
+
type?: string;
|
|
235
|
+
fields?: Record<string, {
|
|
236
|
+
type: string;
|
|
237
|
+
ignore_above?: number;
|
|
238
|
+
}>;
|
|
239
|
+
}
|
|
240
|
+
export interface DashboardPanel {
|
|
241
|
+
version: string;
|
|
242
|
+
gridData: {
|
|
243
|
+
x: number;
|
|
244
|
+
y: number;
|
|
245
|
+
w: number;
|
|
246
|
+
h: number;
|
|
247
|
+
i: string;
|
|
248
|
+
};
|
|
249
|
+
panelIndex: string;
|
|
250
|
+
embeddableConfig: Record<string, unknown>;
|
|
251
|
+
panelRefName: string;
|
|
252
|
+
}
|
|
253
|
+
/** Response from GET /api/status. */
|
|
254
|
+
export interface OsdStatusResponse {
|
|
255
|
+
version?: {
|
|
256
|
+
number?: string;
|
|
257
|
+
build_hash?: string;
|
|
258
|
+
};
|
|
259
|
+
status?: {
|
|
260
|
+
overall?: {
|
|
261
|
+
state?: string;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/** Response from GET /{index}/_mapping. */
|
|
266
|
+
export interface IndexMappingResponse {
|
|
267
|
+
[indexName: string]: {
|
|
268
|
+
mappings?: {
|
|
269
|
+
properties?: Record<string, FieldMapping>;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/** Aggregation shape for pattern-counting queries (monitor.service + playbook). */
|
|
274
|
+
export interface PatternCountAggs {
|
|
275
|
+
_total?: AggFilter;
|
|
276
|
+
[key: string]: AggFilter | undefined;
|
|
277
|
+
}
|
|
278
|
+
export interface SearchArgs {
|
|
279
|
+
env: string;
|
|
280
|
+
query?: string;
|
|
281
|
+
service?: string;
|
|
282
|
+
level?: string;
|
|
283
|
+
status?: string;
|
|
284
|
+
correlationId?: string;
|
|
285
|
+
hours?: number;
|
|
286
|
+
timeFrom?: string;
|
|
287
|
+
timeTo?: string;
|
|
288
|
+
mode: string;
|
|
289
|
+
limit: number;
|
|
290
|
+
interval?: string;
|
|
291
|
+
asc: boolean;
|
|
292
|
+
ids: boolean;
|
|
293
|
+
full: boolean;
|
|
294
|
+
json: boolean;
|
|
295
|
+
link: boolean;
|
|
296
|
+
}
|
|
297
|
+
export interface MonitorArgs {
|
|
298
|
+
mode: string;
|
|
299
|
+
service?: string;
|
|
300
|
+
hours?: number;
|
|
301
|
+
minutes?: number;
|
|
302
|
+
watch?: number;
|
|
303
|
+
from1?: string;
|
|
304
|
+
to1?: string;
|
|
305
|
+
from2?: string;
|
|
306
|
+
to2?: string;
|
|
307
|
+
}
|
|
308
|
+
export interface DashboardArgs {
|
|
309
|
+
validate: boolean;
|
|
310
|
+
delete: boolean;
|
|
311
|
+
name?: string;
|
|
312
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces/interfaces.ts"],"names":[],"mappings":"AAAA,6DAA6D"}
|