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

Timelion query language support for scripted fields #14700

Merged
merged 7 commits into from
Nov 8, 2017

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Nov 1, 2017

fixes #9022

Adds scripted field support to timelion .es() for the metric and split arguments

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

This is a great addition.

The limitation the index-param needs to match the indexpattern-name is very reasonable.

I don't really know why this isn't working with the logstash-* index-pattern. Maybe due to the - character?

@@ -27,7 +27,7 @@ export default new Datasource('es', {
{
name: 'index',
types: ['string', 'null'],
help: 'Index to query, wildcards accepted'
help: 'Index to query, wildcards accepted. Provide Index Pattern name for scripted field support.'
Copy link
Contributor

@thomasneirynck thomasneirynck Nov 3, 2017

Choose a reason for hiding this comment

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

This is somewhat of odd, and I might be missing something.

Have you tested this with the default logstash-* index-pattern, from the examples with makelogs? I tried it, and no matching saved-objects come up. Creating a new index pattern, something like log*, does make it work.

};
} else {
dateAgg.time_buckets.aggs[metricName][metric[0]] = { field: metric[1] };
}
Copy link
Contributor

Choose a reason for hiding this comment

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

thoughts on extracting this boilerplate in separate module, shared with buildRequest? There's some overlap

      const scriptedField = scriptedFields.find(field => {
        return field.name === clause[0];
      });
      if (scriptedField) {
        termsAgg.script = {
          inline: scriptedField.script,
          lang: scriptedField.lang
        };
      } else {
        termsAgg.field = clause[0];
      }

@nreese
Copy link
Contributor Author

nreese commented Nov 3, 2017

@thomasneirynck Turns out the title field is analyzed so the - character causes the search to return no results. There is an open issue for this but will not be resolved any time soon.

As a work around, I can remove characters like - from the savedObjectClient.find request since the results are filtered for an exact title match. What do you think? Is this an ok workaround?

@thomasneirynck
Copy link
Contributor

@nreese oh so funny, known issue.

work-around sounds good. i think that'll be better than just transparently fail. it'd also be a weird limitation to document.

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

sweet, so all it took was quotes...

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

nice! LGTM

@nreese nreese merged commit 86e3925 into elastic:master Nov 8, 2017
nreese added a commit to nreese/kibana that referenced this pull request Nov 8, 2017
* update run REST API to fetch index pattern and use script for scripted fields

* allow scripted fields for elasticsearch split argument

* add test cases for scripted fields to elasticsearch test

* update help text for .es() index argument

* move scripted field check into common file, remove stop characters from index pattern title

* use space instead of nothing for replacing stop chars

* wrap index name in quotes instead of removing dash character
nreese added a commit that referenced this pull request Nov 8, 2017
* update run REST API to fetch index pattern and use script for scripted fields

* allow scripted fields for elasticsearch split argument

* add test cases for scripted fields to elasticsearch test

* update help text for .es() index argument

* move scripted field check into common file, remove stop characters from index pattern title

* use space instead of nothing for replacing stop chars

* wrap index name in quotes instead of removing dash character
chrisronline pushed a commit to chrisronline/kibana that referenced this pull request Nov 20, 2017
* update run REST API to fetch index pattern and use script for scripted fields

* allow scripted fields for elasticsearch split argument

* add test cases for scripted fields to elasticsearch test

* update help text for .es() index argument

* move scripted field check into common file, remove stop characters from index pattern title

* use space instead of nothing for replacing stop chars

* wrap index name in quotes instead of removing dash character
chrisronline pushed a commit to chrisronline/kibana that referenced this pull request Dec 1, 2017
* update run REST API to fetch index pattern and use script for scripted fields

* allow scripted fields for elasticsearch split argument

* add test cases for scripted fields to elasticsearch test

* update help text for .es() index argument

* move scripted field check into common file, remove stop characters from index pattern title

* use space instead of nothing for replacing stop chars

* wrap index name in quotes instead of removing dash character
@nreese nreese deleted the timelion_scripted branch February 13, 2018 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timelion query language support for scripted fields
3 participants