Management advanced settings telemetry (#54369)
* management telemetry * Use getUserProvided
This commit is contained in:
parent
2d62ff2cbf
commit
ebd2c2190b
|
@ -75,3 +75,9 @@ export const UI_METRIC_USAGE_TYPE = 'ui_metric';
|
|||
* Link to Advanced Settings.
|
||||
*/
|
||||
export const PATH_TO_ADVANCED_SETTINGS = 'kibana#/management/kibana/settings';
|
||||
|
||||
/**
|
||||
* The type name used within the Monitoring index to publish management stats.
|
||||
* @type {string}
|
||||
*/
|
||||
export const KIBANA_MANAGEMENT_STATS_TYPE = 'management';
|
||||
|
|
|
@ -22,3 +22,4 @@ export { registerTelemetryUsageCollector } from './usage';
|
|||
export { registerUiMetricUsageCollector } from './ui_metric';
|
||||
export { registerLocalizationUsageCollector } from './localization';
|
||||
export { registerTelemetryPluginUsageCollector } from './telemetry_plugin';
|
||||
export { registerManagementUsageCollector } from './management';
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export { registerManagementUsageCollector } from './telemetry_management_collector';
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { Server } from 'hapi';
|
||||
import { size } from 'lodash';
|
||||
import { KIBANA_MANAGEMENT_STATS_TYPE } from '../../../common/constants';
|
||||
import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/server';
|
||||
import { SavedObjectsClient } from '../../../../../../core/server';
|
||||
|
||||
export type UsageStats = Record<string, any>;
|
||||
|
||||
export async function getTranslationCount(loader: any, locale: string): Promise<number> {
|
||||
const translations = await loader.getTranslationsByLocale(locale);
|
||||
return size(translations.messages);
|
||||
}
|
||||
|
||||
export function createCollectorFetch(server: Server) {
|
||||
return async function fetchUsageStats(): Promise<UsageStats> {
|
||||
const internalRepo = server.newPlatform.setup.core.savedObjects.createInternalRepository();
|
||||
const uiSettingsClient = server.newPlatform.start.core.uiSettings.asScopedToClient(
|
||||
new SavedObjectsClient(internalRepo)
|
||||
);
|
||||
|
||||
const user = await uiSettingsClient.getUserProvided();
|
||||
const modifiedEntries = Object.keys(user)
|
||||
.filter((key: string) => key !== 'buildNum')
|
||||
.reduce((obj: any, key: string) => {
|
||||
obj[key] = user[key].userValue;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
return modifiedEntries;
|
||||
};
|
||||
}
|
||||
|
||||
export function registerManagementUsageCollector(
|
||||
usageCollection: UsageCollectionSetup,
|
||||
server: any
|
||||
) {
|
||||
const collector = usageCollection.makeUsageCollector({
|
||||
type: KIBANA_MANAGEMENT_STATS_TYPE,
|
||||
isReady: () => true,
|
||||
fetch: createCollectorFetch(server),
|
||||
});
|
||||
|
||||
usageCollection.registerCollector(collector);
|
||||
}
|
|
@ -27,6 +27,7 @@ import {
|
|||
registerTelemetryUsageCollector,
|
||||
registerLocalizationUsageCollector,
|
||||
registerTelemetryPluginUsageCollector,
|
||||
registerManagementUsageCollector,
|
||||
} from './collectors';
|
||||
|
||||
export interface PluginsSetup {
|
||||
|
@ -50,5 +51,6 @@ export class TelemetryPlugin {
|
|||
registerLocalizationUsageCollector(usageCollection, server);
|
||||
registerTelemetryUsageCollector(usageCollection, server);
|
||||
registerUiMetricUsageCollector(usageCollection, server);
|
||||
registerManagementUsageCollector(usageCollection, server);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue