-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix support for elasticsearch v7 + add types (#169)
* fix support for elasticsearch v7 + add types * add tests for types + minor improvements * add back tls option --------- Co-authored-by: Roman UNTILOV <[email protected]>
- Loading branch information
1 parent
2610f4d
commit e4beebb
Showing
10 changed files
with
422 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import type { Transform } from 'stream' | ||
import type { ClientOptions } from '@elastic/elasticsearch' | ||
|
||
export default pinoElasticsearch | ||
|
||
declare function pinoElasticsearch(options?: Options): DestinationStream | ||
|
||
export type DestinationStream = Transform & { | ||
/** | ||
* when something, that cannot be parsed, is encountered | ||
*/ | ||
on(event: 'unknown', handler: (line: string, error: string) => void): void | ||
/** | ||
* when a bulk insert request failed which resulted in logs being dropped | ||
*/ | ||
on(event: 'insertError', handler: (error: Error & { document: Record<string, any> }) => void): void | ||
/** | ||
* when a batch of logs was sent successfully | ||
*/ | ||
on(event: 'insert', handler: (stats: Record<string, any>) => void): void | ||
/** | ||
* when some other kind of error happened, e.g. connection issues | ||
*/ | ||
on(event: 'error', handler: (error: Error) => void): void | ||
} | ||
|
||
export type Options = Pick<ClientOptions, 'node' | 'auth' | 'cloud' | 'caFingerprint' | 'Connection' | 'ConnectionPool'> & { | ||
index?: Index | ||
|
||
type?: string | ||
|
||
/** @deprecated use `opType` instead */ | ||
op_type?: OpType; | ||
opType?: OpType; | ||
|
||
/** @deprecated use `flushBytes` instead */ | ||
'flush-bytes'?: number | undefined | ||
flushBytes?: number | undefined | ||
|
||
/** @deprecated use `flushInterval` instead */ | ||
'flush-interval'?: number | undefined | ||
flushInterval?: number | undefined | ||
|
||
/** @deprecated use `esVersion` instead */ | ||
'es-version'?: number | undefined | ||
esVersion?: number | undefined | ||
|
||
/** @deprecated use `tls.rejectUnauthorized` instead */ | ||
rejectUnauthorized?: boolean | ||
|
||
tls?: ClientOptions['ssl']; | ||
} | ||
|
||
export type Index = string | `${string | ''}%{DATE}${string | ''}` | ((logTime: string) => string) | ||
|
||
export type OpType = 'create' | 'index' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.