mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
* fix kibana metricsets property paths * return inner kibana object * fix functional test * rename * adapt tests to datastream * rebuild archived data * extract buildKibanaInfo for reuse * add license * lint Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kevin Lacabane <klacabane@gmail.com>
This commit is contained in:
parent
d165bdad2d
commit
336963cebf
12 changed files with 81 additions and 23414 deletions
|
@ -41,6 +41,7 @@ export interface ElasticsearchSourceKibanaStats {
|
|||
};
|
||||
transport_address?: string;
|
||||
host?: string;
|
||||
version?: string;
|
||||
};
|
||||
os?: {
|
||||
memory?: {
|
||||
|
@ -416,7 +417,9 @@ export interface ElasticsearchMetricbeatNode {
|
|||
export interface ElasticsearchMetricbeatSource {
|
||||
'@timestamp'?: string;
|
||||
service?: {
|
||||
id?: string;
|
||||
address?: string;
|
||||
version?: string;
|
||||
};
|
||||
elasticsearch?: {
|
||||
node?: ElasticsearchLegacySource['source_node'] & ElasticsearchMetricbeatNode;
|
||||
|
@ -534,15 +537,16 @@ export interface ElasticsearchMetricbeatSource {
|
|||
};
|
||||
};
|
||||
kibana?: {
|
||||
kibana?: {
|
||||
transport_address?: string;
|
||||
name?: string;
|
||||
host?: string;
|
||||
uuid?: string;
|
||||
status?: string;
|
||||
};
|
||||
stats?: {
|
||||
name?: string;
|
||||
index?: string;
|
||||
status?: string;
|
||||
transport_address?: string;
|
||||
concurrent_connections?: number;
|
||||
snapshot?: boolean;
|
||||
host?: {
|
||||
name?: string;
|
||||
};
|
||||
process?: {
|
||||
uptime?: {
|
||||
ms?: number;
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { ElasticsearchResponseHit } from '../../../common/types/es';
|
||||
|
||||
export interface KibanaInfo {
|
||||
transport_address?: string;
|
||||
name?: string;
|
||||
index?: string;
|
||||
host?: string;
|
||||
uuid?: string;
|
||||
status?: string;
|
||||
snapshot?: boolean;
|
||||
version?: string;
|
||||
}
|
||||
|
||||
export const buildKibanaInfo = (hit: ElasticsearchResponseHit): KibanaInfo => {
|
||||
const source = hit._source;
|
||||
if (source.kibana_stats) return source.kibana_stats.kibana as KibanaInfo;
|
||||
|
||||
return {
|
||||
name: source.kibana?.stats?.name,
|
||||
host: source.kibana?.stats?.host?.name,
|
||||
status: source.kibana?.stats?.status,
|
||||
transport_address: source.kibana?.stats?.transport_address,
|
||||
uuid: source.service?.id,
|
||||
snapshot: source.kibana?.stats?.snapshot,
|
||||
index: source.kibana?.stats?.index,
|
||||
version: source.service?.version,
|
||||
};
|
||||
};
|
|
@ -12,17 +12,18 @@ import { checkParam, MissingRequiredError } from '../error_missing_required';
|
|||
import { calculateAvailability } from '../calculate_availability';
|
||||
import { LegacyRequest } from '../../types';
|
||||
import { ElasticsearchResponse } from '../../../common/types/es';
|
||||
import { buildKibanaInfo } from './build_kibana_info';
|
||||
|
||||
export function handleResponse(resp: ElasticsearchResponse) {
|
||||
const legacySource = resp.hits?.hits[0]?._source.kibana_stats;
|
||||
const mbSource = resp.hits?.hits[0]?._source.kibana?.stats;
|
||||
const kibana = resp.hits?.hits[0]?._source.kibana?.kibana ?? legacySource?.kibana;
|
||||
const availabilityTimestamp =
|
||||
resp.hits?.hits[0]?._source['@timestamp'] ?? legacySource?.timestamp;
|
||||
const hit = resp.hits?.hits[0];
|
||||
const legacySource = hit?._source.kibana_stats;
|
||||
const mbSource = hit?._source.kibana?.stats;
|
||||
const availabilityTimestamp = hit?._source['@timestamp'] ?? legacySource?.timestamp;
|
||||
if (!availabilityTimestamp) {
|
||||
throw new MissingRequiredError('timestamp');
|
||||
}
|
||||
return merge(kibana, {
|
||||
|
||||
return merge(buildKibanaInfo(hit!), {
|
||||
availability: calculateAvailability(availabilityTimestamp),
|
||||
os_memory_free: mbSource?.os?.memory?.free_in_bytes ?? legacySource?.os?.memory?.free_in_bytes,
|
||||
uptime: mbSource?.process?.uptime?.ms ?? legacySource?.process?.uptime_in_millis,
|
||||
|
@ -42,13 +43,15 @@ export function getKibanaInfo(
|
|||
ignore_unavailable: true,
|
||||
filter_path: [
|
||||
'hits.hits._source.kibana_stats.kibana',
|
||||
'hits.hits._source.kibana.kibana',
|
||||
'hits.hits._source.kibana.stats',
|
||||
'hits.hits._source.kibana_stats.os.memory.free_in_bytes',
|
||||
'hits.hits._source.kibana.stats.os.memory.free_in_bytes',
|
||||
'hits.hits._source.kibana_stats.process.uptime_in_millis',
|
||||
'hits.hits._source.kibana.stats.process.uptime.ms',
|
||||
'hits.hits._source.kibana_stats.timestamp',
|
||||
'hits.hits._source.@timestamp',
|
||||
'hits.hits._source.service.id',
|
||||
'hits.hits._source.service.version',
|
||||
],
|
||||
body: {
|
||||
query: {
|
||||
|
|
|
@ -15,7 +15,8 @@ import { calculateAvailability } from '../calculate_availability';
|
|||
// @ts-ignore
|
||||
import { KibanaMetric } from '../metrics';
|
||||
import { LegacyRequest } from '../../types';
|
||||
import { ElasticsearchResponse } from '../../../common/types/es';
|
||||
import { ElasticsearchResponse, ElasticsearchResponseHit } from '../../../common/types/es';
|
||||
import { KibanaInfo, buildKibanaInfo } from './build_kibana_info';
|
||||
|
||||
interface Kibana {
|
||||
process?: {
|
||||
|
@ -36,13 +37,7 @@ interface Kibana {
|
|||
total?: number;
|
||||
};
|
||||
concurrent_connections?: number;
|
||||
kibana?: {
|
||||
transport_address?: string;
|
||||
name?: string;
|
||||
host?: string;
|
||||
uuid?: string;
|
||||
status?: string;
|
||||
};
|
||||
kibana?: KibanaInfo;
|
||||
availability: boolean;
|
||||
}
|
||||
|
||||
|
@ -98,15 +93,15 @@ export async function getKibanas(
|
|||
'kibana_stats.requests.total',
|
||||
'kibana.stats.request.total',
|
||||
'kibana_stats.kibana.transport_address',
|
||||
'kibana.kibana.transport_address',
|
||||
'kibana.stats.transport_address',
|
||||
'kibana_stats.kibana.name',
|
||||
'kibana.kibana.name',
|
||||
'kibana.stats.name',
|
||||
'kibana_stats.kibana.host',
|
||||
'kibana.kibana.host',
|
||||
'kibana.stats.host.name',
|
||||
'kibana_stats.kibana.uuid',
|
||||
'kibana.kibana.uuid',
|
||||
'service.id',
|
||||
'kibana_stats.kibana.status',
|
||||
'kibana.kibana.status',
|
||||
'kibana.stats.status',
|
||||
'kibana_stats.concurrent_connections',
|
||||
'kibana.stats.concurrent_connections',
|
||||
],
|
||||
|
@ -117,12 +112,12 @@ export async function getKibanas(
|
|||
const response: ElasticsearchResponse = await callWithRequest(req, 'search', params);
|
||||
const instances = response.hits?.hits ?? [];
|
||||
|
||||
return instances.map((hit) => {
|
||||
return instances.map((hit: ElasticsearchResponseHit) => {
|
||||
const legacyStats = hit._source.kibana_stats;
|
||||
const mbStats = hit._source.kibana?.stats;
|
||||
|
||||
const kibana: Kibana = {
|
||||
kibana: hit._source.kibana?.kibana ?? legacyStats?.kibana,
|
||||
kibana: buildKibanaInfo(hit),
|
||||
concurrent_connections:
|
||||
mbStats?.concurrent_connections ?? legacyStats?.concurrent_connections,
|
||||
process: {
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { normalizeDataTypeDifferences } from '../normalize_data_type_differences';
|
||||
import instanceFixture from './fixtures/instance';
|
||||
import { getLifecycleMethods } from '../data_stream';
|
||||
|
||||
export default function ({ getService }) {
|
||||
const supertest = getService('supertest');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const { setup, tearDown } = getLifecycleMethods(getService);
|
||||
|
||||
describe('instance detail mb', () => {
|
||||
const archive =
|
||||
|
@ -22,11 +23,11 @@ export default function ({ getService }) {
|
|||
};
|
||||
|
||||
before('load archive', () => {
|
||||
return esArchiver.load(archive);
|
||||
return setup(archive);
|
||||
});
|
||||
|
||||
after('unload archive', () => {
|
||||
return esArchiver.unload(archive);
|
||||
return tearDown();
|
||||
});
|
||||
|
||||
it('should summarize single kibana instance with metrics', async () => {
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
|
||||
import expect from '@kbn/expect';
|
||||
import listingFixture from './fixtures/listing';
|
||||
import { getLifecycleMethods } from '../data_stream';
|
||||
|
||||
export default function ({ getService }) {
|
||||
const supertest = getService('supertest');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const { setup, tearDown } = getLifecycleMethods(getService);
|
||||
|
||||
describe('listing mb', () => {
|
||||
const archive =
|
||||
|
@ -21,11 +22,11 @@ export default function ({ getService }) {
|
|||
};
|
||||
|
||||
before('load archive', () => {
|
||||
return esArchiver.load(archive);
|
||||
return setup(archive);
|
||||
});
|
||||
|
||||
after('unload archive', () => {
|
||||
return esArchiver.unload(archive);
|
||||
return tearDown();
|
||||
});
|
||||
|
||||
it('should summarize list of kibana instances with stats', async () => {
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { normalizeDataTypeDifferences } from '../normalize_data_type_differences';
|
||||
import overviewFixture from './fixtures/overview';
|
||||
import { getLifecycleMethods } from '../data_stream';
|
||||
|
||||
export default function ({ getService }) {
|
||||
const supertest = getService('supertest');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const { setup, tearDown } = getLifecycleMethods(getService);
|
||||
|
||||
describe('overview mb', () => {
|
||||
const archive =
|
||||
|
@ -22,11 +23,11 @@ export default function ({ getService }) {
|
|||
};
|
||||
|
||||
before('load archive', () => {
|
||||
return esArchiver.load(archive);
|
||||
return setup(archive);
|
||||
});
|
||||
|
||||
after('unload archive', () => {
|
||||
return esArchiver.unload(archive);
|
||||
return tearDown();
|
||||
});
|
||||
|
||||
it('should summarize kibana instances with stats', async () => {
|
||||
|
|
|
@ -22,6 +22,7 @@ export default function ({ getService, getPageObjects }) {
|
|||
{
|
||||
from: 'Aug 29, 2017 @ 17:24:14.254',
|
||||
to: 'Aug 29, 2017 @ 17:25:44.142',
|
||||
useCreate: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ export default function ({ getService, getPageObjects }) {
|
|||
{
|
||||
from: 'Aug 29, 2017 @ 17:24:14.254',
|
||||
to: 'Aug 29, 2017 @ 17:25:44.142',
|
||||
useCreate: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ export default function ({ getService, getPageObjects }) {
|
|||
{
|
||||
from: 'Aug 29, 2017 @ 17:24:14.254',
|
||||
to: 'Aug 29, 2017 @ 17:25:44.142',
|
||||
useCreate: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue