Skip to content
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

Added defaultActionMessage to index threshold alert UI type definition #80936

Merged
merged 19 commits into from
Nov 9, 2020
Merged

Added defaultActionMessage to index threshold alert UI type definition #80936

merged 19 commits into from
Nov 9, 2020

Conversation

dB2510
Copy link
Contributor

@dB2510 dB2510 commented Oct 17, 2020

Fixes #78148
Screenshot from 2020-10-17 18-36-07
The above screenshot displays the defaultActionMessage in the text box when an action is created for index threshold alert.

@dB2510 dB2510 requested a review from a team as a code owner October 17, 2020 13:10
@kibanamachine
Copy link
Contributor

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cla-checker-service
Copy link

cla-checker-service bot commented Oct 17, 2020

💚 CLA has been signed

@dB2510 dB2510 changed the title resolves https://github.com/elastic/kibana/issues/78148 Added defaultActionMessage to index threshold alert UI type definition Oct 17, 2020
@marius-dr marius-dr added Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Oct 17, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@marius-dr
Copy link
Member

marius-dr commented Oct 17, 2020

Thanks for working on this. Until the Kibana Alerting Services team gets back to you, I've added some version labels to it as it would be good to have it backported to 7.x as well. Also, don't forget to sign the CLA.

@marius-dr marius-dr added v7.11.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes labels Oct 17, 2020
@dB2510
Copy link
Contributor Author

dB2510 commented Oct 18, 2020

@marius-dr I have signed the contributer agreement but here it is not showing.

@marius-dr
Copy link
Member

It probably took a while to update. Thanks!

@marius-dr
Copy link
Member

@elasticmachine merge upstream

@mikecote
Copy link
Contributor

@pmuellr PR for #78148.

@pmuellr pmuellr self-assigned this Oct 19, 2020
@pmuellr
Copy link
Member

pmuellr commented Oct 19, 2020

I'm going to do a manual test on this right now, I assume it will work as intended :-)

But wondering if we can add some other useful test. Ideally, a functional test, so we can see this in action. I'll start poking around and what we might want to do. It would probably involve checking the response from invoking the action, and then matching with a regex, as {{context.value}} and {{context.date}} are values we won't be able to pre-determine.

@pmuellr
Copy link
Member

pmuellr commented Oct 19, 2020

is the CI stuck on this? Or maybe the CI doesn't actually run unless we specifically tell it to, for community PRs - I think that's it.

@pmuellr
Copy link
Member

pmuellr commented Oct 19, 2020

jenkins retest this please

@pmuellr
Copy link
Member

pmuellr commented Oct 19, 2020

With a manual test, it looks like this differs from using {{context.message}}. Here are the two - I added spaces with the new default message showing where some values came out blank:

new alert index action name group host-2 value 160 exceeded threshold                                         over    on 2020-10-19T18:25:09.107Z
old alert index action name group host-4 value 160 exceeded threshold avg(system.cpu.total.norm.pct) > 0.8 over 5s on 2020-10-19T18:25:09.080Z

I'm guessing the referenced context variables are not set, maybe we don't even make those available, but then it would be good to add those to the existing context variables ...

@dB2510
Copy link
Contributor Author

dB2510 commented Oct 19, 2020

With a manual test, it looks like this differs from using {{context.message}}. Here are the two - I added spaces with the new default message showing where some values came out blank:

new alert index action name group host-2 value 160 exceeded threshold                                         over    on 2020-10-19T18:25:09.107Z
old alert index action name group host-4 value 160 exceeded threshold avg(system.cpu.total.norm.pct) > 0.8 over 5s on 2020-10-19T18:25:09.080Z

I'm guessing the referenced context variables are not set, maybe we don't even make those available, but then it would be good to add those to the existing context variables ...

@pmuellr what changes I have to make here? Is there a need to do a manual check that whether those referenced variables are set or not?

@pmuellr
Copy link
Member

pmuellr commented Oct 19, 2020

Ya, just checked, we don't have those context variables currently. We should add them, they'll be useful to customers in other situations anyway.

Here's where the existing ones are set:

const message = i18n.translate(
'xpack.stackAlerts.indexThreshold.alertTypeContextMessageDescription',
{
defaultMessage:
'alert {name} group {group} value {value} exceeded threshold {function} over {window} on {date}',
values: {
name: alertInfo.name,
group: baseContext.group,
value: baseContext.value,
function: humanFn,
window,
date: baseContext.date,
},
}
);

