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

[Watcher] Add Webhook Action type on client #29818

Merged
merged 5 commits into from Feb 4, 2019

Conversation

sebelga
Copy link
Contributor

@sebelga sebelga commented Feb 1, 2019

This PR adds the missing action types on the Watcher UI client. Currently, we have an issue related to the Webhook action missing but there are other action types missing.

To unblock #29787 this PR could be merged for the Webhook action that was missing. I will add though the other missing action types to avoid future bugs.

  • Webhook action
  • Index action
  • HipChat action
  • PagerDuty action
  • Jira action

Note: There are several static properties defined on each action class but I can't seem to find where in the UI they are actually used. I put a comment at the bottom of the webhook.action.js file about it.

How to test

  • Start by creating a watcher with a webhook action in the dev console
PUT _watcher/watch/my-watch
{
  "trigger" : {
    "schedule" : { "cron" : "0/5 * * * * ?" }
  },
  "input" : {
    "search" : {
      "request" : {
        "indices" : [
          "kibana_sample_data_flights"
        ],
        "body" : {
          "query" : {
            "bool" : {
              "must" : {
                "match": {
                   "Carrier": "Kibana Airlines"
                }
              }
            }
          }
        }
      }
    }
  },
  "condition" : {
    "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}
  },
  "actions" : {
    "my_webhook" : { 
      "webhook" : {
        "method" : "POST", 
        "host" : "localhost", 
        "port" : 3000, 
        "path": ":/{{ctx.watch_id}}", 
        "body" : "id={{ctx.watch_id}}, hits={{ctx.payload.hits.total}}" 
      }
    }
  }
}
  • Got to the Watcher app and click on "edit" on the row of the created watcher

What we want to test is making sure that the body of the HTTP request contains the corresonding values that we have defined in the JSON editor (and of course that the application does not crash) when saving the watcher.

@sebelga sebelga added bug Fixes for quality problems that affect the customer experience Feature:Watcher Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more labels Feb 1, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

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

Tested locally, code LGTM

@elasticmachine
Copy link
Contributor

💔 Build Failed

@sebelga
Copy link
Contributor Author

sebelga commented Feb 1, 2019

retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Tested locally, fixed the bug reported by the user. Code LGTM! Just found a couple typos in comments. Great work acting on this so quickly, Seb!

* is where it seems that this is read. But I can't access that component navigatint the UI
*
*/
// static typeName = i18n.translate('xpack.watcher.models.webhookAction.typeName', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this commented-out code needed?

Copy link
Contributor Author

@sebelga sebelga Feb 4, 2019

Choose a reason for hiding this comment

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

I was hoping the reviewer(s) to be able to answer this commented code. 😊 Because it has been copied from other watcher action but those static variables don't seem to be used anywhere in the UI.
@bmcconaghy do you know if there used to be a UI form to define the watcher actions? (instead of the advanced JSON editor that we have now). It seems that those static properties were there for that purpose.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there was a draft of such a feature but AFAICR it never made it into an actual release. @chrisronline may remember differently/better.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not familiar with those comments at all unfortunately

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok thanks @chrisronline

* the "advanced watcher" creation through the JSON editor.
*
* ---> ./components/watch_actions/components/watch_action/watch_actions.html
* is where it seems that this is read. But I can't access that component navigatint the UI
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: navigatint -> in

/**
* NOTE:
*
* I don't seem to find in the UI where those static properties are actuall used.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: actuall -> actually

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don' look at the typo, look at the text! 😄 hahaha. This will be eventually removed.

@cjcenizal
Copy link
Contributor

Retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

@cjcenizal
Copy link
Contributor

Looks like these CI failures are the same ones intermittently occurring on master. Kibana team will have to fix this in master before we merge. I believe Spencer is looking into this.

@cjcenizal
Copy link
Contributor

CI has been fixed in master so now this branch just needs to merge those changes in.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@sebelga
Copy link
Contributor Author

sebelga commented Feb 4, 2019

I am going to merge this PR so we have a fix for the #29787 bug. I will create a separate PR for the other missing Watcher actions.

@sebelga sebelga merged commit 2c257df into elastic:master Feb 4, 2019
sebelga added a commit to sebelga/kibana that referenced this pull request Feb 4, 2019
sebelga added a commit to sebelga/kibana that referenced this pull request Feb 4, 2019
sebelga added a commit that referenced this pull request Feb 4, 2019
* Add missing Webhook action on client.

Fixes #29787
sebelga added a commit that referenced this pull request Feb 4, 2019
* Add missing Webhook action on client

Fixes #29787
@cjcenizal cjcenizal changed the title [Watcher] Add missing Action types on client [Watcher] Add missing Action types on client (webhook) Feb 5, 2019
@sebelga sebelga deleted the fix/watcher-webhook-action branch February 5, 2019 07:29
@cjcenizal
Copy link
Contributor

Follow-up PR with other actions is here: #30043

@cjcenizal cjcenizal changed the title [Watcher] Add missing Action types on client (webhook) [Watcher] Add Webhook Action type on client Feb 8, 2019
@cjcenizal
Copy link
Contributor

This is a step towards addressing #18059.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@bhavyarm
Copy link
Contributor

bhavyarm commented Feb 14, 2019

@sebelga @cjcenizal when I try to test this PR - I get error. I am using the watch in description. This is on BC1 of 6.6.1. Can you please tell me whats happening?

screen shot 2019-02-14 at 5 53 37 pm

Logs:

 error  [22:27:22.409] [warning][process] UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'reject' of undefined
    at heap.(anonymous function).onFunctionNotFound.then.catch.e (/Users/bhavyarajumandya/Desktop/release_6.6.1/kibana-6.6.1-darwin-x86_64/src/legacy/core_plugins/interpreter/server/lib/route_expression/thread/index.js:56:38)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at emitWarning (internal/process/promises.js:81:15)
    at emitPromiseRejectionWarnings (internal/process/promises.js:120:9)
    at process._tickCallback (internal/process/next_tick.js:69:34)
 error  [22:27:22.409] [warning][process] TypeError: Cannot read property 'reject' of undefined
    at heap.(anonymous function).onFunctionNotFound.then.catch.e (/Users/bhavyarajumandya/Desktop/release_6.6.1/kibana-6.6.1-darwin-x86_64/src/legacy/core_plugins/interpreter/server/lib/route_expression/thread/index.js:56:38)
    at process._tickCallback (internal/process/next_tick.js:68:7)

@cjcenizal
Copy link
Contributor

@bhavyarm I believe this only made it into 6.6.1.

@bhavyarm
Copy link
Contributor

@cjcenizal apologies 6.6.1. Sorry too many releases. The error I am seeing is on 6.6.1. I have corrected my comment.

@bhavyarm
Copy link
Contributor

This works fine apart from a copy bug. Logging it in a bit. Thanks @sebelga

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Watcher Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v6.6.1 v6.7.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants