-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Retrofit the Bulk Uploader types combiner [ch2198] #22030
Retrofit the Bulk Uploader types combiner [ch2198] #22030
Conversation
568949f
to
0305d48
Compare
eb78627
to
8778c55
Compare
8778c55
to
4597441
Compare
fix usage collector, add comments to formatForBulk remove unnecessary customizations
4597441
to
fb76429
Compare
this.type = type; | ||
this.init = init; | ||
this.fetch = fetch; | ||
|
||
this.log = getCollectorLogger(server); | ||
const defaultFormatterForBulkUpload = result => ({ type, payload: result }); | ||
this._formatForBulkUpload = formatForBulkUpload || defaultFormatterForBulkUpload; |
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'm doing some testing, and it looks like I want to override this in the UsageCollector class. Usage collectors should organize their data in the kibana_stats
type in the usage
namespace. - c940ee1
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, that's snazzy!
💚 Build Succeeded |
So when I run master for Is that expected? |
I'm guessing you see the value as The issue of seeing no value for |
@tsullivan So I should ignore that difference right now? Because the two documents (from master and your branch) are not identical |
💚 Build Succeeded |
@chrisronline I merged in master after the blocker bug fix, please take another look at the settings collector, because I had to resolve a conflict there. Let me know if you are still seeing differences in the shape of the data. |
💚 Build Succeeded |
@tsullivan Great, functionally this LGTM! Going to review the code now |
@@ -44,6 +44,7 @@ export function getOpsStatsCollector(server, kbnServer) { | |||
kibana: getKibanaInfoForStats(server, kbnServer), | |||
...kbnServer.metrics // latest metrics captured from the ops event listener in src/server/status/index | |||
}; | |||
} | |||
}, | |||
internalIgnore: true, // Ignore this one from internal uploader. A different stats collector is used there. |
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'm wondering if this can be more verbose to avoid ambiguity - maybe ignoreForInternalUploader
?
@@ -73,12 +72,12 @@ export class CollectorSet { | |||
* Call a bunch of fetch methods and then do them in bulk | |||
* @param {Array} collectors - an array of collectors, default to all registered collectors | |||
*/ | |||
bulkFetch(callCluster, collectors = this._collectors) { | |||
if (!Array.isArray(collectors)) { | |||
bulkFetch(callCluster, collectors = this) { |
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 rename collectors
to collectorSet
to avoid any potential confusion? By collectors
, I'd assume we're doing with an array of collectors versus a typed CollectorSet
object
@@ -90,10 +89,19 @@ export class CollectorSet { | |||
this._log.warn(`Unable to fetch data from ${collectorType} collector`); | |||
}); | |||
}); | |||
return Promise.all(fetchPromises); |
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.
Just wondering, is there a specific reason we keep using promises versus using async/await?
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.
Not really. This lets us not await each fetch one at a time. I could be wrong, but using Promise.props
inside the loop has it run all the fetches at the same time.
|
||
/* | ||
* Helper Factory methods | ||
* Define as instance properties to allow enclosing the server object | ||
*/ | ||
this.makeStatsCollector = options => new Collector(server, options); | ||
this.makeUsageCollector = options => new UsageCollector(server, options); | ||
this._makeCollectorSetFromArray = collectorsArray => new CollectorSet(server, collectorsArray); |
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.
Why is this an instanced variable versus just static function defined at the top?
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.
Having it here let's us enclose the server
object that the constructor is called with
*/ | ||
formatForBulkUpload: result => { | ||
return { | ||
type: 'kibana_stats', |
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 use the constants here?
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.
Yeah, this can use KIBANA_STATS_TYPE_MONITORING
from the monitoring constants.
*/ | ||
formatForBulkUpload: result => { | ||
return { | ||
type: 'kibana_stats', |
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.
Ditto on the constant
|
||
// convert the raw data to a nested object by taking each payload through | ||
// its formatter, organizing it per-type | ||
const typesNested = rawData.reduce((accum, { type, result }) => { |
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.
Can we include a sample of what the data structure looks like before and after each transformation? I find that helps understand intent a lot
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.
Overall, looking great! I had a few questions and suggestions!
💚 Build Succeeded |
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 and works great!
* Retrofit the Bulk Uploader types combiner [ch2198] fix usage collector, add comments to formatForBulk remove unnecessary customizations * override default format for bulk upload for usage type collectors * rename to ignoreForInternalUploader * collectors -> collectorSet * use constant for kibana_stats type * example of data formatting for bulk in function comment
6.5.0/6.x: #22223 |
* Retrofit the Bulk Uploader types combiner [ch2198] fix usage collector, add comments to formatForBulk remove unnecessary customizations * override default format for bulk upload for usage type collectors * rename to ignoreForInternalUploader * collectors -> collectorSet * use constant for kibana_stats type * example of data formatting for bulk in function comment
Closes https://github.com/elastic/kibana-canvas/issues/128 Makes a summary of Canvas usage that looks like: ``` { "kibana_canvas": { "elements": { "per_page": { "avg": 2, "max": 3, "min": 1 }, "total": 4 }, "functions": { "in_use": [ "filters", "demodata", "markdown", "render", "image", "pointseries", "plot", "getCell", "repeatImage" ], "per_element": { "avg": 4, "max": 5, "min": 2 }, "total": 16 }, "pages": { "per_workpad": { "avg": 1, "max": 1, "min": 1 }, "total": 2 }, "workpads": { "total": 2 } } } ``` To complete end-to-end Telemetry functionality, More work is going on with Monitoring and Telemetry to have every registered collector automatically include the their data in the overall payload. There's ongoing work to implement that in core Kibana, but none of it blocks the PR from being merged. - Having the Canvas usage stats automatically added to `.monitoring-kibana-*` documents depends on this PR: elastic#22030 - That PR can be pulled to help test this PR. The result will be Canvas usage stats in the `kibana_stats` documents in `.monitoring-kibana-*`. - Having Canvas usage stats automatically included in the telemetry payload that gets sent to Elastic depends on this unstarted issue: elastic#21239 - Without that additional work, the way to test this PR is to check for the `usage.kibana_canvas` data in the`localhost:5601/api/stats?extended=true` API response. That pending work in Kibana core does not block this PR from getting merged.
Replaces #21356
Resolves #21238
This PR allows the bulk uploader to handle new types of data without needing to update any legacy code. It helps remove future maintenance on
monitoring/server/kibana_monitoring
, i.e. internal monitoring stats upload.Changes:
src/server/status/collectors/get_ops_stats_collector.js
withinternalIgnore: true
to make it used only for the HTTP stats API. Bulk Uploader uses a different ops stats collector that's going to stay in Monitoring.formatForBulkUpload
method, which allows them to customize how they get combined into the payload for internal data upload. Customizations are optional, default will work most of the time.formatForBulkUpload
methods to the collectors created ingetKibanaUsageCollector
andgetReportingUsageCollector
getFilteredCollectorSet
method to the collectorSet instance, to get a collectorSet instance that has only one kind of collector registered.BulkUploader.combineStatsLegacy
To test:
.monitoring-kibana-*
data when running master.monitoring-kibana-*
data when running this branchLook at the
kibana_stats
andkibana_settings
documents when comparing