In the definition of BaseActionContext above that section of code, we should add two additional string fields:

  • function, whose value would be the same as humanFn defined in that method
  • window, whose value would be the same as window defined in that method

Those values need to be set in the alert type definition tho, here:

const baseContext: BaseActionContext = {
date,
group: instanceId,
value,
};

That file will also need updates to add the new variables to the list here:

actionVariables: {
context: [
{ name: 'message', description: actionVariableContextMessageLabel },
{ name: 'title', description: actionVariableContextTitleLabel },
{ name: 'group', description: actionVariableContextGroupLabel },
{ name: 'date', description: actionVariableContextDateLabel },
{ name: 'value', description: actionVariableContextValueLabel },
],

And then the descriptions needed to be added as i18n strings like the existing ones above that code.

@@ -17,6 +17,12 @@ export function getAlertType(): AlertTypeModel<IndexThresholdAlertParams, Alerts
iconClass: 'alert',
alertParamsExpression: lazy(() => import('./expression')),
validate: validateExpression,
defaultActionMessage: i18n.translate(
'xpack.triggers_actions_ui.builtin_alert_types.threshold.alertDefaultActionMessage',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The i18n error in the CI seems to be caused by using triggers_actions_ui instead of triggersActionsUI, for the string above.

Suggested change
'xpack.triggers_actions_ui.builtin_alert_types.threshold.alertDefaultActionMessage',
'xpack.triggersActionsUI.builtin_alert_types.threshold.alertDefaultActionMessage',

That's a difference from other usages anyway, like this one:

'xpack.triggersActionsUI.sections.alertAdd.threshold.fixErrorInExpressionBelowValidationMessage',

@dB2510
Copy link
Contributor Author

dB2510 commented Oct 21, 2020

@pmuellr Please review the changes

@dB2510
Copy link
Contributor Author

dB2510 commented Nov 6, 2020

@pmuellr I have tried resolving merge conflict. Please review once.

@pmuellr
Copy link
Member

pmuellr commented Nov 6, 2020

@dB2510 the merge looks good! No need to use my copy of the PR/branch if your's is still in good shape.

Again, it's not building, so starting one via a message ...

@pmuellr
Copy link
Member

pmuellr commented Nov 6, 2020

jenkins retest this please

@dB2510
Copy link
Contributor Author

dB2510 commented Nov 6, 2020

There's one thing in this PR that still kind of bugs me, and that's the name of the context variable function that got added:

My vote is for condition :)

Ooooh, I like that.
Realized I should poke around and see what other alert types are using for context names; let me do that in a bit and I'll post the results back here.

The log threshold alert is creating a conditions variable that's similar to this:

const createConditionsMessageForCriteria = (criteria: Criteria) => {
const parts = criteria.map((criterion, index) => {
const { field, comparator, value } = criterion;
return `${index === 0 ? '' : 'and'} ${field} ${comparator} ${value}`;
});
return parts.join(' ');
};

So, seems like a winner, paving the cow paths ...

Now, singular or plural? :-) condtions seems like it still works even if there's only a single condition, and it may well be the case that we add additional filtering capabilities to index threshold anyway, so we may want it to be plural in the future, so thinking we should name it conditions.

@pmuellr Should I go for conditions?

@pmuellr
Copy link
Member

pmuellr commented Nov 6, 2020

@dB2510: Should I go for conditions?

Sure! Unless you want to just get this merged. We have some other changes to the defaultActionMessage coming, fairly soon, I'm happy to do that work then. Up to you. Longer we wait, more chances for more conflicts :-)

@dB2510
Copy link
Contributor Author

dB2510 commented Nov 6, 2020

@pmuellr Okay then its up to you. Can we merge this now?
One change is required now xpack.triggersActionsUI.components.builtinAlertTypes.threshold.alertDefaultActionMessage one in x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/index.ts file

@pmuellr
Copy link
Member

pmuellr commented Nov 6, 2020

One change is required now xpack.triggersActionsUI.components.builtinAlertTypes.threshold.alertDefaultActionMessage one in x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/index.ts file

Ah, for some reason I thought this was already merged. We should go ahead and make this change, because once we create a new i18n key, then it becomes a little messy to rename it later - we should make it right now, since we know what the name will be.

After that, I think will be good to merge!

@dB2510
Copy link
Contributor Author

dB2510 commented Nov 6, 2020

@pmuellr Done! Can we merge this now?

@pmuellr
Copy link
Member

pmuellr commented Nov 6, 2020

Let's get the CI to pass, and then should be good to merge!

