-
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
Add new telemetry data from event-log index. #140943
Merged
ersin-erdal
merged 17 commits into
elastic:main
from
ersin-erdal:138996-telemetry-event-log
Sep 20, 2022
Merged
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5a2adfa
Add new telemetry data from eventLog index.
ersin-erdal 8ba7779
fix the wrong telemetry field
ersin-erdal 5a2b569
Move actions telemetry from alerting plugin to actions plugin
ersin-erdal 126f515
fix test
ersin-erdal 0459890
fix schema
ersin-erdal b1ded0a
revert unnecessary changes on schema
ersin-erdal 8b4bfcd
Merge branch 'main' into 138996-telemetry-event-log
ersin-erdal 693cc89
use replaceFirstAndLastDotSymbols
ersin-erdal be0ef83
Merge remote-tracking branch 'origin/138996-telemetry-event-log' into…
ersin-erdal de4a052
fix task interval
ersin-erdal b9c8252
remove avg_actions_run_duration_by_connector_type_per_day
ersin-erdal 6632748
remove avg_actions_run_duration_by_connector_type_per_day
ersin-erdal 4985a53
fix telemetry schema
ersin-erdal 059d839
Merge branch 'main' into 138996-telemetry-event-log
ersin-erdal 39ebc1a
Merge branch 'main' into 138996-telemetry-event-log
ersin-erdal 70532f5
Merge branch 'main' into 138996-telemetry-event-log
ersin-erdal 871c9fd
Merge branch 'main' into 138996-telemetry-event-log
ersin-erdal 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
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
155 changes: 155 additions & 0 deletions
155
x-pack/plugins/actions/server/usage/lib/parse_connector_type_bucket.test.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,155 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { | ||
parseDurationsByConnectorTypesBucket, | ||
parseActionRunOutcomeByConnectorTypesBucket, | ||
} from './parse_connector_type_bucket'; | ||
|
||
describe('parseDurationsByConnectorTypesBucket', () => { | ||
test('should correctly parse connector type bucket results', () => { | ||
expect( | ||
parseDurationsByConnectorTypesBucket([ | ||
{ | ||
key: '.server-log', | ||
doc_count: 78, | ||
duration: { average: { value: 10.2 } }, | ||
}, | ||
{ | ||
key: '.index', | ||
doc_count: 42, | ||
duration: { average: { value: 11.6 } }, | ||
}, | ||
{ | ||
key: '.slack', | ||
doc_count: 28, | ||
duration: { average: { value: 12.4 } }, | ||
}, | ||
]) | ||
).toEqual({ | ||
'__server-log': 10, | ||
__index: 12, | ||
__slack: 12, | ||
}); | ||
}); | ||
|
||
test('should handle missing values', () => { | ||
expect( | ||
parseDurationsByConnectorTypesBucket([ | ||
// @ts-expect-error | ||
{ | ||
key: '.server-log', | ||
doc_count: 78, | ||
}, | ||
{ | ||
key: '.index', | ||
doc_count: 42, | ||
// @ts-expect-error | ||
duration: {}, | ||
}, | ||
{ | ||
key: '.slack', | ||
doc_count: 28, | ||
// @ts-expect-error | ||
duration: { average: {} }, | ||
}, | ||
]) | ||
).toEqual({ | ||
'__server-log': 0, | ||
__index: 0, | ||
__slack: 0, | ||
}); | ||
}); | ||
|
||
test('should handle empty input', () => { | ||
expect(parseDurationsByConnectorTypesBucket([])).toEqual({}); | ||
}); | ||
// | ||
test('should handle undefined input', () => { | ||
expect(parseDurationsByConnectorTypesBucket(undefined)).toEqual({}); | ||
}); | ||
}); | ||
|
||
describe('parseActionRunOutcomeByConnectorTypesBucket', () => { | ||
test('should correctly parse connector type bucket results', () => { | ||
expect( | ||
parseActionRunOutcomeByConnectorTypesBucket([ | ||
{ | ||
key: '.server-log', | ||
doc_count: 78, | ||
outcome: { | ||
count: { | ||
buckets: [ | ||
{ key: 'success', doc_count: 2 }, | ||
{ key: 'failure', doc_count: 1 }, | ||
], | ||
}, | ||
}, | ||
}, | ||
{ | ||
key: '.index', | ||
doc_count: 42, | ||
outcome: { | ||
count: { | ||
buckets: [ | ||
{ key: 'success', doc_count: 3 }, | ||
{ key: 'failure', doc_count: 4 }, | ||
], | ||
}, | ||
}, | ||
}, | ||
]) | ||
).toEqual({ | ||
__index: { | ||
failure: 4, | ||
success: 3, | ||
}, | ||
'__server-log': { | ||
failure: 1, | ||
success: 2, | ||
}, | ||
}); | ||
}); | ||
|
||
test('should handle missing values', () => { | ||
expect( | ||
parseActionRunOutcomeByConnectorTypesBucket([ | ||
{ | ||
key: '.server-log', | ||
doc_count: 78, | ||
outcome: { | ||
count: { | ||
// @ts-expect-error | ||
buckets: [{ key: 'success', doc_count: 2 }, { key: 'failure' }], | ||
}, | ||
}, | ||
}, | ||
{ | ||
key: '.index', | ||
outcome: { | ||
// @ts-expect-error | ||
count: {}, | ||
}, | ||
}, | ||
]) | ||
).toEqual({ | ||
'__server-log': { | ||
failure: 0, | ||
success: 2, | ||
}, | ||
__index: {}, | ||
}); | ||
}); | ||
|
||
test('should handle empty input', () => { | ||
expect(parseActionRunOutcomeByConnectorTypesBucket([])).toEqual({}); | ||
}); | ||
// | ||
test('should handle undefined input', () => { | ||
expect(parseActionRunOutcomeByConnectorTypesBucket(undefined)).toEqual({}); | ||
}); | ||
}); |
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 believe the paradigm we follow in other telemetry objects is to have the rule type id or connector type id last. That way, we could search by
countRunOutcomeByConnectorType.failed.*
and get all the different connector types that have failed, instead of having to look inside each connector type object. WDYT of switching this around to be similar?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.
But the request is
We'd like to know which connector types are failing the most relative to their successful runs.
Wouldn't it be more difficult to get a connector's success/failure ratio?
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.
Hmm...I'm not sure either of these options will make calculating the ratio per rule type easier :). We can leave it as is.
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.
my idea was getting it like:
count_connector_types_by_action_run_outcome_per_day.__slack.failure / count_connector_types_by_action_run_outcome_per_day.__slack.success
but
count_connector_types_by_action_run_outcome_per_day.failure.__slack./ count_connector_types_by_action_run_outcome_per_day.success.__slack
would also do the same thing... IDK i can change it :)