-
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
Adds telemetry support to alerting and actions plugins #58081
Adds telemetry support to alerting and actions plugins #58081
Conversation
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
…telemetry # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
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.
code LGTM, made some comments; will have a few more comments outside of the review, in the main part of the PR
@@ -162,6 +170,22 @@ export class ActionsPlugin implements Plugin<Promise<PluginSetupContract>, Plugi | |||
actionsConfigUtils, | |||
}); | |||
|
|||
const usageCollection = plugins.usageCollection; | |||
if (usageCollection) { | |||
core.getStartServices().then(async ([coreStart, startPlugins]: [CoreStart, any]) => { |
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.
oh neat, didn't realized you could get start services (async) in setup!
taskManager: TaskManagerStartContract | ||
) { | ||
return usageCollection.makeUsageCollector({ | ||
type: 'actions', |
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.
so does usageCollection
take type: actions
and then look for actions-telemetry
types in the SO? I'm not seeing any other references to actions-telemetry
in the code, other than in the SO mappings at the top, so guessing this must be how it's done.
…telemetry # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
…hedule and connectors count
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.
It's coming along, great work! 👍 Just a few comments, some of them are duplicates between alerts and actions and then a few nits.
…telemetry # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
…telemetry # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
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 awesome! LGTM 👍I like how the number of requests is reduced.
Just wanted to confirm we have follow up issues created for the missing telemetry items? (executions, usage count, etc)
…telemetry # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
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, made some comments, seems fine to ship as-is
import { APICaller } from 'kibana/server'; | ||
|
||
export async function getTotalCount(callCluster: APICaller, kibanaIndex: string) { | ||
const scriptedMetric = { |
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 slightly surprised we can't use some existing agg here, instead of having to script it.
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.
Existing aggregations is designed to work on the document fields, but in case it is a child document like a relation or alert.actions list - we should use nested path and in this case we still able to aggregate only fields on the nested level. I did a deep research over documentation and didn't find any other option https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-aggregations-bucket-nested-aggregation.html. The most pain here that we don't have an actionTypeId in 'relations', but have it on alert.actions and both of this objects are the separate branches of nesting which is not accessible for each other.
}; | ||
} | ||
|
||
export async function getInUseTotalCount(callCluster: APICaller, kibanaIndex: string) { |
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.
It seems like we could probably do all these aggs in a single search, but I doubt there's a great reason to do that, since they won't be running all that often. And it no doubt easier to deal with a small set of semi-complex searchs, rather than run a single search with a bunch of semi-complex aggs in it.
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 had the same thoughts, when was writing this code, but decided to keep it separately for now.
@@ -4,7 +4,7 @@ | |||
* you may not use this file except in compliance with the Elastic License. | |||
*/ | |||
import * as React from 'react'; | |||
import { mountWithIntl } from 'test_utils/enzyme_helpers'; | |||
import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers'; |
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.
Are the changes in this file required for the PR? Like, the server plugin wasn't completely initialized before, or something?
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, it is the last weird test I found. Decided to fix it, because it cause jest tests failing with time out.
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* Added base telemetry functionality * Fixed actions collector due to NP plugin changes * Fixed type checks * Fixed alerting plugin usage collector * Added actions and alerting telemetry tasks * Fixed failing tests and resolved comments * Extended telemetry for alerts by adding aggregations for throttle, schedule and connectors count * Fixed tests * Refactored using callCluster aggregations * Fixed compare * Fixed time convertion
* master: Endpoint: Change the input type for @kbn/config-schema to work with more schemas (elastic#60007) Using re2 for Timelion regular expressions (elastic#55208) [Monitoring] Re-enable logstash tests (elastic#59815) fix karma debug typo (elastic#60029) Adds telemetry support to alerting and actions plugins (elastic#58081)
* Added base telemetry functionality * Fixed actions collector due to NP plugin changes * Fixed type checks * Fixed alerting plugin usage collector * Added actions and alerting telemetry tasks * Fixed failing tests and resolved comments * Extended telemetry for alerts by adding aggregations for throttle, schedule and connectors count * Fixed tests * Refactored using callCluster aggregations * Fixed compare * Fixed time convertion
avg: 0, | ||
max: 0, | ||
}, | ||
schedule_time: { |
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.
After checking off line with @YulNaumenko , the mapping for the schedule_time
and throttle_time
properties should be strings.
Summary
Close #49832
Checklist
Delete any items that are not applicable to this PR.