Skip to content

Commit

Permalink
[Usage Collection] [Schema] "kibana" collector (elastic#77893)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
afharo and elasticmachine committed Sep 24, 2020
1 parent e581a75 commit 62365a8
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
1 change: 0 additions & 1 deletion .telemetryrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
49 changes: 49 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 62365a8

Please sign in to comment.