전단 로그 모니터링 - Nodejs Elastic Search 를 통 해 데이터 프로 세 스 조회
var elasticsearch = require('elasticsearch');
const Service = require('egg').Service;
let esClient;
class EsBaseService extends Service {
getEsHost() {
let esHost = '172.21.101.22:9200';
if (this.ctx.helper.isPro()) {
esHost = '172.2.101.2:93200';
}
return esHost
}
getEsClient(argument) {
if (!esClient) {
this.ctx.logger.info('esClient init' + this.getEsHost())
esClient = new elasticsearch.Client({
host: this.getEsHost(),
log: 'info'
});
}
return esClient;
}
searchBucketsAndCountFromFsBugInfo(opts) {
return new Promise((resolve, reject) => {
this.searchFromFsBugInfo({
body: opts.body
}).then(function (body) {
let data = {
name: opts.name,
count: body.hits.total.value,
buckets: body.aggregations[2].buckets
};
resolve(data)
});
});
}
searchFromFsBugInfo(opts){
return this.getEsClient().search({
index: 'fs-bug-info',
body: opts.body
});
}
}
module.exports = EsBaseService;
2. 조회 작업 정의
async getAggr1(opts = {}) {
let name = ' bug ';
let dateRange = opts.dateRange;
let body = {
"aggs": {
"2": {
"terms": {
"field": "team",
"size": 100,
"order": {
"_count": "desc"
}
}
}
},
"size": 0,
"_source": {
"excludes": []
},
"stored_fields": ["*"],
"script_fields": {},
"query": {
"bool": {
"must": [{
"bool": {
"must": [{
"terms": {
"resolution": ["", "fixed", "hold"]
}
}],
"must_not": [{
"terms": {
"status": ["rejected"]
}
}, {
"term": {
"versionReport": {
"value": " "
}
}
}, {
"term": {
"problemType": {
"value": " bug"
}
}
}]
}
}, {
"range": {
"created": {
"format": "strict_date_optional_time",
"gte": dateRange[0],
"lte": dateRange[1]
}
}
}, {
"bool": {
"must": [{
"terms": {
"resolution": ["", "fixed", "hold"]
}
}],
"must_not": [{
"terms": {
"status": ["rejected"]
}
}, {
"term": {
"versionReport": {
"value": " "
}
}
}, {
"term": {
"problemType": {
"value": " bug"
}
}
}]
}
}],
"filter": [{
"match_all": {}
}, {
"match_all": {}
}],
"should": [],
"must_not": []
}
},
"timeout": "30000ms"
};
return this.ctx.service.es.base.searchBucketsAndCountFromFsBugInfo({
body,
name
});
}
let data1 = await this.getAggr1(opts);
참조 링크:
https://www.npmjs.com/package/elasticsearch
https://is-log-kibana.corp.kuaishou.com/app/kibana#/dev_tools/console
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
효과적인 TypeScript를 읽고 배운 4가지이 기사는 씨에 의해 2020년 1월에 공개된 『 』의 일본어 번역입니다. 본 기사는 원저자로부터 허가를 얻은 후 기사를 공개하고 있습니다. 동일한 함수 시그니처를 가진 유틸리티를 쓰면 약간 반복될 수 있습니다. 아...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.