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

derivative metric aggregation #10020

Merged
merged 19 commits into from
Feb 13, 2017
Merged

derivative metric aggregation #10020

merged 19 commits into from
Feb 13, 2017

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Jan 23, 2017

Summary

(Note: See this PR also in combination with #10070 and #10033).

Kibana Visualizations like line, bar, area charts now support the majority of Elasticsearch's pipeline aggregations. These include the majority of parent and sibling aggregations . These aggregations give you a new look into their data. For example, the moving average aggregations allows users to smooth over outlier data points over time, or the derivative enables users to display rate of change.

image


derivative metric aggregation - cant find existing issue

@ppisljar ppisljar added Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review labels Jan 23, 2017
@thomasneirynck
Copy link
Contributor

jenkins, test this

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.

Do we need the 'Metric' combo-box? It only ever seems to include a single options? (maybe I''m missing something).

image

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.

  1. Anyway we can slightly indent the derivate-form? This is especially relevant for second-order derivatives.

  2. I don't think we need the Custom Label option for derivative (?). This probably need to be completely rewritten at each step. E.g. Distance->Velocity->Acceleration. We only care about acceleration since that's the only one that will get displayed.

image

@ppisljar
Copy link
Member Author

Metric combo box: yeah, as you might select an existing metric. This follows the same pattern you see if you choose Term bucket agg and look at order by combo box. You can select a pre-existing metric or you could add a custom metric.

I will update that design also matches that. i think that would address your 1) point.

regarding 2), i would maybe just leave it like that, for the sake of simplicity first and because it matches the pattern seen in other parts (like the order by in terms agg mentioned above). I agree that's not the best, but i would fix that in separate PR and in every place where it applies.

import VisAggConfigProvider from 'ui/vis/agg_config';
import VisSchemasProvider from 'ui/vis/schemas';

export default function AggTypeMetricDerivativeProvider(Private) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Switch to a named export?

Copy link
Member Author

Choose a reason for hiding this comment

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

every other agg type is using default export ... what do you think would be better? keeping this similar to other aggs ? or going with named export ? (which wont be used as this is only exporting a single thing)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's in our style guide, but I see your point. Up to you.

@stacey-gammon
Copy link
Contributor

stacey-gammon commented Jan 24, 2017

Speaking of custom labels... am I supposed to see goodbye as a label somewhere on this viz?

screen shot 2017-01-24 at 4 45 05 pm

[EDIT]

Looks like the Hello overrides the goodbye portion of the custom label. I feel like the custom label should be the whole thing, not derivative of [custom label].

screen shot 2017-01-24 at 4 47 47 pm

@stacey-gammon
Copy link
Contributor

Playing around and was able to run into this error. Albeit, I really don't know what I'm doing. :)
screen shot 2017-01-24 at 5 00 02 pm

import VisSchemasProvider from 'ui/vis/schemas';