Thanks for all the effort here Dhruv!

@pmuellr
Copy link
Member

pmuellr commented Nov 6, 2020

jenkins retest this please

@dB2510
Copy link
Contributor Author

dB2510 commented Nov 7, 2020

Let's get the CI to pass, and then should be good to merge!

Thanks for all the effort here Dhruv!

@pmuellr Thank you for giving me the opportunity to contribute to this issue.

@pmuellr
Copy link
Member

pmuellr commented Nov 8, 2020

We'll need one more merge from upstream to get the prbot:outdated check to pass. You can try posting the comment it suggests, or do it manually.

@dB2510
Copy link
Contributor Author

dB2510 commented Nov 9, 2020

@elasticmachine merge upstream

@pmuellr
Copy link
Member

pmuellr commented Nov 9, 2020

jenkins retest this please

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

page load bundle size

id before after diff
triggersActionsUi 132.7KB 133.1KB +422.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@pmuellr pmuellr merged commit c78cf35 into elastic:master Nov 9, 2020
pmuellr pushed a commit to pmuellr/kibana that referenced this pull request Nov 9, 2020
…ion (elastic#80936)

* resolves elastic#78148

Adds a `defaultActionMessage` to the index threshold alert, so that the `message` parameter for actions will be pre-filled with a useful message
@pmuellr
Copy link
Member

pmuellr commented Nov 9, 2020

Whew! Merged! I've started the backport on this, so the feature should be available when Kibana 7.11.0 comes out.

Thanks again @dB2510 !!

gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 9, 2020
* master:
  Added `defaultActionMessage` to index threshold alert UI type definition (elastic#80936)
  [ILM] Migrate Delete phase and name field to Form Lib (elastic#82834)
  skip flaky suite (elastic#57426)
  [Alerting] adds an Run When field in the alert flyout to assign the action to an Action Group (elastic#82472)
  [APM] Expose APM event client as part of plugin contract (elastic#82724)
  [Logs UI] Fix errors during navigation (elastic#78319)
  Enable send to background in TSVB (elastic#82835)
  SavedObjects search_dsl: add match_phrase_prefix clauses when using prefix search (elastic#82693)
  [Ingest Manager] Unify install* under installPackage (elastic#82916)
pmuellr added a commit that referenced this pull request Nov 9, 2020
…ion (#80936) (#82950)

* resolves #78148

Adds a `defaultActionMessage` to the index threshold alert, so that the `message` parameter for actions will be pre-filled with a useful message

Co-authored-by: Dhruv Bodani <dhruvbodani2510@gmail.com>
phillipb added a commit to phillipb/kibana that referenced this pull request Nov 10, 2020
…e-details-overlay

* 'master' of github.com:elastic/kibana: (201 commits)
  Added `defaultActionMessage` to index threshold alert UI type definition (elastic#80936)
  [ILM] Migrate Delete phase and name field to Form Lib (elastic#82834)
  skip flaky suite (elastic#57426)
  [Alerting] adds an Run When field in the alert flyout to assign the action to an Action Group (elastic#82472)
  [APM] Expose APM event client as part of plugin contract (elastic#82724)
  [Logs UI] Fix errors during navigation (elastic#78319)
  Enable send to background in TSVB (elastic#82835)
  SavedObjects search_dsl: add match_phrase_prefix clauses when using prefix search (elastic#82693)
  [Ingest Manager] Unify install* under installPackage (elastic#82916)
  [Fleet] Make stream id unique in agent policy (elastic#82447)
  skip flaky suite (elastic#82915)
  skip flaky suite (elastic#75794)
  Copy `dateAsStringRt` to observability plugin (elastic#82839)
  [Maps] rename connected_components/map folder to mb_map (elastic#82897)
  [Security Solution] Fix EventsViewer DnD cypress tests (elastic#82619)
  [Security Solution] Adds logging and performance fan out API for threat/Indicator matching (elastic#82546)
  Implemented Alerting health status pusher by using task manager and status pooler for Kibana status plugins 'kibanahost/api/status' (elastic#79056)
  [APM] Adds new configuration 'xpack.apm.maxServiceEnvironments' (elastic#82090)
  Move single use function in line (elastic#82885)
  [ML] Add unsigned_long support to data frame analytics and anomaly detection (elastic#82636)
  ...
@mikecote mikecote added release_note:enhancement and removed release_note:skip Skip the PR/issue when compiling release notes labels Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add defaultActionMessage to index threshold alert UI type definition
7 participants