Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Usage Collection] [Schema] "kibana" collector #77893

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The payload for stack_stats.kibana doesn't contain an index field, it has indices as a long. I assume we're adding os, versions and plugins through a different collector.

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