[7.x] [Usage Collection] [Schema] "kibana" collector (#77893) (#78397)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Alejandro Fernández Haro 2020-09-24 12:36:50 +01:00 committed by GitHub
parent 6a3ba80309
commit 2ff1156891
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 7 deletions

View file

@ -6,7 +6,6 @@
"src/plugins/kibana_react/",
"src/plugins/testbed/",
"src/plugins/kibana_utils/",
"src/plugins/kibana_usage_collection/server/collectors/kibana/kibana_usage_collector.ts",
"src/plugins/kibana_usage_collection/server/collectors/management/telemetry_management_collector.ts",
"src/plugins/kibana_usage_collection/server/collectors/ui_metric/telemetry_ui_metric_collector.ts",
"src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts"

View file

@ -39,9 +39,12 @@ const TYPES = [
];
export interface KibanaSavedObjectCounts {
[pluginName: string]: {
total: number;
};
dashboard: { total: number };
visualization: { total: number };
search: { total: number };
index_pattern: { total: number };
graph_workspace: { total: number };
timelion_sheet: { total: number };
}
export async function getSavedObjectsCounts(
@ -71,7 +74,7 @@ export async function getSavedObjectsCounts(
// Initialise the object with all zeros for all the types
const allZeros: KibanaSavedObjectCounts = TYPES.reduce(
(acc, type) => ({ ...acc, [snakeCase(type)]: { total: 0 } }),
{}
{} as KibanaSavedObjectCounts
);
// Add the doc_count from each bucket

View file

@ -22,15 +22,28 @@ import { take } from 'rxjs/operators';
import { SharedGlobalConfig } from 'kibana/server';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { KIBANA_STATS_TYPE } from '../../../common/constants';
import { getSavedObjectsCounts } from './get_saved_object_counts';
import { getSavedObjectsCounts, KibanaSavedObjectCounts } from './get_saved_object_counts';
interface KibanaUsage extends KibanaSavedObjectCounts {
index: string;
}
export function getKibanaUsageCollector(
usageCollection: UsageCollectionSetup,
legacyConfig$: Observable<SharedGlobalConfig>
) {
return usageCollection.makeUsageCollector({
return usageCollection.makeUsageCollector<KibanaUsage, { usage: KibanaUsage }>({
type: 'kibana',
isReady: () => true,
schema: {
index: { type: 'keyword' },
dashboard: { total: { type: 'long' } },
visualization: { total: { type: 'long' } },
search: { total: { type: 'long' } },
index_pattern: { total: { type: 'long' } },
graph_workspace: { total: { type: 'long' } },
timelion_sheet: { total: { type: 'long' } },
},
async fetch(callCluster) {
const {
kibana: { index },

View file

@ -1297,6 +1297,55 @@
}
}
},
"kibana": {
"properties": {
"index": {
"type": "keyword"
},
"dashboard": {
"properties": {
"total": {
"type": "long"
}
}
},
"visualization": {
"properties": {
"total": {
"type": "long"
}
}
},
"search": {
"properties": {
"total": {
"type": "long"
}
}
},
"index_pattern": {
"properties": {
"total": {
"type": "long"
}
}
},
"graph_workspace": {
"properties": {
"total": {
"type": "long"
}
}
},
"timelion_sheet": {
"properties": {
"total": {
"type": "long"
}
}
}
}
},
"telemetry": {
"properties": {
"opt_in_status": {