-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Supports field descriptions as meta data #92701
Merged
TinaHeiligers
merged 45 commits into
elastic:master
from
TinaHeiligers:usage-collection/supports-descriptions
Mar 2, 2021
Merged
Changes from 37 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
094b2d4
WIP debugging not writing meta description fields
TinaHeiligers 754fc00
Merge branch 'master' into usage-collection/supports-descriptions
TinaHeiligers 8ae620e
Adds telemetry_tools manage_schema test to ensure descriptions are wr…
TinaHeiligers dda1dc8
Adds collector with a description field fixture, updates telemetry_to…
TinaHeiligers 3e75092
Merge branch 'master' into usage-collection/supports-descriptions
TinaHeiligers b1c8b9b
Merge branch 'master' into usage-collection/supports-descriptions
TinaHeiligers 1d95958
Checks that a collector support _meta.description
TinaHeiligers 6c16a7f
Updates schema for localization collector
TinaHeiligers e22bd14
Updates test
TinaHeiligers 25757a7
Adds description support to README
TinaHeiligers d400be6
Merge branch 'master' into usage-collection/supports-descriptions
TinaHeiligers c40e790
adds descriptions to core_usage_collector savedObjects apiCalls
TinaHeiligers aecce17
Adds descriptions to the remaining core_usage_collector fields
TinaHeiligers 4a0e224
Adds descriptions to the csp collector fields
TinaHeiligers ab01797
Adds schema and descriptions for ops_stats usage collector
TinaHeiligers a826e9b
Deletes unused interface
TinaHeiligers bfd3cc0
Adds descriptions to ui_counters fields
TinaHeiligers 0a25a4d
Updates telemetry schemas
TinaHeiligers dc62bcd
Merge branch 'master' into usage-collection/supports-descriptions
TinaHeiligers c48bb50
debugging collector integrity
TinaHeiligers 093f6cc
fixes incorrect type
TinaHeiligers 2f93064
Dirty support for _meta in stackManagementSchema type
TinaHeiligers 4dfb2a9
Moves schema to main collector registration file, deletes schema file…
TinaHeiligers 7ccfb91
Adds descriptions to kibana saved objects count collector
TinaHeiligers 46ffb45
Adds descriptions to application_usage fields
TinaHeiligers 3772d8c
Adds uiSettings schema back to stack_management_usage folder
TinaHeiligers d0e4a69
Adds descriptions to ui_metric collector
TinaHeiligers 482c674
Updates oss_plugins telemetry schema file
TinaHeiligers 8c67ebd
Updates management collector README
TinaHeiligers e6ba5b3
Merge branch 'master' into usage-collection/supports-descriptions
kibanamachine 0d6b1e5
Changes descriptions for application_usage collector fields
TinaHeiligers dbafa7c
Addresses minor text changes
TinaHeiligers 8a09021
Reverts changes to ops_stats_collector
TinaHeiligers 0fd72ab
application_usage README fix
TinaHeiligers 15c0631
Moves descriptions to telemetry_management_collector schema
TinaHeiligers f9e6566
Reverts changes to README
TinaHeiligers 82cf340
Merge branch 'master' into usage-collection/supports-descriptions
TinaHeiligers 6a0e7d1
Merge branch 'master' into usage-collection/supports-descriptions
TinaHeiligers 14b1bbb
Resolves conflict
TinaHeiligers 0eb72c3
Update src/plugins/kibana_usage_collection/server/collectors/manageme…
TinaHeiligers aee674a
Update src/plugins/kibana_usage_collection/server/collectors/manageme…
TinaHeiligers 3b23636
Update README.mdx
TinaHeiligers 9c1437c
Updates telemetry schema
TinaHeiligers 827cbfc
Updates descriptions in management collector schema
TinaHeiligers 97def09
Updates oss_plugin collectors schemas
TinaHeiligers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/kbn-telemetry-tools/src/tools/__fixture__/mock_schema_with_descriptions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"properties": { | ||
"my_working_collector_with_description": { | ||
"properties": { | ||
"flat": { | ||
"type": "keyword", | ||
"_meta": { | ||
"description": "A flat keyword string" | ||
} | ||
}, | ||
"my_index_signature_prop": { | ||
"properties": { | ||
"avg": { | ||
"type": "float" | ||
}, | ||
"count": { | ||
"type": "long" | ||
}, | ||
"max": { | ||
"type": "long" | ||
}, | ||
"min": { | ||
"type": "long" | ||
} | ||
} | ||
}, | ||
"my_str": { | ||
"type": "text" | ||
}, | ||
"my_objects": { | ||
"properties": { | ||
"total": { | ||
"type": "long" | ||
}, | ||
"type": { | ||
"type": "boolean" | ||
} | ||
} | ||
}, | ||
"my_array": { | ||
"type": "array", | ||
"items": { | ||
"properties": { | ||
"total": { | ||
"type": "long" | ||
}, | ||
"type": { | ||
"type": "boolean" | ||
} | ||
} | ||
} | ||
}, | ||
"my_str_array": { "type": "array", "items": { "type": "keyword" } } | ||
} | ||
} | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...es/kbn-telemetry-tools/src/tools/__fixture__/parsed_working_collector_with_description.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { SyntaxKind } from 'typescript'; | ||
import { ParsedUsageCollection } from '../ts_parser'; | ||
|
||
export const parsedCollectorWithDescription: ParsedUsageCollection = [ | ||
'src/fixtures/telemetry_collectors/working_collector_with_description.ts', | ||
{ | ||
collectorName: 'my_working_collector_with_description', | ||
schema: { | ||
value: { | ||
flat: { | ||
type: 'keyword', | ||
_meta: { | ||
description: 'A flat keyword string', | ||
}, | ||
}, | ||
my_str: { | ||
type: 'text', | ||
}, | ||
my_index_signature_prop: { | ||
avg: { | ||
type: 'float', | ||
}, | ||
count: { | ||
type: 'long', | ||
}, | ||
max: { | ||
type: 'long', | ||
}, | ||
min: { | ||
type: 'long', | ||
}, | ||
}, | ||
my_objects: { | ||
total: { | ||
type: 'long', | ||
}, | ||
type: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
my_array: { | ||
type: 'array', | ||
items: { | ||
total: { | ||
type: 'long', | ||
}, | ||
type: { type: 'boolean' }, | ||
}, | ||
}, | ||
my_str_array: { type: 'array', items: { type: 'keyword' } }, | ||
}, | ||
}, | ||
fetch: { | ||
typeName: 'Usage', | ||
typeDescriptor: { | ||
flat: { | ||
kind: SyntaxKind.StringKeyword, | ||
type: 'StringKeyword', | ||
}, | ||
my_str: { | ||
kind: SyntaxKind.StringKeyword, | ||
type: 'StringKeyword', | ||
}, | ||
my_index_signature_prop: { | ||
'@@INDEX@@': { | ||
kind: SyntaxKind.NumberKeyword, | ||
type: 'NumberKeyword', | ||
}, | ||
}, | ||
my_objects: { | ||
total: { | ||
kind: SyntaxKind.NumberKeyword, | ||
type: 'NumberKeyword', | ||
}, | ||
type: { | ||
kind: SyntaxKind.BooleanKeyword, | ||
type: 'BooleanKeyword', | ||
}, | ||
}, | ||
my_array: { | ||
items: { | ||
total: { | ||
kind: SyntaxKind.NumberKeyword, | ||
type: 'NumberKeyword', | ||
}, | ||
type: { | ||
kind: SyntaxKind.BooleanKeyword, | ||
type: 'BooleanKeyword', | ||
}, | ||
}, | ||
}, | ||
my_str_array: { | ||
items: { | ||
kind: SyntaxKind.StringKeyword, | ||
type: 'StringKeyword', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/fixtures/telemetry_collectors/working_collector_with_description.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { CollectorSet } from '../../plugins/usage_collection/server/collector'; | ||
import { loggerMock } from '../../core/server/logging/logger.mock'; | ||
|
||
const { makeUsageCollector } = new CollectorSet({ | ||
logger: loggerMock.create(), | ||
maximumWaitTimeForAllCollectorsInS: 0, | ||
}); | ||
|
||
interface MyObject { | ||
total: number; | ||
type: boolean; | ||
} | ||
|
||
interface Usage { | ||
flat?: string; | ||
my_str?: string; | ||
my_objects: MyObject; | ||
my_array?: MyObject[]; | ||
my_str_array?: string[]; | ||
my_index_signature_prop?: { | ||
[key: string]: number; | ||
}; | ||
} | ||
|
||
const SOME_NUMBER: number = 123; | ||
|
||
export const myCollector = makeUsageCollector<Usage>({ | ||
type: 'my_working_collector_with_description', | ||
isReady: () => true, | ||
fetch() { | ||
const testString = '123'; | ||
// query ES and get some data | ||
|
||
// summarize the data into a model | ||
// return the modeled object that includes whatever you want to track | ||
try { | ||
return { | ||
flat: 'hello', | ||
my_str: testString, | ||
my_objects: { | ||
total: SOME_NUMBER, | ||
type: true, | ||
}, | ||
my_array: [ | ||
{ | ||
total: SOME_NUMBER, | ||
type: true, | ||
}, | ||
], | ||
my_str_array: ['hello', 'world'], | ||
}; | ||
} catch (err) { | ||
return { | ||
my_objects: { | ||
total: 0, | ||
type: true, | ||
}, | ||
}; | ||
} | ||
}, | ||
schema: { | ||
flat: { | ||
type: 'keyword', | ||
_meta: { | ||
description: 'A flat keyword string', | ||
}, | ||
}, | ||
my_str: { | ||
type: 'text', | ||
}, | ||
my_objects: { | ||
total: { | ||
type: 'long', | ||
}, | ||
type: { type: 'boolean' }, | ||
}, | ||
my_array: { | ||
type: 'array', | ||
items: { | ||
total: { | ||
type: 'long', | ||
}, | ||
type: { type: 'boolean' }, | ||
}, | ||
}, | ||
my_str_array: { type: 'array', items: { type: 'keyword' } }, | ||
my_index_signature_prop: { | ||
count: { type: 'long' }, | ||
avg: { type: 'float' }, | ||
max: { type: 'long' }, | ||
min: { type: 'long' }, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ To track a sub view inside your application (ie a flyout, a tab, form step, etc) | |
|
||
#### For a React Component | ||
|
||
For tracking an application view rendered using react the simplest way is to wrap your component with the `TrackApplicationView` Higher order component: | ||
For tracking an application view rendered using react the simplest way is to wrap your component with the `TrackApplicationView` Higher order component exposed from the `usageCollection` plugin. You will need to add the plugin to plugin's `kibana.json` file as an item in the `optionalPlugins` and `requiredBundles` declarations: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the phrases/sentences to describe what we're showing in the code snippet. |
||
|
||
kibana.json | ||
```json | ||
|
@@ -26,6 +26,7 @@ kibana.json | |
|
||
At the application level, the application must be wrapped by the `ApplicationUsageTrackingProvider` provided in the `usageCollection`'s setup contract. | ||
|
||
For example: | ||
```typescript jsx | ||
class MyPlugin implements Plugin { | ||
... | ||
|
@@ -69,7 +70,6 @@ const MyTrackedComponent = () => { | |
Application Usage will automatically track the active minutes on screen and clicks for both the application and the `MyComponent` component whenever it is mounted on the screen. Application Usage pauses counting screen minutes whenever the user is tabbed to another browser window. | ||
|
||
The prop `viewId` is used as a unique identifier for your plugin. The Application Id is automatically attached to the tracked usage, based on the ID used when registering your app via `core.application.register`. | ||
|
||
## Application Usage Telemetry Data | ||
|
||
This collector reports the number of general clicks and minutes on screen for each registered application in Kibana. | ||
|
@@ -126,4 +126,4 @@ In order to keep the count of the events, this collector uses 3 Saved Objects: | |
|
||
All the types use the shared fields `appId: 'keyword'`, `viewId: 'keyword'`, `numberOfClicks: 'long'` and `minutesOnScreen: 'float'`, but they are currently not added in the mappings because we don't use them for search purposes, and we need to be thoughtful with the number of mapped fields in the SavedObjects index ([#43673](https://github.com/elastic/kibana/issues/43673)). `application_usage_transactional` and `application_usage_daily` also store `timestamp: { type: 'date' }`. | ||
|
||
Rollups uses `appId` in the savedObject id for the default view. For other views `viewId` is concatenated. This keeps backwards compatiblity with previously stored documents on the clusters without requiring any form of migration. | ||
Rollups uses `appId` in the savedObject id for the default view. For other views `viewId` is concatenated. This keeps backwards compatiblity with previously stored documents on the clusters without requiring any form of migration. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the order of the collectors to match the order with have in the plugin code.