fix(ci): Update CI workflows and build config; bump dependencies; code style and TS config fixes
This commit is contained in:
@@ -16,12 +16,14 @@ export class ElasticIndex {
|
||||
return indexNameArg;
|
||||
}
|
||||
|
||||
const responseArg = await this.elasticSearchRef.client.cat.indices({
|
||||
format: 'json',
|
||||
bytes: 'mb',
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
const responseArg = await this.elasticSearchRef.client.cat
|
||||
.indices({
|
||||
format: 'json',
|
||||
bytes: 'mb',
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
if (!responseArg) {
|
||||
throw new Error('Could not get valid response from elastic search');
|
||||
@@ -57,19 +59,17 @@ export class ElasticIndex {
|
||||
const response = await this.elasticSearchRef.client.indices.create({
|
||||
wait_for_active_shards: 1,
|
||||
index: indexNameArg,
|
||||
body: {
|
||||
mappings: {
|
||||
properties: {
|
||||
'@timestamp': {
|
||||
type: 'date',
|
||||
},
|
||||
logPackageArg: {
|
||||
properties: {
|
||||
payload: {
|
||||
type: 'object',
|
||||
dynamic: true
|
||||
}
|
||||
}
|
||||
mappings: {
|
||||
properties: {
|
||||
'@timestamp': {
|
||||
type: 'date',
|
||||
},
|
||||
logPackageArg: {
|
||||
properties: {
|
||||
payload: {
|
||||
type: 'object',
|
||||
dynamic: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -80,21 +80,24 @@ export class ElasticIndex {
|
||||
public async deleteOldIndices(prefixArg: string, indicesArray: string[]) {
|
||||
const todayAsUnix: number = Date.now();
|
||||
const rententionPeriodAsUnix: number = plugins.smarttime.units.days(
|
||||
this.elasticSearchRef.indexRetention
|
||||
this.elasticSearchRef.indexRetention,
|
||||
);
|
||||
for (const indexName of indicesArray) {
|
||||
if (!indexName.startsWith(prefixArg)) continue;
|
||||
const indexRegex = new RegExp(`^${prefixArg}-([0-9]*)-([0-9]*)-([0-9]*)$`)
|
||||
const indexRegex = new RegExp(
|
||||
`^${prefixArg}-([0-9]*)-([0-9]*)-([0-9]*)$`,
|
||||
);
|
||||
const regexResult = indexRegex.exec(indexName);
|
||||
const dateAsUnix: number = new Date(
|
||||
`${regexResult[1]}-${regexResult[2]}-${regexResult[3]}`
|
||||
`${regexResult[1]}-${regexResult[2]}-${regexResult[3]}`,
|
||||
).getTime();
|
||||
if (todayAsUnix - rententionPeriodAsUnix > dateAsUnix) {
|
||||
console.log(`found old index ${indexName}`);
|
||||
const response = await this.elasticSearchRef.client.indices.delete(
|
||||
{
|
||||
const response = await this.elasticSearchRef.client.indices
|
||||
.delete({
|
||||
index: indexName,
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user