-
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
[data views] More efficient telemetry collection #152298
[data views] More efficient telemetry collection #152298
Conversation
results.runtimeFieldCount / results.indexPatternsWithRuntimeFieldCount; | ||
} | ||
}); | ||
} | ||
|
||
return results; |
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.
console.log here to see results. results are encrypted in the http response. You may need to restart kibana to run this multiple times.
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
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.
results.indexPatternsWithRuntimeFieldCount++; | ||
results.runtimeFieldCount += runtimeFields.length; | ||
savedObjects.forEach((obj) => { | ||
const fields = JSON.parse(obj.attributes.fields) || []; |
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.
the JSON.parse threw an exception locally, so it's recommendable to use atry{}catch(){}
pattern for this case
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.
Ah, I had failed to push a change. I also changed the default data view definition in the test not to have the attributes that are used as to provide test coverage.
savedObjects.forEach((obj) => { | ||
const fields = JSON.parse(obj.attributes.fields) || []; | ||
const runtimeFieldsMap = obj.attributes.runtimeFieldMap | ||
? JSON.parse(obj.attributes.runtimeFieldMap) || {} |
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.
This is also a candidate for try - catch
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.
@mattkime Telemetry stats now work as excepted 👍 ... one think I still think worth to consider is using a try - catch
pattern for the JSON.parse. Because if for whatever reason an invalid JSON string is passed in, a SyntaxError
is thrown, and this would lead and the one hostile data view would stop the generation of the results ... or do I miss somewhere this was caught? ... or would such a case also lead to troubles before this change?
…kime/kibana into data_views_telemetry_more_efficient
|
||
const scriptedFields = ip.getScriptedFields(); | ||
const runtimeFields = ip.fields.filter((fld) => !!fld.runtimeField); | ||
const finder = savedObjectsService.createPointInTimeFinder<DataViewFieldAttrs>(findOptions); |
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.
Should we also call finder.close()
or it's not required?
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.
Its not needed with the for loop.
It'll be easier if we could get that merged into main, but would be good to test this with #151110 |
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.
Tested it and I found that when using our demo data views, the result of the telemetry is different
Before:
{
indexPatternsCount: 3,
indexPatternsWithScriptedFieldCount: 0,
indexPatternsWithRuntimeFieldCount: 2,
scriptedFieldCount: 0,
runtimeFieldCount: 2,
perIndexPattern: {
scriptedFieldCount: { min: undefined, max: undefined, avg: undefined },
runtimeFieldCount: { min: 1, max: 1, avg: 1 },
scriptedFieldLineCount: { min: undefined, max: undefined, avg: undefined },
runtimeFieldLineCount: { min: 1, max: 1, avg: 1 }
}
}
After
{
indexPatternsCount: 3,
indexPatternsWithScriptedFieldCount: 0,
indexPatternsWithRuntimeFieldCount: 0,
scriptedFieldCount: 0,
runtimeFieldCount: 0,
perIndexPattern: {
scriptedFieldCount: { min: undefined, max: undefined, avg: undefined },
runtimeFieldCount: { min: undefined, max: undefined, avg: undefined },
scriptedFieldLineCount: { min: undefined, max: undefined, avg: undefined },
runtimeFieldLineCount: { min: undefined, max: undefined, avg: undefined }
}
}
so the field count doesn't seem to work
…kime/kibana into data_views_telemetry_more_efficient
@kertal fixed. I was requesting the fields wrong, its 'runtimeFieldMap' not 'attributes.runtimeFieldMap' |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Unknown metric groupsESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @mattkime |
@kertal I think I still need an official 👍 |
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.
LGTM, tested the payload sent for telemetry before and with this PR using our demo datasets. it's identical 👍
## Summary Telemetry no longer makes field caps calls. Also batch loads data view saved objects. To collect telemetry - ``` POST kbn:/api/telemetry/v2/clusters/_stats { } ``` Addresses: elastic/sdh-kibana#3389 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit 1892bf6)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…3293) # Backport This will backport the following commits from `main` to `8.7`: - [[data views] More efficient telemetry collection (#152298)](#152298) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Matthew Kime","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-03-20T12:52:55Z","message":"[data views] More efficient telemetry collection (#152298)\n\n## Summary\r\n\r\nTelemetry no longer makes field caps calls. Also batch loads data view\r\nsaved objects.\r\n\r\nTo collect telemetry - \r\n```\r\nPOST kbn:/api/telemetry/v2/clusters/_stats\r\n{\r\n}\r\n```\r\n\r\nAddresses: https://github.com/elastic/sdh-kibana/issues/3389\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"1892bf65352aa819cefb0408c507ad894edb8a16","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Data Views","release_note:skip","Team:DataDiscovery","backport:prev-minor","v8.8.0"],"number":152298,"url":"https://github.com/elastic/kibana/pull/152298","mergeCommit":{"message":"[data views] More efficient telemetry collection (#152298)\n\n## Summary\r\n\r\nTelemetry no longer makes field caps calls. Also batch loads data view\r\nsaved objects.\r\n\r\nTo collect telemetry - \r\n```\r\nPOST kbn:/api/telemetry/v2/clusters/_stats\r\n{\r\n}\r\n```\r\n\r\nAddresses: https://github.com/elastic/sdh-kibana/issues/3389\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"1892bf65352aa819cefb0408c507ad894edb8a16"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/152298","number":152298,"mergeCommit":{"message":"[data views] More efficient telemetry collection (#152298)\n\n## Summary\r\n\r\nTelemetry no longer makes field caps calls. Also batch loads data view\r\nsaved objects.\r\n\r\nTo collect telemetry - \r\n```\r\nPOST kbn:/api/telemetry/v2/clusters/_stats\r\n{\r\n}\r\n```\r\n\r\nAddresses: https://github.com/elastic/sdh-kibana/issues/3389\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"1892bf65352aa819cefb0408c507ad894edb8a16"}}]}] BACKPORT--> Co-authored-by: Matthew Kime <[email protected]>
Summary
Telemetry no longer makes field caps calls. Also batch loads data view saved objects.
To collect telemetry -
Addresses: https://github.com/elastic/sdh-kibana/issues/3389
Checklist