Skip to content

fixes #4693 and fixes #4526: add Nested type bucket aggregation support for elasticsearch datasource#4694

Merged
torkelo merged 1 commit intografana:masterfrom
arcolife:nested_agg_query
Feb 27, 2017
Merged

fixes #4693 and fixes #4526: add Nested type bucket aggregation support for elasticsearch datasource#4694
torkelo merged 1 commit intografana:masterfrom
arcolife:nested_agg_query

Conversation

@arcolife
Copy link
Contributor

@arcolife arcolife commented Apr 13, 2016

EDIT: This PR was accidentally merged by the maintainer. Follow up at #4694 (comment)


This adds support for querying nested fields with elasticsearch as datasource; built on top of PR #4527

fixes #4693

Cheers.

@arcolife
Copy link
Contributor Author

arcolife commented Apr 13, 2016

@torkelo Would look something like this. Your thoughts? (I'll change the Nested Query part to another dropdown list).

screenshot from 2016-04-18 23-24-38

Also the arrangements of Group By / Then By, would matter, since date_histogram has to be the outermost agg. I first included nested options under Metric as a new option "Average (nested)" but then that wouldn't make sense, so I changed it to show as an option under bucket aggs.

@arcolife
Copy link
Contributor Author

arcolife commented Apr 14, 2016

A query generated from this would look something like:

..
"aggs": {
    "4": {
      "date_histogram": {
        "interval": "1m",
        "field": "_timestamp",
        "min_doc_count": 0,
        "extended_bounds": {
          "min": "1434982853565",
          "max": "1434984034923"
        }
      },
      "aggs": {
        "2": {
          "nested": {
            "path": "disk"
          },
          "aggs": {
            "nested_aggs": {
              "filter": {
                "term": {
                  "disk.disk-device": "dev8-0"
                }
              },
              "aggs": {
                "1": {
                  "avg": {
                    "field": "disk.wr_sec"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

And sample results:

..
"aggregations": {
    "4": {
        "buckets": [
            {
                "2": {
                    "doc_count": 9,
                    "nested_aggs": {
                        "1": {
                            "value": 90.4
                        },
                        "doc_count": 1
                    }
                },
                "key_as_string": "2015-06-22T14:20:00.000Z",
                "key": 1434982800000,
                "doc_count": 1
            }..
..

Notice extra levels of hierarchy in buckets.

@arcolife arcolife force-pushed the nested_agg_query branch 2 times, most recently from 0f62869 to 2f06cb8 Compare April 19, 2016 14:54
@arcolife arcolife changed the title WIP: add Nested type bucket aggregation support for elasticsearch datasource; fixes #4693 fixes #4693: add Nested type bucket aggregation support for elasticsearch datasource Apr 19, 2016
@arcolife arcolife force-pushed the nested_agg_query branch 3 times, most recently from 92ded71 to 21db062 Compare April 27, 2016 14:31
@arcolife arcolife changed the title fixes #4693: add Nested type bucket aggregation support for elasticsearch datasource fixes #4693 and fixes #4526: add Nested type bucket aggregation support for elasticsearch datasource Apr 27, 2016
@arcolife arcolife force-pushed the nested_agg_query branch 2 times, most recently from 2d74214 to 06dd8fa Compare April 27, 2016 14:51
@portante
Copy link

@arcolife, can you rebase this work?

@arcolife
Copy link
Contributor Author

rebased. Thanks!
Also fixed a bug from one of the earlier commits of master. ref: a1faaa1#commitcomment-17295710

@arcolife arcolife force-pushed the nested_agg_query branch 3 times, most recently from a5369e2 to b0ae077 Compare April 30, 2016 21:12
@arcolife
Copy link
Contributor Author

arcolife commented Apr 30, 2016

added unit test for nested aggs: https://github.com/grafana/grafana/pull/4694/files#diff-c0af25ef637ff34b3c81f7ff8b78243cR122

@torkelo Please review. Thanks!

@arcolife arcolife force-pushed the nested_agg_query branch 3 times, most recently from f623cfa to f5e336d Compare May 3, 2016 11:43
@arcolife
Copy link
Contributor Author

@torkelo hey could you do a quick usability review and let me know what to change? I'd be glad if this gets merged sooner; really need this feature in official.. thanks!

@arcolife arcolife force-pushed the nested_agg_query branch from f5e336d to 32d8103 Compare May 14, 2016 06:16
@concaf
Copy link

concaf commented Jun 6, 2016

+1 @arcolife, it would be very useful for our project too!

@krishnakalyan3
Copy link

krishnakalyan3 commented Jun 8, 2016

+1 @arcolife Looks like a good feature.

@arcolife
Copy link
Contributor Author

arcolife commented Jun 8, 2016

@torkelo Sarjitsu is a project powered by Grafana, where I wanna make use of the nested docs feature and it would really cool to have it integrated. I've blogged about it here: http://arcolife.github.io/blog/2016/06/06/sarjitsu-a-project-on-visualizing-your-systems-activity/

Would appreciate your quick feedback, so we could take this further. I was thinking we could release a separate build with this feature, and put it out there for testing. Thanks!

* (elasticsearch): add nested agg (use bucket aggs). fixes grafana#4693

* (elasticsearch): rebased after merge of grafana#6043 refactored from grafana#4527
@arcolife
Copy link
Contributor Author

@torkelo @alexanderzobnin This patch has been in a limbo since we last worked on #6043. Could you guys review this once? I've rebased to get rid of conflicts.
Let me know if there's something wrong with it and I could update this quickly. We're eagerly waiting for this feature, since Kibana doesn't do nested docs either (IIRC). Thanks.

@arcolife
Copy link
Contributor Author

Ok CI check 1 failed, 1 passed. let me look at the failing checks and get back to you with updates.. (a lot has changed in grafana since last year). But do let me know when you would have time to review this.

@torkelo torkelo merged commit 8087af9 into grafana:master Feb 27, 2017
torkelo added a commit that referenced this pull request Feb 27, 2017
@torkelo
Copy link
Contributor

torkelo commented Feb 27, 2017

sorry, merged this by mistake (to many PR tabs open). Reverted the merge.

@arcolife
Copy link
Contributor Author

@torkelo I see this as merged, while this was reverted. Do I need to reopen this patch in another PR or can this be resurrected?

@torkelo
Copy link
Contributor

torkelo commented Mar 7, 2017

it is not possible to reopen a merged PR (that was later reverted)

@arcolife
Copy link
Contributor Author

arcolife commented Mar 7, 2017

ok i'll add another PR then, piggy backing on this one.

@arcolife
Copy link
Contributor Author

@torkelo ^ turns out I can't really add another PR because github shows me "This branch is even with grafana:master." when I click https://github.com/arcolife/grafana/tree/nested_agg_query due to the accidental merge on master earlier. Any clues on how we can get this back on track? thanks.
cc/ @portante

@arcolife
Copy link
Contributor Author

arcolife commented Mar 17, 2017

okay so i've added a new PR mirroring the patches from this one. WIP now at #7863

@carlosvega
Copy link

Is this available in any Grafana release? How is it doing?

@lephix
Copy link

lephix commented Jul 15, 2017

+1

1 similar comment
@killpanda
Copy link

+1

@ali-bugdayci
Copy link

+++1

arcolife pushed a commit to arcolife/grafana that referenced this pull request Dec 26, 2017
… is to correct grafana#4694's accidental merge

* (elasticsearch): add nested agg (use bucket aggs). fixes grafana#4693

* (elasticsearch): rebased after merge of grafana#6043 refactored from grafana#4527
@arcolife
Copy link
Contributor Author

@ali-bugdayci @killpanda @lephix @carlosvega @rburkhonov @gsaslis for updates on this, kindly refer to #7863 (comment)

Looking for feedback! thanks.

@ameed93
Copy link

ameed93 commented Mar 18, 2020

@arcolife : could you please share the docker image if you have it?

@arcolife
Copy link
Contributor Author

@ameed93 no docker image with me. After this PR was "accidentally merged", I had another one #7863 -> rebased a couple times and needed reviews from the devs which it never got.

@ameed93
Copy link

ameed93 commented Mar 18, 2020

@arcolife: it's very sad how they treat this feature, its a very important one, I decided to create my custom graphs!
Just a question: can I build a docker image from #7863? since I tried to do that with this branch but that didn't work!

PS: I think if you publish #7863 to get more +1's, maybe they will take a look.

@arcolife
Copy link
Contributor Author

arcolife commented Mar 19, 2020

@ameed93 sure go ahead (not so sure it'll work as expected, and then you'd have to go backwards with corresponding ES versions as well I suppose). Also I don't think that PR is complete since I was waiting for reviews before refactoring further. But I'm interested in the outcome nonetheless.

most of the folks have ended up flattening their nested structes in ES as a workaround. lol

not sure about state of affairs right now with Grafana if it has an editable ES query box that supports the nested types. It'll be harder for sure than UI boxes.

To that end, my work on nested fields autocomplete in query searh was wrapped around in #6043 and merged, so it shouldn't be too difficult to build a query, hopefully. Also #3772 and #4526

@ying-jeanne ying-jeanne added the pr/external This PR is from external contributor label Apr 29, 2021
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.

Elasticsearch: No option for 'nested' type bucket aggregation to deal with nested fields