export default function AggTypeMetricDerivativeProvider(Private) {
const DerivativeAggType = Private(AggTypesMetricsMetricAggTypeProvider);
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 this name is confusing - it's not a DerivativeAggType but a MetricAggType. The way it is named now, it looks like a subclass of MetricAggType, but if that was the case, you wouldn't have to pass in all the options to specialize the metric for a derivative type.

return new DerivativeAggType({
name: 'derivative',
title: 'Derivative',
makeLabel: function (aggConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this function could be pulled out into a separate file and then tested separately?

Copy link
Member Author

Choose a reason for hiding this comment

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

you mean makeLabel ? I would argue that it would be less readable after. I usually look at the following:

  • can the code be reused by something else ? if yes, separate out in a new file
  • is the original file too complex or long ? if yes, separate out
  • is it impossible to test ? if yes, separate out

but i think on all above the answer is no (i can test, the file is not really long, and this seems specific to just this agg, wont be reused elsewhere)

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose I disagree on the second point, I think this file would be more readable with less LOC. The more focused functions are, the more I can concentrate on what it is doing, and switch to other focus areas as a follow up. This file has a whole controller in it, which could also probably be split out. It also becomes tough to follow with a lot of indentation.

For instance, the creation of the params argument is a bit confusing for me to follow. It looks like the object parameters are later translated into classes based on the type and/or name field of the object. I got a little lost however because there are two agg_params.js files. More functions generally mean more comments, or barring that, self documenting code using the function name.

I also look at this file and wonder if we can separate the business logic from the angular portions. makeLabel has nothing angular specific about it, but this file has a reference to $scope and Private, which is angular specific.

Anyway, I'm fine if you leave as is, just expressing my opinion. This is the first I've looked at the visualize code, so trying to follow the logic is a bit tough.

@ppisljar
Copy link
Member Author

regarding labels ....
if you have Derivative of Count ... if you put custom label on count you could have Derivative of CUSTOM ... but if you put custom label on derivative you can completely override it with CUSTOM LABEL.

As @thomasneirynck pointed out above custom labels on intermediate levels don't make much sense, and i would prefer to solve that in separate PR, as similar issue already exists in visualize, hence i would like to fix it everywhere and its not only related to this PR.

@ppisljar
Copy link
Member Author

regarding the error, i can't see what buckets have you selected ... clould you paste whole request ?

  • this happens because you are trying to use derivative with something thats not histogram or date_histogram
  • the error should be properly handled by visualize editor (coloring derivative red ... ) ... this doesn't happen obviously

@ppisljar
Copy link
Member Author

tests are failing on FAIL: chrome on any platform - kibana - visualize app - visualize app - tile map chart - should zoom out to level 1 from default level 2, which is unrelated to this pr

@stacey-gammon
Copy link
Contributor

Here is the request that caused the error. I didn't select anything for the x-axis, I guess that is the issue.

{
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "analyze_wildcard": true,
            "query": "*"
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": 1485357911849,
              "lte": 1485358811850,
              "format": "epoch_millis"
            }
          }
        }
      ],
      "must_not": []
    }
  },
  "_source": {
    "excludes": []
  },
  "aggs": {
    "2": {
      "avg": {
        "field": "bytes"
      }
    },
    "3": {
      "derivative": {
        "buckets_path": "2"
      }
    }
  }
}

@ppisljar
Copy link
Member Author

@stacey-gammon I extracted the functions to new files, also the error should be fixed now.

@stacey-gammon
Copy link
Contributor

Nice, thanks!

So it's a bit confusing now where the error is coming from when not using the historgram for x-axis. I guess there is nothing we can do about that since we dont' support tooltips on that error icon?

screen shot 2017-01-26 at 11 50 06 am

I think I ran across another bug. If I first select custom metric for a sub derivative and run the visualization, I see results. If I then go back and select the non custom metric and hit run, nothing changes in the view.

derivativebug

@ppisljar
Copy link
Member Author

you rock @stacey-gammon !

regarding errors ... yeah they suck at the moment ... but I plan to start working on that shortly (in a separate PR)

@ppisljar
Copy link
Member Author

the bug is fixed (seems i introduced it during moving of makelabels function).
also i added separate tests for the make_nested_label

@ppisljar
Copy link
Member Author

ppisljar commented Feb 3, 2017

jenkins, test this

@stacey-gammon
Copy link
Contributor

Think I found something else. For some reason If I click x-axis first, but don't select anything, the custom derivative section looks funny. If I don't click x-axis first, everything seems to work. See if you can repro.

derivativebug

@ppisljar
Copy link
Member Author

ppisljar commented Feb 6, 2017

@stacey-gammon thanks ! it should be fixed now, also i fixed the tests (selenium ones are still failing due to tile map issue). can you take another look ?

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.

I like the new error messaging in place. It's useful, and would work better than an app-wide toast IMHO.

@cjcenizal
Copy link
Contributor

@alexfrancoeur I think the second example is better than the first one, since it grabs your attention more. It would be good to style these errors consistently, and then we can update their design en masse.

@tbragin
Copy link
Contributor

tbragin commented Feb 13, 2017

@ppisljar I also like the new error handling in the context of what we're trying to do. It's consistent with the other place where we signal something about agg ordering (pie chart), and I think it gives the user something actionable to react to when the aggregations are incorrectly ordered for derivative.
screen shot 2017-02-13 at 10 15 14 am

I have a minor tweak proposed for help text:

  • instead of "Last bucket must be "date histogram" or "histogram" when using derivative metric!"
  • i propose "Last bucket aggregation must be "Date Histogram" or "Histogram" when using "Derivative" metric aggregation!"

@ppisljar ppisljar merged commit be27727 into elastic:master Feb 13, 2017
elastic-jasper added a commit that referenced this pull request Feb 13, 2017
Backports PR #10020

**Commit 1:**
updating agg_config to allow adding parent aggregations

