mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Ensure mappings exist * Add APM * Remove unnecessary eslint disable comment * Update snapshots
This commit is contained in:
parent
5ddd666d13
commit
52043e0fa1
7 changed files with 103 additions and 2 deletions
|
@ -1796,6 +1796,7 @@ Object {
|
|||
"description": "The number of operations the follower index is lagging behind the leader.",
|
||||
"field": "",
|
||||
"format": "0,0.[00]",
|
||||
"getFields": [Function],
|
||||
"label": "Ops delay",
|
||||
"metricAgg": "sum",
|
||||
"timestampField": "timestamp",
|
||||
|
@ -2277,7 +2278,7 @@ Object {
|
|||
"app": "elasticsearch",
|
||||
"derivative": true,
|
||||
"description": "Time spent on Elasticsearch refresh for primary and replica shards.",
|
||||
"field": "total.refresh.total_time_in_millis",
|
||||
"field": "index_stats.total.refresh.total_time_in_millis",
|
||||
"format": "0,0.[00]",
|
||||
"label": "Total Refresh Time",
|
||||
"metricAgg": "max",
|
||||
|
|
|
@ -54,6 +54,19 @@ export class Metric {
|
|||
};
|
||||
}
|
||||
|
||||
getFields() {
|
||||
return [this.field];
|
||||
}
|
||||
|
||||
getDocType() {
|
||||
return this.docType || this.getInferredDocType();
|
||||
}
|
||||
|
||||
getInferredDocType() {
|
||||
const fields = this.getFields();
|
||||
return fields && fields.length ? fields[0].split('.')[0] : null;
|
||||
}
|
||||
|
||||
static calculateLatency(timeInMillis, totalEvents) {
|
||||
if (timeInMillis === null || totalEvents === null) {
|
||||
return null;
|
||||
|
|
|
@ -56,6 +56,8 @@ export class DifferenceMetric extends ElasticsearchMetric {
|
|||
},
|
||||
};
|
||||
|
||||
this.getFields = () => [`${fieldSource}.${metric}`, `${fieldSource}.${metric2}`];
|
||||
|
||||
this.calculation = (bucket) => {
|
||||
return _.get(bucket, 'metric_max.value') - _.get(bucket, 'metric2_max.value');
|
||||
};
|
||||
|
|
|
@ -937,7 +937,7 @@ export const metrics = {
|
|||
type: 'index'
|
||||
}),
|
||||
index_refresh_time: new ElasticsearchMetric({
|
||||
field: 'total.refresh.total_time_in_millis',
|
||||
field: 'index_stats.total.refresh.total_time_in_millis',
|
||||
label: 'Total Refresh Time',
|
||||
description:
|
||||
'Time spent on Elasticsearch refresh for primary and replica shards.',
|
||||
|
|
11
x-pack/test/api_integration/apis/monitoring/common/index.js
Normal file
11
x-pack/test/api_integration/apis/monitoring/common/index.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export default function ({ loadTestFile }) {
|
||||
describe('common', () => {
|
||||
loadTestFile(require.resolve('./mappings_exist'));
|
||||
});
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import expect from 'expect.js';
|
||||
import { get } from 'lodash';
|
||||
import * as esMetrics from '../../../../../plugins/monitoring/server/lib/metrics/elasticsearch/metrics';
|
||||
import * as kibanaMetrics from '../../../../../plugins/monitoring/server/lib/metrics/kibana/metrics';
|
||||
import * as logstashMetrics from '../../../../../plugins/monitoring/server/lib/metrics/logstash/metrics';
|
||||
import * as beatsMetrics from '../../../../../plugins/monitoring/server/lib/metrics/beats/metrics';
|
||||
import * as apmMetrics from '../../../../../plugins/monitoring/server/lib/metrics/apm/metrics';
|
||||
|
||||
export default function ({ getService }) {
|
||||
const es = getService('es');
|
||||
|
||||
const metricSets = [
|
||||
{
|
||||
metrics: esMetrics.metrics,
|
||||
name: 'es metrics',
|
||||
indexTemplate: '.monitoring-es'
|
||||
},
|
||||
{
|
||||
metrics: kibanaMetrics.metrics,
|
||||
name: 'kibana metrics',
|
||||
indexTemplate: '.monitoring-kibana'
|
||||
},
|
||||
{
|
||||
metrics: logstashMetrics.metrics,
|
||||
name: 'logstash metrics',
|
||||
indexTemplate: '.monitoring-logstash'
|
||||
},
|
||||
{
|
||||
metrics: beatsMetrics.metrics,
|
||||
name: 'beats metrics',
|
||||
indexTemplate: '.monitoring-beats'
|
||||
},
|
||||
{
|
||||
metrics: apmMetrics.metrics,
|
||||
name: 'apm metrics',
|
||||
indexTemplate: '.monitoring-beats' // apm uses the same as beats
|
||||
},
|
||||
];
|
||||
|
||||
describe('mappings', () => {
|
||||
for (const { indexTemplate, metrics, name } of metricSets) {
|
||||
let mappings;
|
||||
|
||||
before('load mappings', async () => {
|
||||
const template = await es.indices.getTemplate({ name: indexTemplate });
|
||||
mappings = get(template, [indexTemplate, 'mappings', 'doc', 'properties']);
|
||||
});
|
||||
|
||||
describe(`for ${name}`, () => { // eslint-disable-line no-loop-func
|
||||
for (const metric of Object.values(metrics)) {
|
||||
for (const field of metric.getFields()) {
|
||||
it(`${field} should exist in the mappings`, () => { // eslint-disable-line no-loop-func
|
||||
const propertyGetter = field.split('.').reduce((list, field) => {
|
||||
list.push(field);
|
||||
list.push('properties');
|
||||
return list;
|
||||
}, []).slice(0, -1); // Remove the trailing 'properties'
|
||||
|
||||
const foundMapping = get(mappings, propertyGetter, null);
|
||||
expect(foundMapping).to.not.equal(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
|
@ -13,5 +13,6 @@ export default function ({ loadTestFile }) {
|
|||
loadTestFile(require.resolve('./elasticsearch_settings'));
|
||||
loadTestFile(require.resolve('./kibana'));
|
||||
loadTestFile(require.resolve('./logstash'));
|
||||
loadTestFile(require.resolve('./common'));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue