fix(core): update
This commit is contained in:
parent
cc7eb8c139
commit
1dbf3724d0
19
.gitignore
vendored
19
.gitignore
vendored
@ -1,5 +1,22 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
107
.gitlab-ci.yml
107
.gitlab-ci.yml
@ -1,16 +1,16 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
@ -18,10 +18,11 @@ stages:
|
|||||||
mirror:
|
mirror:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
snyk:
|
||||||
stage: security
|
stage: security
|
||||||
@ -31,89 +32,89 @@ snyk:
|
|||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command snyk test
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# metadata stage
|
# metadata stage
|
||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm prepare
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci npm install
|
||||||
--volume "$PWD":/code
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@ -121,5 +122,5 @@ pages:
|
|||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
@ -2,5 +2,15 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "mojoio",
|
||||||
|
"gitrepo": "elasticsearch",
|
||||||
|
"shortDescription": "log to elasticsearch in a kibana compatible format",
|
||||||
|
"npmPackagename": "@mojoio/elasticsearch",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
13
package.json
13
package.json
@ -30,5 +30,16 @@
|
|||||||
"@pushrocks/smarttime": "^3.0.12",
|
"@pushrocks/smarttime": "^3.0.12",
|
||||||
"@types/elasticsearch": "^5.0.35",
|
"@types/elasticsearch": "^5.0.35",
|
||||||
"elasticsearch": "^16.5.0"
|
"elasticsearch": "^16.5.0"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_web/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
43
readme.md
43
readme.md
@ -1,26 +1,20 @@
|
|||||||
# elasticlog
|
# @mojoio/elasticsearch
|
||||||
|
|
||||||
log to elasticsearch in a kibana compatible format
|
log to elasticsearch in a kibana compatible format
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/elasticsearch)
|
||||||
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/elasticlog)
|
* [gitlab.com (source)](https://gitlab.com/mojoio/elasticsearch)
|
||||||
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/elasticlog)
|
* [github.com (source mirror)](https://github.com/mojoio/elasticsearch)
|
||||||
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/elasticlog)
|
* [docs (typedoc)](https://mojoio.gitlab.io/elasticsearch/)
|
||||||
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/elasticlog/)
|
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
[![build status](https://gitlab.com/mojoio/elasticsearch/badges/master/build.svg)](https://gitlab.com/mojoio/elasticsearch/commits/master)
|
||||||
[![build status](https://GitLab.com/pushrocks/elasticlog/badges/master/build.svg)](https://GitLab.com/pushrocks/elasticlog/commits/master)
|
[![coverage report](https://gitlab.com/mojoio/elasticsearch/badges/master/coverage.svg)](https://gitlab.com/mojoio/elasticsearch/commits/master)
|
||||||
[![coverage report](https://GitLab.com/pushrocks/elasticlog/badges/master/coverage.svg)](https://GitLab.com/pushrocks/elasticlog/commits/master)
|
[![npm downloads per month](https://img.shields.io/npm/dm/@mojoio/elasticsearch.svg)](https://www.npmjs.com/package/@mojoio/elasticsearch)
|
||||||
[![npm downloads per month](https://img.shields.io/npm/dm/elasticlog.svg)](https://www.npmjs.com/package/elasticlog)
|
[![Known Vulnerabilities](https://snyk.io/test/npm/@mojoio/elasticsearch/badge.svg)](https://snyk.io/test/npm/@mojoio/elasticsearch)
|
||||||
[![Dependency Status](https://david-dm.org/pushrocks/elasticlog.svg)](https://david-dm.org/pushrocks/elasticlog)
|
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/elasticlog/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/elasticlog/master/dependencies/npm)
|
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[![bitHound Code](https://www.bithound.io/github/pushrocks/elasticlog/badges/code.svg)](https://www.bithound.io/github/pushrocks/elasticlog)
|
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
|
||||||
[![Known Vulnerabilities](https://snyk.io/test/npm/elasticlog/badge.svg)](https://snyk.io/test/npm/elasticlog)
|
|
||||||
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -32,3 +26,14 @@ For further information read the linked docs at the top of this README.
|
|||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
|
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
|
||||||
|
|
||||||
|
|
||||||
|
## Contribute
|
||||||
|
We are always happy for code contributions. If you are not the code contributing type that is ok. + Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: [Contribute monthly :)](https://lossless.link/contribute)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
|
||||||
|
@ -24,13 +24,13 @@ export class ElasticIndex {
|
|||||||
bytes: 'm'
|
bytes: 'm'
|
||||||
},
|
},
|
||||||
async (err, responseArg: any[]) => {
|
async (err, responseArg: any[]) => {
|
||||||
if(err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// lets delete indexes that violate the retention
|
// lets delete indexes that violate the retention
|
||||||
if(Array.isArray(responseArg)) {
|
if (Array.isArray(responseArg)) {
|
||||||
const filteredIndices = responseArg.filter(indexObjectArg => {
|
const filteredIndices = responseArg.filter(indexObjectArg => {
|
||||||
return indexObjectArg.index.startsWith('smartlog');
|
return indexObjectArg.index.startsWith('smartlog');
|
||||||
});
|
});
|
||||||
@ -42,7 +42,7 @@ export class ElasticIndex {
|
|||||||
|
|
||||||
let index = null;
|
let index = null;
|
||||||
|
|
||||||
if(Array.isArray(responseArg)) {
|
if (Array.isArray(responseArg)) {
|
||||||
index = responseArg.find(indexObject => {
|
index = responseArg.find(indexObject => {
|
||||||
return indexObject.index === indexArg;
|
return indexObject.index === indexArg;
|
||||||
});
|
});
|
||||||
@ -52,7 +52,6 @@ export class ElasticIndex {
|
|||||||
const done2 = plugins.smartpromise.defer();
|
const done2 = plugins.smartpromise.defer();
|
||||||
this.elasticSearchRef.client.indices.create(
|
this.elasticSearchRef.client.indices.create(
|
||||||
{
|
{
|
||||||
|
|
||||||
waitForActiveShards: '1',
|
waitForActiveShards: '1',
|
||||||
index: indexArg
|
index: indexArg
|
||||||
},
|
},
|
||||||
@ -70,15 +69,13 @@ export class ElasticIndex {
|
|||||||
await done.promise;
|
await done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public createNewIndex(indexNameArg: string) {
|
public createNewIndex(indexNameArg: string) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public async deleteOldIndices(indicesArray: string[]) {
|
public async deleteOldIndices(indicesArray: string[]) {
|
||||||
const todayAsUnix: number = Date.now();
|
const todayAsUnix: number = Date.now();
|
||||||
const rententionPeriodAsUnix: number = plugins.smarttime.units.days(
|
const rententionPeriodAsUnix: number = plugins.smarttime.units.days(
|
||||||
this.elasticSearchRef.indexRetention
|
this.elasticSearchRef.indexRetention
|
||||||
);
|
);
|
||||||
for (const indexName of indicesArray) {
|
for (const indexName of indicesArray) {
|
||||||
const regexResult = /^smartlog-([0-9]*)\.([0-9]*)\.([0-9]*)$/.exec(indexName);
|
const regexResult = /^smartlog-([0-9]*)\.([0-9]*)\.([0-9]*)$/.exec(indexName);
|
||||||
const dateAsUnix: number = new Date(
|
const dateAsUnix: number = new Date(
|
||||||
|
@ -35,7 +35,7 @@ export class ElasticSearch<T> {
|
|||||||
*/
|
*/
|
||||||
constructor(optionsArg: IElasticSearchConstructorOptions) {
|
constructor(optionsArg: IElasticSearchConstructorOptions) {
|
||||||
this.client = new ElasticClient({
|
this.client = new ElasticClient({
|
||||||
host: this.computeHostString(optionsArg),
|
host: this.computeHostString(optionsArg)
|
||||||
// log: 'trace'
|
// log: 'trace'
|
||||||
});
|
});
|
||||||
this.indexPrefix = optionsArg.indexPrefix;
|
this.indexPrefix = optionsArg.indexPrefix;
|
||||||
|
Loading…
Reference in New Issue
Block a user