Last active
February 20, 2019 01:02
-
-
Save painnick/d9df1755ff2ae9c0e538f96c3572ae49 to your computer and use it in GitHub Desktop.
Elastic Search 명령어
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET api-*/_search | |
{ | |
"size": 0, | |
"aggs" : { | |
"Date" : { | |
"date_histogram" : { | |
"field" : "logtime", | |
"interval": "day", | |
"format" : "yyyy.MM.dd", | |
"time_zone": "+09:00" | |
}, | |
"aggs" : { | |
"ProcTime" : { | |
"histogram" : { | |
"field" : "processTime", | |
"interval": 20 | |
} | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST _bulk | |
{"index":{"_index":"api-2018.09.20","_type":"api"}} | |
{"logtime":"2018-09-20T16:16:01+09:00","method":"Test","code":"402","processTime":2101,"service_name":"poc1","server":"painnick-desktop5","@timestamp":"2018-09-20T07:16:20.306438957+00:00"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE api-2018.09.27 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST api-*/_search | |
{ | |
"size": 5, | |
"sort": [{"logtime":"desc"}], | |
"_source": ["method", "code", "processTime"], | |
"query": { | |
"constant_score": { | |
"filter": { | |
"bool": { | |
"must": [ | |
{"term": {"server": "006a13e76eaf"}}, | |
{"range": {"processTime": {"lt": 1000}}} | |
] | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST /api-poc1-2018.09.28/_search | |
{ | |
"size": 0, | |
"aggs" : { | |
"process_time_outlier" : { | |
"percentiles" : { | |
"field" : "processTime", | |
"percents": [90, 95, 99] | |
} | |
} | |
}, | |
"query": { | |
"bool": { | |
"must": [ | |
{"range": {"logtime": { | |
"gt": "now-5m" | |
}}} | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET _search | |
{ | |
"query": { | |
"match_all": {} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#상하위 10% 값 추출 | |
POST /api-poc1-*/_search | |
{ | |
"size": 0, | |
"aggs" : { | |
"process_time_outlier" : { | |
"percentiles" : { | |
"field" : "processTime", | |
"percents": [10, 90] | |
} | |
} | |
}, | |
"query": { | |
"bool": { | |
"must": [ | |
{"range": {"logtime": { | |
"gt": "now-1m" | |
}}} | |
] | |
} | |
} | |
} | |
#추출된 기준값 내의 평균값 | |
POST /api-poc1-*/_search | |
{ | |
"size": 0, | |
"aggs" : { | |
"normal_rage": { | |
"range": { | |
"field" : "processTime", | |
"ranges": [{"from":269.5, "to":3418}] | |
}, | |
"aggs": { | |
"stats": { | |
"avg": { | |
"field": "processTime" | |
} | |
} | |
} | |
} | |
}, | |
"query": { | |
"bool": { | |
"must": [ | |
{"range": {"logtime": { | |
"gt": "now-1m" | |
}}} | |
] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET api-*/_search | |
{ | |
"size": 0, | |
"aggs": { | |
"apis" : { | |
"terms": {"field":"method.keyword"} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment