mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Telemetry] [Schema] remove number type and support all es number types (#81774)
This commit is contained in:
parent
f095ec3663
commit
4f717708b4
17 changed files with 55 additions and 68 deletions
|
@ -148,14 +148,7 @@ usageCollection.makeUsageCollector<Usage>({
|
|||
Any field property in the schema accepts a `type` field. By default the type is `object` which accepts nested properties under it. Currently we accept the following property types:
|
||||
|
||||
```
|
||||
AllowedSchemaTypes =
|
||||
| 'keyword'
|
||||
| 'text'
|
||||
| 'number'
|
||||
| 'boolean'
|
||||
| 'long'
|
||||
| 'date'
|
||||
| 'float';
|
||||
'long', 'integer', 'short', 'byte', 'double', 'float', 'keyword', 'text', 'boolean', 'date'
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
"my_index_signature_prop": {
|
||||
"properties": {
|
||||
"avg": {
|
||||
"type": "number"
|
||||
"type": "float"
|
||||
},
|
||||
"count": {
|
||||
"type": "number"
|
||||
"type": "long"
|
||||
},
|
||||
"max": {
|
||||
"type": "number"
|
||||
"type": "long"
|
||||
},
|
||||
"min": {
|
||||
"type": "number"
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -27,7 +27,7 @@
|
|||
"my_objects": {
|
||||
"properties": {
|
||||
"total": {
|
||||
"type": "number"
|
||||
"type": "long"
|
||||
},
|
||||
"type": {
|
||||
"type": "boolean"
|
||||
|
@ -39,7 +39,7 @@
|
|||
"items": {
|
||||
"properties": {
|
||||
"total": {
|
||||
"type": "number"
|
||||
"type": "long"
|
||||
},
|
||||
"type": {
|
||||
"type": "boolean"
|
||||
|
|
|
@ -28,7 +28,7 @@ export const parsedIndexedInterfaceWithNoMatchingSchema: ParsedUsageCollection =
|
|||
value: {
|
||||
something: {
|
||||
count_1: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -34,7 +34,7 @@ export const parsedSchemaDefinedWithSpreadsCollector: ParsedUsageCollection = [
|
|||
},
|
||||
my_objects: {
|
||||
total: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
type: {
|
||||
type: 'boolean',
|
||||
|
|
|
@ -34,21 +34,21 @@ export const parsedWorkingCollector: ParsedUsageCollection = [
|
|||
},
|
||||
my_index_signature_prop: {
|
||||
avg: {
|
||||
type: 'number',
|
||||
type: 'float',
|
||||
},
|
||||
count: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
max: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
min: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
},
|
||||
my_objects: {
|
||||
total: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
type: {
|
||||
type: 'boolean',
|
||||
|
@ -58,7 +58,7 @@ export const parsedWorkingCollector: ParsedUsageCollection = [
|
|||
type: 'array',
|
||||
items: {
|
||||
total: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
type: { type: 'boolean' },
|
||||
},
|
||||
|
|
|
@ -176,7 +176,7 @@ Array [
|
|||
},
|
||||
"my_objects": Object {
|
||||
"total": Object {
|
||||
"type": "number",
|
||||
"type": "long",
|
||||
},
|
||||
"type": Object {
|
||||
"type": "boolean",
|
||||
|
@ -248,7 +248,7 @@ Array [
|
|||
"my_array": Object {
|
||||
"items": Object {
|
||||
"total": Object {
|
||||
"type": "number",
|
||||
"type": "long",
|
||||
},
|
||||
"type": Object {
|
||||
"type": "boolean",
|
||||
|
@ -258,21 +258,21 @@ Array [
|
|||
},
|
||||
"my_index_signature_prop": Object {
|
||||
"avg": Object {
|
||||
"type": "number",
|
||||
"type": "float",
|
||||
},
|
||||
"count": Object {
|
||||
"type": "number",
|
||||
"type": "long",
|
||||
},
|
||||
"max": Object {
|
||||
"type": "number",
|
||||
"type": "long",
|
||||
},
|
||||
"min": Object {
|
||||
"type": "number",
|
||||
"type": "long",
|
||||
},
|
||||
},
|
||||
"my_objects": Object {
|
||||
"total": Object {
|
||||
"type": "number",
|
||||
"type": "long",
|
||||
},
|
||||
"type": Object {
|
||||
"type": "boolean",
|
||||
|
|
|
@ -44,7 +44,7 @@ describe('checkMatchingMapping', () => {
|
|||
it('returns diff on mismatching parsedCollections and stored mapping', async () => {
|
||||
const mockSchema = await parseJsonFile('mock_schema.json');
|
||||
const malformedParsedCollector = cloneDeep(parsedWorkingCollector);
|
||||
const fieldMapping = { type: 'number' };
|
||||
const fieldMapping = { type: 'long' };
|
||||
malformedParsedCollector[1].schema.value.flat = fieldMapping;
|
||||
|
||||
const diffs = checkMatchingMapping([malformedParsedCollector], mockSchema);
|
||||
|
@ -61,9 +61,9 @@ describe('checkMatchingMapping', () => {
|
|||
const mockSchema = await parseJsonFile('mock_schema.json');
|
||||
const malformedParsedCollector = cloneDeep(parsedWorkingCollector);
|
||||
const collectorName = 'New Collector in town!';
|
||||
const collectorMapping = { some_usage: { type: 'number' } };
|
||||
const collectorMapping = { some_usage: { type: 'long' } };
|
||||
malformedParsedCollector[1].collectorName = collectorName;
|
||||
malformedParsedCollector[1].schema.value = { some_usage: { type: 'number' } };
|
||||
malformedParsedCollector[1].schema.value = { some_usage: { type: 'long' } };
|
||||
|
||||
const diffs = checkMatchingMapping([malformedParsedCollector], mockSchema);
|
||||
expect(diffs).toEqual({
|
||||
|
|
|
@ -19,14 +19,9 @@
|
|||
|
||||
import { ParsedUsageCollection } from './ts_parser';
|
||||
|
||||
export type AllowedSchemaTypes =
|
||||
| 'keyword'
|
||||
| 'text'
|
||||
| 'number'
|
||||
| 'boolean'
|
||||
| 'long'
|
||||
| 'date'
|
||||
| 'float';
|
||||
export type AllowedSchemaNumberTypes = 'long' | 'integer' | 'short' | 'byte' | 'double' | 'float';
|
||||
|
||||
export type AllowedSchemaTypes = AllowedSchemaNumberTypes | 'keyword' | 'text' | 'boolean' | 'date';
|
||||
|
||||
export function compatibleSchemaTypes(type: AllowedSchemaTypes | 'array') {
|
||||
switch (type) {
|
||||
|
@ -36,9 +31,12 @@ export function compatibleSchemaTypes(type: AllowedSchemaTypes | 'array') {
|
|||
return 'string';
|
||||
case 'boolean':
|
||||
return 'boolean';
|
||||
case 'number':
|
||||
case 'float':
|
||||
case 'long':
|
||||
case 'integer':
|
||||
case 'short':
|
||||
case 'byte':
|
||||
case 'double':
|
||||
case 'float':
|
||||
return 'number';
|
||||
case 'array':
|
||||
return 'array';
|
||||
|
|
|
@ -49,7 +49,7 @@ const someSchema: MakeSchemaFrom<Pick<Usage, 'flat' | 'my_str'>> = {
|
|||
const someOtherSchema: MakeSchemaFrom<Pick<Usage, 'my_objects'>> = {
|
||||
my_objects: {
|
||||
total: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
type: { type: 'boolean' },
|
||||
},
|
||||
|
|
|
@ -85,7 +85,7 @@ export const myCollector = makeUsageCollector<Usage>({
|
|||
},
|
||||
my_objects: {
|
||||
total: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
type: { type: 'boolean' },
|
||||
},
|
||||
|
@ -93,17 +93,17 @@ export const myCollector = makeUsageCollector<Usage>({
|
|||
type: 'array',
|
||||
items: {
|
||||
total: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
type: { type: 'boolean' },
|
||||
},
|
||||
},
|
||||
my_str_array: { type: 'array', items: { type: 'keyword' } },
|
||||
my_index_signature_prop: {
|
||||
count: { type: 'number' },
|
||||
avg: { type: 'number' },
|
||||
max: { type: 'number' },
|
||||
min: { type: 'number' },
|
||||
count: { type: 'long' },
|
||||
avg: { type: 'float' },
|
||||
max: { type: 'long' },
|
||||
min: { type: 'long' },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -37,9 +37,9 @@ export async function registerUsageCollector(
|
|||
isReady: () => true,
|
||||
fetch: fetchProvider(context.config.legacy.globalConfig$),
|
||||
schema: {
|
||||
successCount: { type: 'number' },
|
||||
errorCount: { type: 'number' },
|
||||
averageDuration: { type: 'long' },
|
||||
successCount: { type: 'long' },
|
||||
errorCount: { type: 'long' },
|
||||
averageDuration: { type: 'float' },
|
||||
},
|
||||
});
|
||||
usageCollection.registerCollector(collector);
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
"search": {
|
||||
"properties": {
|
||||
"successCount": {
|
||||
"type": "number"
|
||||
"type": "long"
|
||||
},
|
||||
"errorCount": {
|
||||
"type": "number"
|
||||
"type": "long"
|
||||
},
|
||||
"averageDuration": {
|
||||
"type": "long"
|
||||
"type": "float"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -138,7 +138,7 @@ The `schema` field is a proscribed data model assists with detecting changes in
|
|||
The `AllowedSchemaTypes` is the list of allowed schema types for the usage fields getting reported:
|
||||
|
||||
```
|
||||
'keyword', 'text', 'number', 'boolean', 'long', 'date', 'float'
|
||||
'long', 'integer', 'short', 'byte', 'double', 'float', 'keyword', 'text', 'boolean', 'date'
|
||||
```
|
||||
|
||||
### Arrays
|
||||
|
@ -171,7 +171,7 @@ export const myCollector = makeUsageCollector<Usage>({
|
|||
},
|
||||
some_obj: {
|
||||
total: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
},
|
||||
some_array: {
|
||||
|
@ -182,7 +182,7 @@ export const myCollector = makeUsageCollector<Usage>({
|
|||
type: 'array',
|
||||
items: {
|
||||
total: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -27,14 +27,9 @@ import {
|
|||
|
||||
export type CollectorFormatForBulkUpload<T, U> = (result: T) => { type: string; payload: U };
|
||||
|
||||
export type AllowedSchemaTypes =
|
||||
| 'keyword'
|
||||
| 'text'
|
||||
| 'number'
|
||||
| 'boolean'
|
||||
| 'long'
|
||||
| 'date'
|
||||
| 'float';
|
||||
export type AllowedSchemaNumberTypes = 'long' | 'integer' | 'short' | 'byte' | 'double' | 'float';
|
||||
|
||||
export type AllowedSchemaTypes = AllowedSchemaNumberTypes | 'keyword' | 'text' | 'boolean' | 'date';
|
||||
|
||||
export interface SchemaField {
|
||||
type: string;
|
||||
|
|
|
@ -21,6 +21,7 @@ export { CollectorSet } from './collector_set';
|
|||
export {
|
||||
Collector,
|
||||
AllowedSchemaTypes,
|
||||
AllowedSchemaNumberTypes,
|
||||
SchemaField,
|
||||
MakeSchemaFrom,
|
||||
CollectorOptions,
|
||||
|
|
|
@ -59,7 +59,7 @@ export function registerSecurityUsageCollector({ usageCollection, config, licens
|
|||
type: 'boolean',
|
||||
},
|
||||
authProviderCount: {
|
||||
type: 'number',
|
||||
type: 'long',
|
||||
},
|
||||
enabledAuthProviders: {
|
||||
type: 'array',
|
||||
|
|
|
@ -3250,7 +3250,7 @@
|
|||
"type": "boolean"
|
||||
},
|
||||
"authProviderCount": {
|
||||
"type": "number"
|
||||
"type": "long"
|
||||
},
|
||||
"enabledAuthProviders": {
|
||||
"type": "array",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue