-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtypes.ts
124 lines (109 loc) · 2.08 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
/**
* Different log levels detected by loki
*/
export enum LokiLogLevel {
Info = 'info',
Debug = 'debug',
Error = 'error',
Warning = 'warning',
Critical = 'critical',
}
/**
* Shape for a Loki log entry
*/
export interface LokiLog {
stream: {
level: LokiLogLevel
[key: string]: string
}
values: [string, string][]
}
/**
* Shape for a Pino log entry
*/
export interface PinoLog {
level: number
[key: string]: any
}
/**
* Options for the Pino-Loki transport
*/
export interface LokiOptions {
/**
* URL for Loki
*/
host: string
/**
* Timeout for request to Loki
*
* @default 30_000
*/
timeout?: number
/**
* If false, errors will be displayed in the console
*
* @default false
*/
silenceErrors?: boolean
/**
* Should logs be sent in batch mode
*
* @default true
*/
batching?: boolean
/**
* The interval at which batched logs are sent in seconds
*
* @default 5
*/
interval?: number
/**
* Replace pino logs timestamps with Date.now()
*
* Be careful when using batch mode, that will cause all logs
* to have the same timestamp
*
* @default false
*/
replaceTimestamp?: boolean
/**
* Additional labels to be added to all Loki logs
*/
labels?: {
[key: string]: string
}
/**
* Custom pino to loki log level mapping, merged with the default one.
* @default
* 10: LokiLogLevel.Debug,
20: LokiLogLevel.Debug,
30: LokiLogLevel.Info,
40: LokiLogLevel.Warning,
50: LokiLogLevel.Error,
60: LokiLogLevel.Critical
*/
levelMap?: {
[key: number]: LokiLogLevel
}
/**
* Basic auth credentials to be used when sending logs to Loki
*/
basicAuth?: {
username: string
password: string
}
/**
* Headers to be sent when pushing logs to Loki API
*/
headers?: Record<string, string>
/**
* Select log message's props to set as Loki labels
*/
propsToLabels?: string[]
/**
* Convert arrays in log messages to objects with index as key
*
* @default false
*/
convertArrays?: boolean
}