Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
36d7cb69a3 | |||
4924e0a151 | |||
cd98529541 | |||
e6a9282987 | |||
9dcadcd611 | |||
4b045ff988 | |||
023dd1b519 | |||
4971385eae | |||
e209839962 | |||
e44365b674 | |||
bd154089c3 | |||
0be693da60 | |||
040c93dec3 | |||
21e55bd341 | |||
f1d04fe63c | |||
49c4660131 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@apiclient.xyz/elasticsearch",
|
"name": "@apiclient.xyz/elasticsearch",
|
||||||
"version": "2.0.8",
|
"version": "2.0.16",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "log to elasticsearch in a kibana compatible format",
|
"description": "log to elasticsearch in a kibana compatible format",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@apiclient.xyz/elasticsearch',
|
name: '@apiclient.xyz/elasticsearch',
|
||||||
version: '2.0.8',
|
version: '2.0.16',
|
||||||
description: 'log to elasticsearch in a kibana compatible format'
|
description: 'log to elasticsearch in a kibana compatible format'
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ export class ElasticDoc {
|
|||||||
private indexInitialized: boolean = false;
|
private indexInitialized: boolean = false;
|
||||||
private latestTimestamp: string | null = null; // Store the latest timestamp
|
private latestTimestamp: string | null = null; // Store the latest timestamp
|
||||||
private onlyNew: boolean = false; // Whether to only pipe new docs
|
private onlyNew: boolean = false; // Whether to only pipe new docs
|
||||||
|
public fastForward: boolean = false; // Whether to fast forward to the latest timestamp
|
||||||
|
|
||||||
private BATCH_SIZE = 1000;
|
private BATCH_SIZE = 1000;
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ export class ElasticDoc {
|
|||||||
await this.client.indices.create({
|
await this.client.indices.create({
|
||||||
index: this.index,
|
index: this.index,
|
||||||
body: {
|
body: {
|
||||||
mappings,
|
// mappings,
|
||||||
settings: {
|
settings: {
|
||||||
// You can define the settings according to your requirements here
|
// You can define the settings according to your requirements here
|
||||||
},
|
},
|
||||||
@ -106,15 +107,22 @@ export class ElasticDoc {
|
|||||||
// If 'onlyNew' is true, compare the document timestamp with the latest timestamp
|
// If 'onlyNew' is true, compare the document timestamp with the latest timestamp
|
||||||
if (this.onlyNew) {
|
if (this.onlyNew) {
|
||||||
if (this.latestTimestamp && optionsArg.timestamp <= this.latestTimestamp) {
|
if (this.latestTimestamp && optionsArg.timestamp <= this.latestTimestamp) {
|
||||||
// Omit the document
|
this.fastForward = true;
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
|
this.fastForward = false;
|
||||||
await this.client.index({
|
await this.client.index({
|
||||||
index: this.index,
|
index: this.index,
|
||||||
id: optionsArg.docId,
|
id: optionsArg.docId,
|
||||||
body: documentBody,
|
body: documentBody,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.fastForward = false;
|
||||||
|
await this.client.index({
|
||||||
|
index: this.index,
|
||||||
|
id: optionsArg.docId,
|
||||||
|
body: documentBody,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.sessionDocs.add(optionsArg.docId);
|
this.sessionDocs.add(optionsArg.docId);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ export class ElsSmartlogDestination<T> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.index(
|
await this.client.index(
|
||||||
{
|
{
|
||||||
index: indexToUse,
|
index: indexToUse,
|
||||||
body: {
|
body: {
|
||||||
@ -68,7 +68,7 @@ export class ElsSmartlogDestination<T> {
|
|||||||
get logDestination(): ILogDestination {
|
get logDestination(): ILogDestination {
|
||||||
return {
|
return {
|
||||||
handleLog: async (smartlogPackageArg: ILogPackage) => {
|
handleLog: async (smartlogPackageArg: ILogPackage) => {
|
||||||
this.log(smartlogPackageArg);
|
await this.log(smartlogPackageArg);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user