-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.ts
1092 lines (838 loc) · 29.6 KB
/
client.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Do not edit, this file was generated by github.com/apex/rpc.
// Alert represents configuration for performing alerting.
export interface Alert {
// created_at is a timestamp indicating when the alert was created. This field is read-only.
created_at?: Date
// description is the description of the alert.
description?: string
// id is the alert id. This field is read-only.
id?: string
// interval is the interval in minutes for performing the alert.
interval?: number
// limit is the maximum number of events in the alert notification.
limit?: number
// muted is a boolean used ignore trigger and resolve notifications.
muted?: boolean
// name is the name of the alert. This field is required.
name: string
// notification_id is the notification id for reporting alerts, when omitted the alert will not run. This field is required.
notification_id: string
// operator is the operator used when comparing against the threshold. This field is required. Must be one of: ">", ">=", "<", "<=".
operator: string
// project_id is the associated project id. This field is required.
project_id: string
// query is the query performed by the alert. This field is required.
query: string
// severity is the severity of the alert. This field is required. Must be one of: "info", "notice", "error", "critical".
severity: string
// threshold is the threshold for comparison against the selected operator.
threshold?: number
// updated_at is a timestamp indicating when the alert was last updated. This field is read-only.
updated_at?: Date
}
// BooleanFieldStat represents a boolean field's stats.
export interface BooleanFieldStat {
// count is the number of times this field occurred in the sampled events.
count?: number
// percent is the percentage of occurrences in the sampled events.
percent?: number
// value is the boolean value.
value?: boolean
}
// DiscoveredField represents a single discovered field.
export interface DiscoveredField {
// count is the number of times this field occurred in the sampled events.
count?: number
// name is the field name.
name?: string
// percent is the percentage of occurrences in the sampled events.
percent?: number
// type is the type of discovered field. Must be one of: "string", "number", "boolean".
type?: string
}
// Event represents a single log event.
export interface Event {
// fields is the log fields.
fields?: object
// id is the event id.
id?: string
// level is the severity level. This field is required. Must be one of: "debug", "info", "notice", "warning", "error", "critical", "alert", "emergency".
level: string
// message is the log message. This field is required.
message: string
// timestamp is the creation timestamp.
timestamp?: Date
}
// InstanceConfig represents an instance's configuration.
export interface InstanceConfig {
// project_id is the Google Cloud project id.
project_id?: string
// region is the Google Cloud region id.
region?: string
// team_id is the Apex team id.
team_id?: string
}
// Notification represents an alert notification.
export interface Notification {
// created_at is a timestamp indicating when the notification was created. This field is read-only.
created_at?: Date
// email_addresses is the receipients of the alert notifications.
email_addresses?: string[]
// id is the notification id. This field is read-only.
id?: string
// name is the name of the notification. This field is required.
name: string
// pagerduty_service_key is the PagerDuty service key.
pagerduty_service_key?: string
// project_id is the associated project id. This field is required.
project_id: string
// slack_channel is the Slack channel name, otherwise the default for the webhook is used.
slack_channel?: string
// slack_webhook_url is the Slack webhook URL.
slack_webhook_url?: string
// sms_numbers is the receipients of the alert notifications.
sms_numbers?: string[]
// type is the type of notification. This field is required. Must be one of: "slack", "pagerduty", "email", "sms", "webhook".
type: string
// updated_at is a timestamp indicating when the notification was last updated. This field is read-only.
updated_at?: Date
// webhook_url is the webhook URL which receives the alert payloads.
webhook_url?: string
}
// Project represents an isolated set of log events and alerts. A project can be created for each application, environment, or team within an organization depending on your preferences.
export interface Project {
// created_at is a timestamp indicating when the project was created. This field is read-only.
created_at?: Date
// description is the project description.
description?: string
// id is the project id. This field is read-only.
id?: string
// location is the geographical location where the log events are stored. This field is required. Must be one of: "us-west2", "northamerica-northeast1", "us-east4", "southamerica-east1", "europe-north1", "europe-west2", "europe-west6", "asia-east2", "asia-south1", "asia-northeast2", "asia-east1", "asia-northeast1", "asia-southeast1", "australia-southeast1".
location: string
// mode is the storage mode, optimized for plain-text or structured logs. Both options support plain-text and structured logging, however, the structured mode shards on the `message` value, restricting its length to 1024 bytes. This field is required. Must be one of: "plain_text", "structured".
mode: string
// name is the human-friendly project name. This field is required.
name: string
// retention is the retention of log events in days. When zero the logs do not expire.
retention?: number
// updated_at is a timestamp indicating when the project was last updated. This field is read-only.
updated_at?: Date
}
// QueryStats represents query statistics.
export interface QueryStats {
// cache_hit is a boolean indicating if the query was cached.
cache_hit?: boolean
// duration is the query duration in milliseconds.
duration?: number
// total_bytes_billed is the total number of bytes billed by the query.
total_bytes_billed?: number
// total_bytes_processed is the total number of bytes processed by the query.
total_bytes_processed?: number
}
// Search represents a saved search query.
export interface Search {
// created_at is a timestamp indicating when the saved search was created. This field is read-only.
created_at?: Date
// id is the saved search id. This field is read-only.
id?: string
// name is the name of the saved search. This field is required.
name: string
// project_id is the associated project id. This field is required.
project_id: string
// query is the saved search query. This field is required.
query: string
// updated_at is a timestamp indicating when the saved search was last updated. This field is read-only.
updated_at?: Date
}
// StringFieldStat represents a string field's stats.
export interface StringFieldStat {
// count is the number of times this field occurred in the sampled events.
count?: number
// percent is the percentage of occurrences in the sampled events.
percent?: number
// value is the string value.
value?: string
}
// TimeseriesPoint represents a single point in a timeseries query.
export interface TimeseriesPoint {
// count is the number of events for this bucket.
count?: number
// timestamp is the bucket timestamp.
timestamp?: Date
}
// Token represents an API token.
export interface Token {
// created_at is a timestamp indicating when the token was created. This field is read-only.
created_at?: Date
// description is the description of the token.
description?: string
// id is the token. This field is read-only.
id?: string
// last_used_at is a timestamp indicating when the token was last used. This field is read-only.
last_used_at?: Date
// scopes is available to this token, permitting access to read and write data. This field is required. Must be one of: "events:read", "events:write", "alerts:read", "alerts:write", "notifications:read", "notifications:write", "projects:read", "projects:write", "tokens:read", "tokens:write", "searches:read", "searches:write".
scopes: string[]
}
// AddAlertInput params.
interface AddAlertInput {
// alert is the alert. This field is required.
alert: Alert
}
// AddAlertOutput params.
interface AddAlertOutput {
// id is the alert id. This field is required.
id: string
}
// AddEventsInput params.
interface AddEventsInput {
// events is the batch of events. This field is required.
events: Event[]
// project_id is the project id. This field is required.
project_id: string
}
// AddNotificationInput params.
interface AddNotificationInput {
// notification is the notification. This field is required.
notification: Notification
}
// AddNotificationOutput params.
interface AddNotificationOutput {
// id is the notification id. This field is required.
id: string
}
// AddProjectInput params.
interface AddProjectInput {
// project is the project. This field is required.
project: Project
}
// AddProjectOutput params.
interface AddProjectOutput {
// id is the project id. This field is required.
id: string
}
// AddSearchInput params.
interface AddSearchInput {
// search is the saved search. This field is required.
search: Search
}
// AddSearchOutput params.
interface AddSearchOutput {
// id is the saved search id. This field is required.
id: string
}
// AddTokenInput params.
interface AddTokenInput {
// token is the token. This field is required.
token: Token
}
// AddTokenOutput params.
interface AddTokenOutput {
// id is the token id.
id?: string
}
// GetAlertInput params.
interface GetAlertInput {
// alert_id is the alert id. This field is required.
alert_id: string
// project_id is the project id. This field is required.
project_id: string
}
// GetAlertOutput params.
interface GetAlertOutput {
// alert is the alert. This field is required.
alert: Alert
}
// GetAlertsInput params.
interface GetAlertsInput {
// project_id is the project id. This field is required.
project_id: string
}
// GetAlertsOutput params.
interface GetAlertsOutput {
// alerts is the alerts. This field is required.
alerts: Alert[]
}
// GetBooleanFieldStatsInput params.
interface GetBooleanFieldStatsInput {
// field is the field name. This field is required.
field: string
// project_id is the project id. This field is required.
project_id: string
// query is the search query string.
query?: string
// start is the start timestamp, events before this time are not included. This field is required.
start: Date
// stop is the stop timestamp, events after this time are not included. This field is required.
stop: Date
}
// GetBooleanFieldStatsOutput params.
interface GetBooleanFieldStatsOutput {
// stats is the query statistics. This field is required.
stats: QueryStats
// values is the boolean values. This field is required.
values: BooleanFieldStat[]
}
// GetCountInput params.
interface GetCountInput {
// project_id is the project id. This field is required.
project_id: string
// query is the search query string.
query?: string
// start is the start timestamp, events before this time are not included. This field is required.
start: Date
// stop is the stop timestamp, events after this time are not included. This field is required.
stop: Date
}
// GetCountOutput params.
interface GetCountOutput {
// count is the query result count. This field is required.
count: number
// stats is the query statistics. This field is required.
stats: QueryStats
}
// GetDiscoveredFieldsInput params.
interface GetDiscoveredFieldsInput {
// project_id is the project id. This field is required.
project_id: string
// query is the search query string.
query?: string
// start is the start timestamp, events before this time are not included. This field is required.
start: Date
// stop is the stop timestamp, events after this time are not included. This field is required.
stop: Date
}
// GetDiscoveredFieldsOutput params.
interface GetDiscoveredFieldsOutput {
// fields is the fields discovered. This field is required.
fields: DiscoveredField[]
// stats is the query statistics. This field is required.
stats: QueryStats
}
// GetInstanceConfigOutput params.
interface GetInstanceConfigOutput {
// config is the instance configuration.
config?: InstanceConfig
}
// GetNotificationInput params.
interface GetNotificationInput {
// notification_id is the notification id. This field is required.
notification_id: string
// project_id is the project id. This field is required.
project_id: string
}
// GetNotificationOutput params.
interface GetNotificationOutput {
// notification is the notification. This field is required.
notification: Notification
}
// GetNotificationsInput params.
interface GetNotificationsInput {
// project_id is the project id. This field is required.
project_id: string
}
// GetNotificationsOutput params.
interface GetNotificationsOutput {
// notifications is the notifications. This field is required.
notifications: Notification[]
}
// GetNumericFieldStatsInput params.
interface GetNumericFieldStatsInput {
// field is the field name. This field is required.
field: string
// project_id is the project id. This field is required.
project_id: string
// query is the search query string.
query?: string
// start is the start timestamp, events before this time are not included. This field is required.
start: Date
// stop is the stop timestamp, events after this time are not included. This field is required.
stop: Date
}
// GetNumericFieldStatsOutput params.
interface GetNumericFieldStatsOutput {
// avg is the avg value. This field is required.
avg: number
// max is The max value. This field is required.
max: number
// min is the min value. This field is required.
min: number
// stats is the query statistics. This field is required.
stats: QueryStats
}
// GetProjectStatsInput params.
interface GetProjectStatsInput {
// project_id is the project id. This field is required.
project_id: string
}
// GetProjectStatsOutput params.
interface GetProjectStatsOutput {
// bytes_total is the total number of bytes stored. This field is required.
bytes_total: number
// events_total is the total number of events stored. This field is required.
events_total: number
}
// GetProjectsOutput params.
interface GetProjectsOutput {
// projects is the projects. This field is required.
projects: Project[]
}
// GetSearchesInput params.
interface GetSearchesInput {
// project_id is the project id. This field is required.
project_id: string
}
// GetSearchesOutput params.
interface GetSearchesOutput {
// searches is the saved searches.
searches?: Search[]
}
// GetStringFieldStatsInput params.
interface GetStringFieldStatsInput {
// field is the field name. This field is required.
field: string
// limit is the maximum number of values to return.
limit?: number
// project_id is the project id. This field is required.
project_id: string
// query is the search query string.
query?: string
// start is the start timestamp, events before this time are not included. This field is required.
start: Date
// stop is the stop timestamp, events after this time are not included. This field is required.
stop: Date
}
// GetStringFieldStatsOutput params.
interface GetStringFieldStatsOutput {
// stats is the query statistics. This field is required.
stats: QueryStats
// values is the string values. This field is required.
values: StringFieldStat[]
}
// GetTimeseriesInput params.
interface GetTimeseriesInput {
// max_points is the maxmimum number of datapoints to return. This field is required.
max_points: number
// project_id is the project id. This field is required.
project_id: string
// query is the search query string.
query?: string
// start is the start timestamp, events before this time are not included. This field is required.
start: Date
// stop is the stop timestamp, events after this time are not included. This field is required.
stop: Date
}
// GetTimeseriesOutput params.
interface GetTimeseriesOutput {
// points is the series. This field is required.
points: TimeseriesPoint[]
// stats is the query statistics. This field is required.
stats: QueryStats
}
// GetTokensOutput params.
interface GetTokensOutput {
// tokens is the tokens.
tokens?: Token[]
}
// QueryInput params.
interface QueryInput {
// project_id is the project id. This field is required.
project_id: string
// query is the SQL query string. This field is required.
query: string
}
// QueryOutput params.
interface QueryOutput {
// results is the query results. This field is required.
results: object[]
// stats is the query statistics. This field is required.
stats: QueryStats
}
// RemoveAlertInput params.
interface RemoveAlertInput {
// alert_id is the alert id. This field is required.
alert_id: string
// project_id is the project id. This field is required.
project_id: string
}
// RemoveNotificationInput params.
interface RemoveNotificationInput {
// notification_id is the notification id. This field is required.
notification_id: string
// project_id is the project id. This field is required.
project_id: string
}
// RemoveProjectInput params.
interface RemoveProjectInput {
// project_id is the project id. This field is required.
project_id: string
}
// RemoveSearchInput params.
interface RemoveSearchInput {
// project_id is the project id. This field is required.
project_id: string
// search_id is the saved search id. This field is required.
search_id: string
}
// RemoveTokenInput params.
interface RemoveTokenInput {
// token_id is the token id. This field is required.
token_id: string
}
// SearchInput params.
interface SearchInput {
// limit is the maxmimum number of events to return.
limit?: number
// order is the query timestamp sort order. Must be one of: "ascending", "descending".
order?: string
// project_id is the project id. This field is required.
project_id: string
// query is the search query string.
query?: string
// start is the start timestamp, events before this time are not included. This field is required.
start: Date
// stop is the stop timestamp, events after this time are not included. This field is required.
stop: Date
}
// SearchOutput params.
interface SearchOutput {
// events is the query search results. This field is required.
events: Event[]
// stats is the query statistics. This field is required.
stats: QueryStats
}
// TestAlertInput params.
interface TestAlertInput {
// alert is the alert. This field is required.
alert: Alert
}
// UpdateAlertInput params.
interface UpdateAlertInput {
// alert is the alert. This field is required.
alert: Alert
}
// UpdateNotificationInput params.
interface UpdateNotificationInput {
// notification is the notification. This field is required.
notification: Notification
}
// UpdateProjectInput params.
interface UpdateProjectInput {
// project is the project. This field is required.
project: Project
}
// UpdateSearchInput params.
interface UpdateSearchInput {
// search is the saved search. This field is required.
search: Search
}
// fetch for Node
const fetch = (typeof window == 'undefined' || window.fetch == null)
// @ts-ignore
? require('node-fetch')
: window.fetch
/**
* ClientError is an API client error providing the HTTP status code and error type.
*/
class ClientError extends Error {
status: number;
type?: string;
constructor(status: number, message?: string, type?: string) {
super(message)
this.status = status
this.type = type
}
}
/**
* Call method with params via a POST request.
*/
async function call(url: string, method: string, authToken?: string, params?: any): Promise<string> {
const headers: Record<string, string> = {
'Content-Type': 'application/json'
}
if (authToken != null) {
headers['Authorization'] = `Bearer ${authToken}`
}
const res = await fetch(url + '/' + method, {
method: 'POST',
body: JSON.stringify(params),
headers
})
// we have an error, try to parse a well-formed json
// error response, otherwise default to status code
if (res.status >= 300) {
let err
try {
const { type, message } = await res.json()
err = new ClientError(res.status, message, type)
} catch {
err = new ClientError(res.status, res.statusText)
}
throw err
}
return res.text()
}
const reISO8601 = /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/
/**
* Client is the API client.
*/
export class Client {
private url: string
private authToken?: string
/**
* Initialize.
*/
constructor(params: { url: string, authToken?: string }) {
this.url = params.url
this.authToken = params.authToken
}
/**
* Decoder is used as the reviver parameter when decoding responses.
*/
private decoder(key: any, value: any) {
return typeof value == 'string' && reISO8601.test(value)
? new Date(value)
: value
}
/**
* addAlert: creates a new alert.
*/
async addAlert(params: AddAlertInput): Promise<AddAlertOutput> {
let res = await call(this.url, 'add_alert', this.authToken, params)
let out: AddAlertOutput = JSON.parse(res, this.decoder)
return out
}
/**
* addEvents: ingests a batch of events.
*/
async addEvents(params: AddEventsInput) {
await call(this.url, 'add_events', this.authToken, params)
}
/**
* addNotification: creates a new notification.
*/
async addNotification(params: AddNotificationInput): Promise<AddNotificationOutput> {
let res = await call(this.url, 'add_notification', this.authToken, params)
let out: AddNotificationOutput = JSON.parse(res, this.decoder)
return out
}
/**
* addProject: creates a new project.
*/
async addProject(params: AddProjectInput): Promise<AddProjectOutput> {
let res = await call(this.url, 'add_project', this.authToken, params)
let out: AddProjectOutput = JSON.parse(res, this.decoder)
return out
}
/**
* addSearch: creates a new saved search.
*/
async addSearch(params: AddSearchInput): Promise<AddSearchOutput> {
let res = await call(this.url, 'add_search', this.authToken, params)
let out: AddSearchOutput = JSON.parse(res, this.decoder)
return out
}
/**
* addToken: creates a new token.
*/
async addToken(params: AddTokenInput): Promise<AddTokenOutput> {
let res = await call(this.url, 'add_token', this.authToken, params)
let out: AddTokenOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getAlert: returns an alert.
*/
async getAlert(params: GetAlertInput): Promise<GetAlertOutput> {
let res = await call(this.url, 'get_alert', this.authToken, params)
let out: GetAlertOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getAlerts: returns all alerts in a project.
*/
async getAlerts(params: GetAlertsInput): Promise<GetAlertsOutput> {
let res = await call(this.url, 'get_alerts', this.authToken, params)
let out: GetAlertsOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getBooleanFieldStats: returns field statistics for a boolean field.
*/
async getBooleanFieldStats(params: GetBooleanFieldStatsInput): Promise<GetBooleanFieldStatsOutput> {
let res = await call(this.url, 'get_boolean_field_stats', this.authToken, params)
let out: GetBooleanFieldStatsOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getCount: performs a search query against the log events, returning the number of matches.
*/
async getCount(params: GetCountInput): Promise<GetCountOutput> {
let res = await call(this.url, 'get_count', this.authToken, params)
let out: GetCountOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getDiscoveredFields: returns fields discovered in the provided time range.
*/
async getDiscoveredFields(params: GetDiscoveredFieldsInput): Promise<GetDiscoveredFieldsOutput> {
let res = await call(this.url, 'get_discovered_fields', this.authToken, params)
let out: GetDiscoveredFieldsOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getInstanceConfig: returns instance configuration.
*/
async getInstanceConfig(): Promise<GetInstanceConfigOutput> {
let res = await call(this.url, 'get_instance_config', this.authToken)
let out: GetInstanceConfigOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getNotification: returns a notification.
*/
async getNotification(params: GetNotificationInput): Promise<GetNotificationOutput> {
let res = await call(this.url, 'get_notification', this.authToken, params)
let out: GetNotificationOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getNotifications: returns all notifications.
*/
async getNotifications(params: GetNotificationsInput): Promise<GetNotificationsOutput> {
let res = await call(this.url, 'get_notifications', this.authToken, params)
let out: GetNotificationsOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getNumericFieldStats: returns field statistics for a numeric field.
*/
async getNumericFieldStats(params: GetNumericFieldStatsInput): Promise<GetNumericFieldStatsOutput> {
let res = await call(this.url, 'get_numeric_field_stats', this.authToken, params)
let out: GetNumericFieldStatsOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getProjectStats: returns project statistics.
*/
async getProjectStats(params: GetProjectStatsInput): Promise<GetProjectStatsOutput> {
let res = await call(this.url, 'get_project_stats', this.authToken, params)
let out: GetProjectStatsOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getProjects: returns all projects.
*/
async getProjects(): Promise<GetProjectsOutput> {
let res = await call(this.url, 'get_projects', this.authToken)
let out: GetProjectsOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getSearches: returns all saved searches in a project.
*/
async getSearches(params: GetSearchesInput): Promise<GetSearchesOutput> {
let res = await call(this.url, 'get_searches', this.authToken, params)
let out: GetSearchesOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getStringFieldStats: returns field statistics for a string field.
*/
async getStringFieldStats(params: GetStringFieldStatsInput): Promise<GetStringFieldStatsOutput> {
let res = await call(this.url, 'get_string_field_stats', this.authToken, params)
let out: GetStringFieldStatsOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getTimeseries: returns a timeseries of event counts in the provided time range.
*/
async getTimeseries(params: GetTimeseriesInput): Promise<GetTimeseriesOutput> {
let res = await call(this.url, 'get_timeseries', this.authToken, params)
let out: GetTimeseriesOutput = JSON.parse(res, this.decoder)
return out
}
/**
* getTokens: returns all tokens.
*/
async getTokens(): Promise<GetTokensOutput> {
let res = await call(this.url, 'get_tokens', this.authToken)
let out: GetTokensOutput = JSON.parse(res, this.decoder)
return out
}
/**
* query: performs a SQL query against the log events.
*/
async query(params: QueryInput): Promise<QueryOutput> {
let res = await call(this.url, 'query', this.authToken, params)
let out: QueryOutput = JSON.parse(res, this.decoder)
return out
}