-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Watcher] Support for adding actions to threshold watch #35175
[Watcher] Support for adding actions to threshold watch #35175
Conversation
a4af6cc
to
b107924
Compare
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
d939599
to
ac0b569
Compare
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
b4c6218
to
feae801
Compare
💔 Build Failed |
feae801
to
86974fd
Compare
💔 Build Failed |
86974fd
to
23cf1c3
Compare
💚 Build Succeeded |
23cf1c3
to
7d85488
Compare
@cjcenizal I pushed some changes based on your review and a couple other bugs I noticed while testing. Re:
I fixed this by calling
I went ahead and made changes to the folder structure as shown in my above comment. Let me know what you think. FYI: I need to do more thorough testing for Jira and PagerDuty actions, but I think logging, index, email and Slack are in good shape now. |
💚 Build Succeeded |
@bmcconaghy / @cjcenizal Something else I came across while testing… The current code was calling the cluster settings API to determine if an action was enabled or not for this dropdown menu. However, I don’t think this really achieves what we want, especially now that we have added support for Jira and PagerDuty. Technically, for Jira and PagerDuty (and Slack), a user only has to set some values via the keystore to configure. In this scenario, there would not be any values under the It looks like this may have come up before with Slack, and as a workaround, Slack is “enabled” by default in the code. I supposed we could do the same for Jira and PagerDuty, but in that case, the only thing this code is really checking for is email. Thoughts? Code in question: https://github.com/alisonelizabeth/kibana/blob/threshold-watch-actions/x-pack/plugins/watcher/server/models/settings/settings.js |
@alisonelizabeth Great work. I find the action combo too much to the right (compared to other fields) |
Thanks, @yaronp68! It's currently right-aligned. I tried to replicate what existing previously, but I'm not sold on it either. Do you have any suggestions? I wonder if it would help if there was more separation between the different sections? Another idea might be to just show the actions dropdown initially, and only render the text if an action has been added rather than having |
Had a conversation with @bmcconaghy about the actions dropdown. Updated the code to work as follows:
|
💔 Build Failed |
6aba211
to
85fc8df
Compare
💔 Build Failed |
Great job @alisonelizabeth ! For now, I only did a local test of the UI (haven't reviewed the code yet), but here are some comments on the UI.
and extract the fields from there? If it's complex we could leave it for a second pass but, as a user, I would expect to be able to copy paste a URL in one field. One last thing, could you add in the PR description how we can test the integration (email, Slack, Jira, Pager duty)? I'm sure I would find it in the docs somewhere but it would be much easier to copy paste your |
Thanks, @sebelga! I updated the PR with links to some setup instructions. You can reach out to me regarding Jira, and of course if you have any other questions!
|
I think the idea of using a button is a good one. I'd suggest using the same pattern Jen used for rollup index pattern creation. |
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 went ahead and made changes to the folder structure as shown in my above comment. Let me know what you think.
Looks much better! Thank you for doing that.
Great work on this @alisonelizabeth. This code LGTM. At a later point I think we should create a test plan for this, based on the original Watcher behavior. For this test plan, I'd expect:
- Explicit steps on how to get set up, e.g. a copy-pasteable elasticsearch.yml file as Seb suggested.
- Step-by-step instructions for testing each action, with notes on what the tester should expect to happen in the UI in response to different input (e.g. callouts, validation states).
- Notes on any special behaviors, e.g. setting the admin email will pre-populate the Email action's
to
field.
These are my just initial thoughts. @silne30 owns testing and QA so once we get to that point we'll look to him for guidance.
Retest |
💔 Build Failed |
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. I added a few comments about code style, look if you can address them.
About the client side validation that you removed, can you double checked that you went in "create advanced watch" and made sure we don't need them any more there?
Make sure we don't reintroduced the bug from #23887. where a badly formatted watch could be created in the console, and then could not be editted in the Watcher UI.
Cheers!
if (!this.to || !this.to.length) { | ||
errors.to.push( | ||
i18n.translate('xpack.watcher.watchActions.email.emailRecipientIsRequiredValidationMessage', { | ||
defaultMessage: 'To email address is 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.
I'm not native speaker, but shouldn't we quote the "to"? "To" email property is 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.
Good point. Updated, but also plan on doing a copy review with gail.
} | ||
|
||
validate() { | ||
const errors = []; | ||
|
||
if (!this.to.length) { |
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 the validation that was added in #23887 was that we can't validate the "to" field as it is not mandatory in the UI if it has been set in elasticsearch.yml
. Why do you think it is not necessary anymore to warn the user of a possible error?
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.
see comment regarding this above. if you still have concerns, please let me know!
* Client validation of the Watch. | ||
* Currently we are *only* validating the Watch "Actions" | ||
*/ | ||
validate() { |
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.
Could you remind me why we don't do any more validation client side? This is both used in Threshold alert and advanced watch.
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.
There is still validation, but it was added as part of the specific watch (see: models/watch/threshold_watch.js
, models/watch/json_watch.js
). Each action model also has its own validation.
}) => { | ||
const { index } = action; | ||
return ( | ||
<Fragment> |
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.
nit: no need to wrap a Fragment here
}) => { | ||
const { text } = action; | ||
return ( | ||
<Fragment> |
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.
nit: no need to wrap with Fragment here.
name: string; | ||
iconClass: 'loggingApp' | 'logoWebhook' | 'logoSlack' | 'apps' | 'email' | 'indexOpen'; | ||
}) => ( | ||
<Fragment> |
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.
nit: Fragment is not needed here. You're like @jen-huang , you love Fragments! 😄
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.
haha. thanks for the catch - fixed. i originally had this set up a little differently where it was necessary and forgot to remove.
buttonContentClassName="euiAccordionForm__button" | ||
buttonContent={<ButtonContent name={action.typeName} iconClass={action.iconClass} />} | ||
extraAction={ | ||
<DeleteIcon |
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 not directly use the <EuiButtonIcon />
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.
good point, fixed.
const { watch, setWatchProperty } = useContext(WatchContext); | ||
const { actions } = watch; | ||
|
||
const ButtonContent = ({ |
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 declare the component outside the WatchActionsAccordion
? It seems strange to me to declare a component from inside another one. It would then name it EuiAccordionButton
probably.
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.
good point. i decided to directly declare this for the buttonContent
prop
const allActionTypes = Action.getActionTypes(); | ||
|
||
const actions = Object.keys(allActionTypes).map(actionKey => { | ||
const { typeName, iconClass, selectMessage } = allActionTypes[actionKey]; |
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.
nit: you could simplify with Object.entries
const allActionTypes = Action.getActionTypes() as Record<string, any>;
const actions = Object.entries(allActionTypes).map(([type, { typeName, iconClass, selectMessage }]) => ({
type,
typeName,
iconClass,
selectMessage,
isEnabled: settings ? settings.actionTypes[type].enabled : true,
}));
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.
thanks - updated
@@ -75,21 +75,30 @@ export async function saveWatch(watch: BaseWatch, licenseService: any) { | |||
} | |||
|
|||
export async function validateActionsAndSaveWatch(watch: BaseWatch, licenseService: any) { | |||
const { warning } = watch.validate(); |
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 am not sure this is correct. From the comment
The way I setup my Slack Webhook for this watch, it has a default "to" on the slack side.
So a "to" is required. The thing is, the user can set it multiple ways. The warning that was put in place is: "we can't validate that you have set properly a "to" field, be aware that the watch might not work if you haven't specified it outside our UI".
This validation was useful if the user enters "Create advanced watch", add a JSON payload of the watch with a Slack action, but without a "to" field.
💔 Build Failed |
@sebelga, thanks for your review! I believe I addressed all of your comments. Also, fixed a couple bugs I came across while making changes. Can you take another look when you get a chance? I’d like to address the design issues in a follow-up PR if that works for you (changing the actions dropdown to a button, and updating the webhook form to have one field for host/port/path) I opened an issue against EUI regarding the ComboBox, but realized that it is working as intended. We might need to rethink how we’re using it. See: elastic/eui#1901. I tested the scenario mentioned in #23887. It works as expected in edit mode. However, it looks like we are missing the error column and corresponding modal on the details pages (see screenshots of old UI below). This is unrelated to my changes, so I think this should be addressed in a separate PR. FYI @cjcenizal |
💔 Build Failed |
retest |
💚 Build Succeeded |
💚 Build Succeeded |
This PR adds support for adding actions via threshold alert.
Other action items:
Instructions
Instructions for setting up accounts to test actions.
Index, webhook and logging actions can be tested without any configuration in ES.
All other actions need at least one configured account to work.
Slack
Follow documentation here.
I used my own account and created a dummy channel:
#alison-watcher-test
. I plan on archiving after testing is complete.PagerDuty
Follow documentation here.
Jira
Follow documentation here.
Please DM me for details on a Jira account to use.
Email
Follow documentation here.
Screenshots
Actions panel with no actions selected:
Actions dropdown:
Email action:
Logging action:
Slack action:
Webhook action:
Index action:
PagerDuty action:
Jira action:
Action with field error:
Advanced watch with invalid action: