kibana/x-pack/plugins/osquery/server/saved_objects.ts
Bryan Clement 62f3a55cd8
[Asset Management] Osquery telemetry updates (#100754)
* first pass of basic osquery usage stats collection

* updates, linting

* updated exported metrics

* clean up comments, add description fields to metric fields

* reworked types

* actually use the updated types

* added tests around the route usage recoder functions

* review comments

* update aggregate types

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-06-17 14:53:27 -04:00

34 lines
1,010 B
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { CoreSetup } from '../../../../src/core/server';
import { OsqueryAppContext } from './lib/osquery_app_context_services';
import { savedQueryType, packType } from './lib/saved_query/saved_object_mappings';
import { usageMetricType } from './routes/usage/saved_object_mappings';
const types = [savedQueryType, packType];
export const savedObjectTypes = types.map((type) => type.name);
export const initSavedObjects = (
savedObjects: CoreSetup['savedObjects'],
osqueryContext: OsqueryAppContext
) => {
const config = osqueryContext.config();
savedObjects.registerType(usageMetricType);
if (config.savedQueries) {
savedObjects.registerType(savedQueryType);
}
if (config.packs) {
savedObjects.registerType(packType);
}
};