-
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 index action as built-in action #41592
Conversation
Currently there is no config for this action, and the params look like this: const ParamsSchema = schema.object({
index: schema.string(),
doc_id: schema.maybe(schema.string()),
execution_time_field: schema.maybe(schema.string()),
refresh: schema.maybe(schema.boolean()),
body: IndexBodySchema,
});
It seems like having So, thinking we could make This would be the first case of having an execution property being set by config | params, which is something we will likely see again. |
retest |
💔 Build Failed |
💔 Build Failed |
aca712d
to
685bc6b
Compare
💔 Build Failed |
💚 Build Succeeded |
💚 Build Succeeded |
e47a543
to
c34650b
Compare
Pinging @elastic/kibana-stack-services |
💚 Build Succeeded |
fixes #40027 |
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.
Just one small comment but everything else looks good.
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.
Looking good, just a couple of things need to get addressed (localization most importantly).
x-pack/legacy/plugins/actions/server/builtin_action_types/es_index.ts
Outdated
Show resolved
Hide resolved
type IndexArrayBodySchemaType = TypeOf<typeof IndexArrayBodySchema>; | ||
|
||
// see: https://www.elastic.co/guide/en/elastic-stack-overview/current/actions-index.html | ||
// - timeout not added here, as this seems to be a generic thing we want to do |
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.
wondering if we do want to add timeout here, as you might want to have that value be different from whatever would be set globally.
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 have a card open for this - https://github.com/elastic/kibana/projects/26#card-24087404
Yeah, I think we will probably want a global timeout, and then allow an action type to override. Then the next question is, how can a user change these? env var or kibana yaml config or ...
We could get more elaborate, allow timeout per action, but I don't think we need to go there just yet ...
doc_id: schema.maybe(schema.string()), | ||
execution_time_field: schema.maybe(schema.string()), | ||
refresh: schema.maybe(schema.boolean()), | ||
body: IndexBodySchema, |
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.
looks like we are also missing refresh
and transform
from the options that watcher index action supports. Thinking that body
isn't the best name for this param, maybe document
instead? Also thinking that we should make this always an array, to make it more obvious that you can pass multiples 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.
documents
sounds good, as does always making it an array; that means doc_id
would go away, as that was only applicable to the single document case.
refresh
is already there. transform
isn't, because I figured transform
was a general watcher thing, perhaps not appropriate for Kibana. Guessing that if we want it here, we want it as a general capability for all actions. And to some extent, this may intersect with the thought of using templates to generate action parameters. And maybe what we want in the end is to use "expressions" to handle all this jazz. Expressions being the kind of "painless" of Kibana (in terms of a general transformer thing, and it's ubiquity) ...
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.
@bmcconaghy so ... whatcha thinking on transform
? Even though I think it's possible it could be a general thing for actions, perhaps it's really most appropriate for the index
action, since that one deal in fairly arbitrary JSON-able objects, vs the other actions which have less arbitrary params and are more "notification"-y vs "update the db"-y.
Perhaps some research is required to see how people are using it today with watcher, come up with a use case for using it today?
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 don't really know how it is used today. I suppose that the alert that was going to trigger this action could do its own transformation, so maybe it's not necessary. Just was looking to see if we were at watcher parity and noticed this.
@@ -49,7 +50,7 @@ async function executor(execOptions: ActionTypeExecutorOptions): Promise<ActionT | |||
} catch (err) { | |||
return { | |||
status: 'error', | |||
message: `error logging message: ${err.message}`, | |||
message: `error in action ${id} logging message: ${err.message}`, |
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 and all strings returned from API calls should be localized.
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.
Probably localization should be a separate PR - created a card for that - https://github.com/elastic/kibana/projects/26#card-24316443
- moved `nullableType` to a module so it can be reused across action types - changed index action param `body` to `documents`, and it's no longer an object or array, it's only an array - rename index action param `execution_time_field` to `executionTimeField` - remove index action param `doc_id` as it's no longer relevant (only useful in the single document story previously)
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 for my comments 👍
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.
retest |
💔 Build Failed |
The |
💔 Build Failed |
retest |
💚 Build Succeeded |
* Adds index action as built-in action * resolve PR comments - moved `nullableType` to a module so it can be reused across action types - changed index action param `body` to `documents`, and it's no longer an object or array, it's only an array - rename index action param `execution_time_field` to `executionTimeField` - remove index action param `doc_id` as it's no longer relevant (only useful in the single document story previously)
* Adds index action as built-in action * resolve PR comments - moved `nullableType` to a module so it can be reused across action types - changed index action param `body` to `documents`, and it's no longer an object or array, it's only an array - rename index action param `execution_time_field` to `executionTimeField` - remove index action param `doc_id` as it's no longer relevant (only useful in the single document story previously)
Intended to be functionally equivalent to the watcher index action.