发布时间:2019-08-28 09:19:00编辑:auto阅读(1845)
1 | pip install elasticsearch |
1 2 | from elasticsearch import Elasticsearches = Elasticsearch([{'host':'10.10.13.12','port':9200}]) |
1 | es.search(index='logstash-2015.08.20', q='http_status_code:5* AND server_name:"web1"', from_='124119') |
1 2 | In[52]: es.count(index='logstash-2015.08.21', q='http_status_code:500')Out[52]:{u'_shards':{u'failed':0, u'successful':5, u'total':5}, u'count':17042} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Initialize the scrollpage = es.search( index ='yourIndex', doc_type ='yourType', scroll ='2m', search_type ='scan', size =1000, body ={ # Your query's body})sid = page['_scroll_id']scroll_size = page['hits']['total']# Start scrollingwhile(scroll_size >0): print "Scrolling..." page = es.scroll(scroll_id = sid, scroll ='2m') # Update the scroll ID sid = page['_scroll_id'] # Get the number of results that we returned in the last scroll scroll_size = len(page['hits']['hits']) print "scroll size: "+ str(scroll_size) # Do something with the obtained page |
1 2 3 4 5 6 | "range":{ "money":{ "gt":20, "lt":40 }} |
1 2 3 4 5 6 7 | { "bool":{ "must":[], "should":[], "must_not":[], }} |
1 2 3 4 5 | { "terms":{ "money":20 }} |
1 2 3 4 5 | { "terms":{ "money": [20,30] }} |
1 2 3 4 5 | { "regexp": { "http_status_code": "5.*" }} |
1 2 3 4 5 | { "match":{ "email":"123456@qq.com" }} |
1 2 3 4 5 6 | { "multi_match":{ "query":"11", "fields":["Tr","Tq"] }} |
1 2 3 4 5 6 7 8 9 | {'query': {'filtered': {'filter': {'range': {'@timestamp':{'gt':'now-1h'}} } } }} |
1 2 3 4 5 6 7 8 | { "query":{ "filtered":{ "query":{"match":{"http_status_code":500}}, "filter":{"term":{"server_name":"vip03"}} } }} |
1 2 3 4 5 6 7 8 9 10 | {'facets': {'stat': {'terms': {'field':'http_status_code', 'order':'count', 'size':50} } }, 'size':0} |
1 2 3 4 5 6 7 8 9 10 | {'facets': {'cip': {'terms': {'fields':['client_ip']}}, 'status_facets':{'terms':{'fields':['http_status_code'], 'order':'term', 'size':50}}}, 'query':{'query_string':{'query':'*'}}, 'size':0} |
1 2 3 4 5 6 7 8 9 10 11 12 | {'facets': {'tag': {'terms': {'fields':['http_status_code','client_ip'], 'size':10 } } }, 'query': {'match_all':{}}, 'size':0} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | { "facets": { "0": { "date_histogram": { "field": "@timestamp", "interval": "5m" }, "facet_filter": { "fquery": { "query": { "filtered": { "query": { "query_string": { "query": "*" } }, "filter": { "bool": { "must": [ { "range": { "@timestamp": { 'gt': 'now-1h' } } }, { "exists": { "field": "http_status_code.raw" } }, # --------------- ------- # 此处加匹配条件 ] } } } } } } } }, "size": 0} |
1 2 3 4 5 | {"query": { "query_string": {"query": "backend_name:baidu.com"} }}, |
上一篇: Python基础-对数
下一篇: python读写protobuf
51128
50521
41141
37984
32448
29349
28221
23066
23033
21359
1396°
2087°
1742°
1669°
1959°
1745°
2416°
4074°
3952°
2825°