* Original sha: f83a3af
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:05:04Z

**Commit 2:**
derivative metric aggregation

* Original sha: c04b6c9
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:05:51Z

**Commit 3:**
disable on metric and tagcloud

* Original sha: 0698336
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:06:13Z

**Commit 4:**
fixing point series to correctly handle missing y values

* Original sha: 69a5329
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:06:39Z

**Commit 5:**
adding unit tests

* Original sha: 85c0b46
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:07:01Z

**Commit 6:**
fix broken ui

* Original sha: 20ae746
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-24T19:21:59Z

**Commit 7:**
removing percentile ranks

* Original sha: 7402c6c
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-24T20:11:45Z

**Commit 8:**
updating based on review

* Original sha: 40af4a3
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-25T07:14:21Z

**Commit 9:**
fixing bug and adding make_nested_label tests

* Original sha: 1d5e0c3
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-27T09:55:22Z

**Commit 10:**
fixing error

* Original sha: affdef6
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T09:56:51Z

**Commit 11:**
fixing test

* Original sha: b043ce1
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T09:59:35Z

**Commit 12:**
fixing based on last review

* Original sha: 8b321d6
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T16:49:42Z

**Commit 13:**
fixing based on thomas review

* Original sha: 32e75cc
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T17:13:29Z

**Commit 14:**
allow nested aggs

* Original sha: 1754424
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T17:25:51Z

**Commit 15:**
prevent sorting on derivative metric

* Original sha: ea7c055
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T18:33:08Z

**Commit 16:**
updating based on last review

* Original sha: acb11d8
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-07T09:10:56Z

**Commit 17:**
adding error message when histogram is not the last bucket

* Original sha: 4dc6af6
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-13T12:10:36Z

**Commit 18:**
fixing test

* Original sha: ff4777f
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-13T13:09:03Z

**Commit 19:**
updating error message

* Original sha: dc1133b
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-13T18:37:33Z
ppisljar pushed a commit that referenced this pull request Feb 13, 2017
Backports PR #10020

**Commit 1:**
updating agg_config to allow adding parent aggregations

* Original sha: f83a3af
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:05:04Z

**Commit 2:**
derivative metric aggregation

* Original sha: c04b6c9
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:05:51Z

**Commit 3:**
disable on metric and tagcloud

* Original sha: 0698336
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:06:13Z

**Commit 4:**
fixing point series to correctly handle missing y values

* Original sha: 69a5329
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:06:39Z

**Commit 5:**
adding unit tests

* Original sha: 85c0b46
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-23T21:07:01Z

**Commit 6:**
fix broken ui

* Original sha: 20ae746
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-24T19:21:59Z

**Commit 7:**
removing percentile ranks

* Original sha: 7402c6c
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-24T20:11:45Z

**Commit 8:**
updating based on review

* Original sha: 40af4a3
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-25T07:14:21Z

**Commit 9:**
fixing bug and adding make_nested_label tests

* Original sha: 1d5e0c3
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-01-27T09:55:22Z

**Commit 10:**
fixing error

* Original sha: affdef6
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T09:56:51Z

**Commit 11:**
fixing test

* Original sha: b043ce1
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T09:59:35Z

**Commit 12:**
fixing based on last review

* Original sha: 8b321d6
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T16:49:42Z

**Commit 13:**
fixing based on thomas review

* Original sha: 32e75cc
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T17:13:29Z

**Commit 14:**
allow nested aggs

* Original sha: 1754424
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T17:25:51Z

**Commit 15:**
prevent sorting on derivative metric

* Original sha: ea7c055
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-06T18:33:08Z

**Commit 16:**
updating based on last review

* Original sha: acb11d8
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-07T09:10:56Z

**Commit 17:**
adding error message when histogram is not the last bucket

* Original sha: 4dc6af6
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-13T12:10:36Z

**Commit 18:**
fixing test

* Original sha: ff4777f
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-13T13:09:03Z

**Commit 19:**
updating error message

* Original sha: dc1133b
* Authored by ppisljar <peter.pisljar@gmail.com> on 2017-02-13T18:37:33Z
@ppisljar ppisljar deleted the agg/derivative branch February 13, 2017 19:44
@tbragin tbragin added the v5.4.0 label May 4, 2017
@tbragin tbragin mentioned this pull request May 4, 2017
@ppisljar ppisljar restored the agg/derivative branch September 26, 2018 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review v5.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants