mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Usage Collection] [schema] static_telemetry
(#77902)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
5d5ce40168
commit
88b03d943b
4 changed files with 219 additions and 6 deletions
|
@ -8,8 +8,7 @@
|
|||
"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"
|
||||
"src/plugins/kibana_usage_collection/server/collectors/ui_metric/telemetry_ui_metric_collector.ts"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1310,6 +1310,121 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"static_telemetry": {
|
||||
"properties": {
|
||||
"ece": {
|
||||
"properties": {
|
||||
"kb_uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"es_uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"account_id": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"license": {
|
||||
"properties": {
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"type": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"issued_to": {
|
||||
"type": "text"
|
||||
},
|
||||
"issuer": {
|
||||
"type": "text"
|
||||
},
|
||||
"issue_date_in_millis": {
|
||||
"type": "long"
|
||||
},
|
||||
"start_date_in_millis": {
|
||||
"type": "long"
|
||||
},
|
||||
"expiry_date_in_millis": {
|
||||
"type": "long"
|
||||
},
|
||||
"max_resource_units": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ess": {
|
||||
"properties": {
|
||||
"kb_uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"es_uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"account_id": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"license": {
|
||||
"properties": {
|
||||
"uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"type": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"issued_to": {
|
||||
"type": "text"
|
||||
},
|
||||
"issuer": {
|
||||
"type": "text"
|
||||
},
|
||||
"issue_date_in_millis": {
|
||||
"type": "long"
|
||||
},
|
||||
"start_date_in_millis": {
|
||||
"type": "long"
|
||||
},
|
||||
"expiry_date_in_millis": {
|
||||
"type": "long"
|
||||
},
|
||||
"max_resource_units": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"eck": {
|
||||
"properties": {
|
||||
"operator_uuid": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"operator_roles": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"custom_operator_namespace": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"distribution": {
|
||||
"type": "text"
|
||||
},
|
||||
"build": {
|
||||
"properties": {
|
||||
"hash": {
|
||||
"type": "text"
|
||||
},
|
||||
"date": {
|
||||
"type": "date"
|
||||
},
|
||||
"version": {
|
||||
"type": "keyword"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tsvb-validation": {
|
||||
"properties": {
|
||||
"failed_validations": {
|
||||
|
|
58
src/plugins/telemetry/server/collectors/usage/schema.ts
Normal file
58
src/plugins/telemetry/server/collectors/usage/schema.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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 { MakeSchemaFrom } from 'src/plugins/usage_collection/server';
|
||||
import { LicenseUsage, StaticTelemetryUsage } from './telemetry_usage_collector';
|
||||
|
||||
const licenseSchema: MakeSchemaFrom<LicenseUsage> = {
|
||||
uuid: { type: 'keyword' },
|
||||
type: { type: 'keyword' },
|
||||
issued_to: { type: 'text' },
|
||||
issuer: { type: 'text' },
|
||||
issue_date_in_millis: { type: 'long' },
|
||||
start_date_in_millis: { type: 'long' },
|
||||
expiry_date_in_millis: { type: 'long' },
|
||||
max_resource_units: { type: 'long' },
|
||||
};
|
||||
|
||||
export const staticTelemetrySchema: MakeSchemaFrom<Required<StaticTelemetryUsage>> = {
|
||||
ece: {
|
||||
kb_uuid: { type: 'keyword' },
|
||||
es_uuid: { type: 'keyword' },
|
||||
account_id: { type: 'keyword' },
|
||||
license: licenseSchema,
|
||||
},
|
||||
ess: {
|
||||
kb_uuid: { type: 'keyword' },
|
||||
es_uuid: { type: 'keyword' },
|
||||
account_id: { type: 'keyword' },
|
||||
license: licenseSchema,
|
||||
},
|
||||
eck: {
|
||||
operator_uuid: { type: 'keyword' },
|
||||
operator_roles: { type: 'keyword' },
|
||||
custom_operator_namespace: { type: 'boolean' },
|
||||
distribution: { type: 'text' },
|
||||
build: {
|
||||
hash: { type: 'text' },
|
||||
date: { type: 'date' },
|
||||
version: { type: 'keyword' },
|
||||
},
|
||||
},
|
||||
};
|
|
@ -29,6 +29,7 @@ import { TelemetryConfigType } from '../../config';
|
|||
|
||||
// look for telemetry.yml in the same places we expect kibana.yml
|
||||
import { ensureDeepObject } from './ensure_deep_object';
|
||||
import { staticTelemetrySchema } from './schema';
|
||||
|
||||
/**
|
||||
* The maximum file size before we ignore it (note: this limit is arbitrary).
|
||||
|
@ -60,10 +61,12 @@ export function isFileReadable(path: string): boolean {
|
|||
* @param configPath The config file path.
|
||||
* @returns The unmodified JSON object if the file exists and is a valid YAML file.
|
||||
*/
|
||||
export async function readTelemetryFile(path: string): Promise<object | undefined> {
|
||||
export async function readTelemetryFile<T extends object>(
|
||||
configPath: string
|
||||
): Promise<T | undefined> {
|
||||
try {
|
||||
if (isFileReadable(path)) {
|
||||
const yaml = readFileSync(path);
|
||||
if (isFileReadable(configPath)) {
|
||||
const yaml = readFileSync(configPath);
|
||||
const data = safeLoad(yaml.toString());
|
||||
|
||||
// don't bother returning empty objects
|
||||
|
@ -79,11 +82,48 @@ export async function readTelemetryFile(path: string): Promise<object | undefine
|
|||
return undefined;
|
||||
}
|
||||
|
||||
export interface LicenseUsage {
|
||||
uuid: string;
|
||||
type: string;
|
||||
issued_to: string;
|
||||
issuer: string;
|
||||
issue_date_in_millis: number;
|
||||
start_date_in_millis: number;
|
||||
expiry_date_in_millis: number;
|
||||
max_resource_units: number;
|
||||
}
|
||||
|
||||
export interface StaticTelemetryUsage {
|
||||
ece?: {
|
||||
kb_uuid: string;
|
||||
es_uuid: string;
|
||||
account_id: string;
|
||||
license: LicenseUsage;
|
||||
};
|
||||
ess?: {
|
||||
kb_uuid: string;
|
||||
es_uuid: string;
|
||||
account_id: string;
|
||||
license: LicenseUsage;
|
||||
};
|
||||
eck?: {
|
||||
operator_uuid: string;
|
||||
operator_roles: string;
|
||||
custom_operator_namespace: boolean;
|
||||
distribution: string;
|
||||
build: {
|
||||
hash: string;
|
||||
date: string;
|
||||
version: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export function createTelemetryUsageCollector(
|
||||
usageCollection: UsageCollectionSetup,
|
||||
getConfigPathFn: () => Promise<string>
|
||||
) {
|
||||
return usageCollection.makeUsageCollector({
|
||||
return usageCollection.makeUsageCollector<StaticTelemetryUsage | undefined>({
|
||||
type: 'static_telemetry',
|
||||
isReady: () => true,
|
||||
fetch: async () => {
|
||||
|
@ -91,6 +131,7 @@ export function createTelemetryUsageCollector(
|
|||
const telemetryPath = join(dirname(configPath), 'telemetry.yml');
|
||||
return await readTelemetryFile(telemetryPath);
|
||||
},
|
||||
schema: staticTelemetrySchema,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue