際際滷
Submit Search
[????] Elasticsearch Aggregation (2018)
?
2 likes
?
1,032 views
?? ?
Follow
2018? ???? ?????? ?? ?? ?? ??
Read less
Read more
1 of 45
More Related Content
[????] Elasticsearch Aggregation (2018)
1.
Elasticsearch Aggregation ???
2.
?? (Aggregation)
3.
??(Aggregation)?? ? ??, ??,
????? ??? ?? ? ???? ?? ??????? ????? ? ?? ??? ???? ????? ?? ??(??/??) ??(??? ??? ??? ??? ?)? ?? ? ???? ???? ??? ???? ??? ????.
4.
Aggregation ?? "aggregations" :
{ "<aggregation_name>" : { "<aggregation_type>" : { <aggregation_body> } [,"meta" : { [<meta_data_body>] } ]? [,"aggregations" : { [<sub_aggregation>]+ } ]? } [,"<aggregation_name_2>" : { ... } ]* } ?? ?? (??? ?? ???? ??? ??? ??? ?? ??)
5.
Aggregation ?? "aggregations" :
{ "<aggregation_name>" : { "<aggregation_type>" : { <aggregation_body> } [,"meta" : { [<meta_data_body>] } ]? [,"aggregations" : { [<sub_aggregation>]+ } ]? } [,"<aggregation_name_2>" : { ... } ]* } terms, date_historam, sum? ?? ? ?? ??? ??? ??
6.
Aggregation ?? "aggregations" :
{ "<aggregation_name>" : { "<aggregation_type>" : { <aggregation_body> } [,"meta" : { [<meta_data_body>] } ]? [,"aggregations" : { [<sub_aggregation>]+ } ]? } [,"<aggregation_name_2>" : { ... } ]* } Aggregation_type? ?? ??? ??. (??? ?? ??? ????? ?? ??)
7.
Aggregation ?? "aggregations" :
{ "<aggregation_name>" : { "<aggregation_type>" : { <aggregation_body> } [,"meta" : { [<meta_data_body>] } ]? [,"aggregations" : { [<sub_aggregation>]+ } ]? } [,"<aggregation_name_2>" : { ... } ]* } Meta ??? ??? ??? ?? ? ??? ???? ???. (?? ??? ??? ???? ?? ? ?? ??)
8.
Aggregation ?? "aggregations" :
{ "<aggregation_name>" : { "<aggregation_type>" : { <aggregation_body> } [,"meta" : { [<meta_data_body>] } ]? [,"aggregations" : { [<sub_aggregation>]+ } ]? } [,"<aggregation_name_2>" : { ... } ]* } ?? ??? ?? ??? ?? ? ? ?? ?? ?? (?? ??)
9.
Aggregation ?? "aggregations" :
{ "<aggregation_name>" : { "<aggregation_type>" : { <aggregation_body> } [,"meta" : { [<meta_data_body>] } ]? [,"aggregations" : { [<sub_aggregation>]+ } ]? } [,"<aggregation_name_2>" : { ... } ]* } ? ??? ??? ??? ??. ? ??? ??? ??? ?? (?? ??)
10.
?? ?? (Sub
Aggregation) ? ??? ??? ?? ? ?? ? ???? ???? ??? ??? ? ? ??? ??? ??? ?? ? ? ??? ?? ?? ? ??????? ??? ??? ?? ??? ??? ? ? ?? ??? ? ? ?? ??? ?? ??? ??? ??? ?? ??? ????.
11.
?? ?? ? ??
??? ??? ??? ???? ? ? ?? ??? ??? ???? ?? ???? ??? ??? ? ?? ? ??.
12.
?? ?? ? ???
?? (Metric Aggregation) ? ?? ?? (Bucket Aggregation) ? ???? ?? (Matrix Aggregation) ? ????? ?? (Pipeline Aggregation)
13.
??? ??
14.
??? ??(Metric Aggregation) ?
?? ??? ???? ?????? ?? ?? ? ??/???, ??, ??, ???? ?
15.
??? ?? ?? ???
? ??? ??? ????
16.
?? ?? ? ???
? ??? ???? ??? ??? ??? ????. ? ? ? ???? ?? ??? ???????? ??? ??? ?? ????. ? ???? ?? ? bytes ??? ???? ??? ???? ?? ? ????. ? ????? bytes ??? ?? ???? ??? ????.
17.
?? ?? GET /apache-web-log/_search?size=0 { "aggs":
{ "total_bytes": { "sum": { "field": "bytes" } } } } ??? ???? ?? ??? total_bytes? ??
18.
?? ?? GET /apache-web-log/_search?size=0 { "aggs":
{ "total_bytes": { "sum": { "field": "bytes" } } } } ?? ??? ??? ?? sum ??
19.
?? ?? GET /apache-web-log/_search?size=0 { "aggs":
{ "total_bytes": { "sum": { "field": "bytes" } } } } ??? ???? ?? ?? ???? bytes ? ??
20.
?? ?? { ´ ??
... "aggregations": { "total_bytes": { "value": 2747282505 } } }
21.
?? ?? { ´ ??
... "aggregations": { "total_bytes": { "value": 2747282505 } } } ?? ??? ? ??? ????? ? ? ??.
22.
?? ??
23.
?? ??(Bucket Aggregation) ?
?? ??? ???? ?????? ?? ???? ?? ?? ?? ?? ?????? ??? ?? ?? ? ? ?, ???? ??? ???? ? ? ?) ??? ???? ?? ????? ?? ?? ??? ?? ? ?? ?? : ?? ??? ? ?? ?? : ?? ?? ? ? ?? ??? ??? ?????? ?? ?? ?? ?? ? ?? ?? : SUM(??)
24.
?? ?? ?? ?
?? ?? (Range Aggregation) ? ?? ?? ?? (Date Range Aggregation) ? ????? ?? (Histogram Aggregation) ? ?? ????? ??(Date Histogram Aggregation) ? ?? ?? (Terms Aggregation)
25.
?? ?? (Range
Aggregation) ? ???? ??? ?? ??? ??? ???? ?? ?? ?? ? ??? ?????? ?? ??? ?????? ?? ?? ? ??? ???? ?????? ???? ?? ?? ? from, to ??? ?? ?? ?? ? ??? ?? ??
26.
?? ?? ? (???
? ?? ?? ??? ?? ??) GET /apache-web-log/_search?size=0 { "aggs ̄ : {  ̄bytes_range ̄ : {  ̄range ̄: {  ̄field ̄: ^bytes ̄,  ̄ranges ̄: [ {  ̄from ̄: 1000,  ̄to ̄: 2000 } ] } } } } ??? ? ??? ??? ???? ? ?? 1000 ~ 2000 byte ??? ?? ???? ??
27.
?? ?? ? (???
? ?? ?? ??? ?? ??) ´ ?? ´ "aggregations": { "bytes_range": { "buckets": [ { "key": "1000.0-2000.0", "from": 1000, "to": 2000, "doc_count": 754 } ] } } } ?? ?? ??? ???? ??? 1000~2000 byte? ??? ???? ? ? 754?? ?? ? ? ??.
28.
?? ?? ??
(Date Range Aggregation) ? ??? ???? ?? ??? ?? ??? ??? ?? ?? ? From : ?? ?? ? To : ?? ??? ??? ?? ? ??? ??? ??
29.
?? ?? ??
? ??? ?? ??? ??? ??? ? GET /apache-web-log/_search?size=0 { "aggs" : { "request count with date range" : { "date_range": { "field": "timestamp", "ranges": [ { "from": "2015-01-04T05:14:00.000Z", "to": "2015-01-04T05:16:00.000Z" } ] } } } } ?? ??? ???????? ??? ? ??? ??
30.
?? ?? ??
? ??? ?? ??? ??? ??? ? ´ ?? ´ "aggregations": { "request count with date range": { "buckets": [ { "key": "2015-01-04T05:14:00.000Z-2015-01-04T05:16:00.000Z", "from": 1420348440000, "from_as_string": "2015-01-04T05:14:00.000Z", "to": 1420348560000, "to_as_string": "2015-01-04T05:16:00.000Z", "doc_count": 0 } ] } } ??? ??? ?? ??
31.
?? ?? ??
? ??? ?? ??? ??? ??? ? ´ ?? ´ "aggregations": { "request count with date range": { "buckets": [ { "key": "2015-01-04T05:14:00.000Z-2015-01-04T05:16:00.000Z", "from": 1420348440000, "from_as_string": "2015-01-04T05:14:00.000Z", "to": 1420348560000, "to_as_string": "2015-01-04T05:16:00.000Z", "doc_count": 0 } ] } } ?? ??? ???? ????? ?
32.
?? ?? ??
? ??? ?? ??? ??? ??? ? ´ ?? ´ "aggregations": { "request count with date range": { "buckets": [ { "key": "2015-01-04T05:14:00.000Z-2015-01-04T05:16:00.000Z", "from": 1420348440000, "from_as_string": "2015-01-04T05:14:00.000Z", "to": 1420348560000, "to_as_string": "2015-01-04T05:16:00.000Z", "doc_count": 0 } ] } } ?? ??? ??? ??
33.
?? ?? ??
? ??? ?? ??? ??? ??? ? ´ ?? ´ "aggregations": { "request count with date range": { "buckets": [ { "key": "2015-01-04T05:14:00.000Z-2015-01-04T05:16:00.000Z", "from": 1420348440000, "from_as_string": "2015-01-04T05:14:00.000Z", "to": 1420348560000, "to_as_string": "2015-01-04T05:16:00.000Z", "doc_count": 0 } ] } } ??? ??? ???? ????? ?
34.
?? ?? ??
? ??? ?? ??? ??? ??? ? ´ ?? ´ "aggregations": { "request count with date range": { "buckets": [ { "key": "2015-01-04T05:14:00.000Z-2015-01-04T05:16:00.000Z", "from": 1420348440000, "from_as_string": "2015-01-04T05:14:00.000Z", "to": 1420348560000, "to_as_string": "2015-01-04T05:16:00.000Z", "doc_count": 0 } ] } } ??? ??? ??? ??
35.
?? ?? ??
? ??? ?? ??? ??? ??? ? ´ ?? ´ "aggregations": { "request count with date range": { "buckets": [ { "key": "2015-01-04T05:14:00.000Z-2015-01-04T05:16:00.000Z", "from": 1420348440000, "from_as_string": "2015-01-04T05:14:00.000Z", "to": 1420348560000, "to_as_string": "2015-01-04T05:16:00.000Z", "doc_count": 0 } ] } } ?? ??? ??? ???? ?
36.
????? ?? (Histogram Aggregation) ?
?? ??? ????? ??? ??? ?? ? ?? ??? ?? ????? ??? ??? ??? ??? ? ??? ?? ???? ?? ? ?? ? ??? ?????? ?? ??? ??
37.
????? ?? ? ???
? ??? ???? ???? ??? ???? ?? GET /apache-web-log/_search?size=0 { "aggs" : { "bytes_histogram" : { "histogram" : { "field" : "bytes", "interval": 10000 } } } } 10000 byte ??? ?? ?? 0 ~ 10000 10000 ~ 20000 ´
38.
????? ?? ? ???
? ??? ???? ???? ??? ???? ?? "aggregations": { "bytes_histogram": { "buckets": [ { "key": 0, "doc_count": 4196 }, { "key": 10000, "doc_count": 1930 }, { "key": 20000, "doc_count": 539 }, ´ ?? ´ 0 ~ 10000 byte ??? ???? ?
39.
????? ?? ? ???
? ??? ???? ???? ??? ???? ?? "aggregations": { "bytes_histogram": { "buckets": [ { "key": 0, "doc_count": 4196 }, { "key": 10000, "doc_count": 1930 }, { "key": 20000, "doc_count": 539 }, ´ ?? ´ 10000 ~ 20000 byte ??? ???? ?
40.
?? ????? ??(Date
Histogram Aggregation) ? ????? ??? ????? ??? ?? ??? ???? ??. ? ? ??, ?? ??, ? ?? ?
41.
?? ????? ??
? ??? ??? ?? ?? GET /apache-web-log/_search?size=0 { "aggs" : { "daily_request_count" : { "date_histogram": { "field": "timestamp", "interval": "minute" } } } } ??? ?? ??? ???? timestamp ??? ??? ????? ?.
42.
?? ????? ??
? ??? ??? ?? ?? GET /apache-web-log/_search?size=0 { "aggs" : { "daily_request_count" : { "date_histogram": { "field": "timestamp", "interval": "minute" } } } } ? ??? ??? ?? ?? ?? ??? ??? ??? hour, ? ??? ??? ??? day? ??
43.
?? ????? ??
? ??? ??? ?? ?? "aggregations": { "daily_request_count": { "buckets": [ { "key_as_string": "2015-05-17T10:05:00.000Z", "key": 1431857100000, "doc_count": 74 }, { "key_as_string": "2015-05-17T10:06:00.000Z", "key": 1431857160000, "doc_count": 0 }, ´ ?? ´ ? ??? ??? ???? ?
44.
???? ??(Matrix Aggregation) ?
?? ??? ?? ????? ?? ???? ??? ?? ?? ??? ??. ? ???? ??? ?? ??? ?? ????? ???? ?? ?.
45.
????? ??(Pipeline Aggregation) ?
?? ??? ??? ??? ??? ??? ??