-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add kibana stats * fix tests * format the stats for telemetry * fix the os/platform stats * add version to locally-source kibana telemetry stats * use callWithInternalUser * better get_kibana module unit test verification * separate handleKibanaStats * variable rename * fix comment * fix functional test * keep the return object literal from handleLocalStats * validate the payload fields * add warning log if no kibana stats returned
- Loading branch information
Showing
7 changed files
with
551 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
x-pack/plugins/xpack_main/server/lib/telemetry/local/get_kibana.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 { get, omit } from 'lodash'; | ||
|
||
export function handleKibanaStats(server, response) { | ||
if (!response) { | ||
server.log(['warning', 'telemetry', 'local-stats'], 'No Kibana stats returned from usage collectors'); | ||
return; | ||
} | ||
|
||
const { kibana, kibana_stats: stats, ...plugins } = response; | ||
|
||
const platform = get(stats, 'os.platform', 'unknown'); | ||
const platformRelease = get(stats, 'os.platformRelease', 'unknown'); | ||
|
||
let version; | ||
const { kbnServer } = get(server, 'plugins.xpack_main.status.plugin'); | ||
if (kbnServer) { | ||
version = kbnServer.version.replace(/-snapshot/i, ''); | ||
} | ||
|
||
// combine core stats (os types, saved objects) with plugin usage stats | ||
// organize the object into the same format as monitoring-enabled telemetry | ||
return { | ||
...omit(kibana, 'index'), // discard index | ||
count: 1, | ||
indices: 1, | ||
os: { | ||
platforms: [{ platform, count: 1 }], | ||
platformReleases: [{ platformRelease, count: 1 }], | ||
}, | ||
versions: [{ version, count: 1 }], | ||
plugins, | ||
}; | ||
} | ||
|
||
/* | ||
* Check user privileges for read access to monitoring | ||
* Pass callWithInternalUser to bulkFetchUsage | ||
*/ | ||
export async function getKibana(server, callWithInternalUser) { | ||
const { collectorSet } = server.usage; | ||
const usage = await collectorSet.bulkFetch(callWithInternalUser); | ||
return collectorSet.toObject(usage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.