Created
October 25, 2016 09:48
-
-
Save hynek2001/3559cc5ead015fc2115b9c8d3cf76fa0 to your computer and use it in GitHub Desktop.
kibana last 24
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
""" | |
curl | |
"http://172.21.168.120:5601/elasticsearch/_msearch?timeout=0&ignore_unavailable=true&preference=1477387351450" - H | |
"Origin: http://172.21.168.120:5601" - H | |
"Accept-Encoding: gzip, deflate" - H | |
"Accept-Language: en-US,en;q=0.8,cs;q=0.6,sk;q=0.4" - H | |
"kbn-version: 4.4.2" - H | |
"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36" - H | |
"Content-Type: application/json;charset=UTF-8" - H | |
"Accept: application/json, text/plain, */*" - H | |
"Referer: http://172.21.168.120:5601/app/kibana?" - H | |
"Connection: keep-alive" - -data - binary | |
"{""index"":""sla-db"",""search_type"":""count"",""ignore_unavailable"":true}" ^ | |
"" - -compressed | |
""" | |
import json | |
import requests | |
qq = """ | |
{ | |
"query": { | |
"filtered": { | |
"query": { | |
"query_string": { | |
"analyze_wildcard": "true", | |
"query": "linkname:/.*evoucher.*/ OR linkname:/.*sigos.*/ OR linkname:/.*mefs.*/" | |
} | |
}, | |
"filter": { | |
"bool": { | |
"must": [ | |
{ | |
"range": { | |
"timestamp": { | |
"gte": 1477301314986, | |
"lte": 1477387714986, | |
"format": "epoch_millis" | |
} | |
} | |
} | |
], | |
"must_not": [] | |
} | |
} | |
} | |
}, | |
"size": 0, | |
"aggs": { | |
"2": { | |
"terms": { | |
"field": "linkname.raw", | |
"size": 50, | |
"order": { | |
"1": "desc" | |
} | |
}, | |
"aggs": { | |
"1": { | |
"avg": { | |
"field": "pcktloss" | |
} | |
}, | |
"3": { | |
"date_histogram": { | |
"field": "timestamp", | |
"interval": "30m", | |
"time_zone": "Asia/Baghdad", | |
"min_doc_count": 1, | |
"extended_bounds": { | |
"min": 1477301314985, | |
"max": 1477387714985 | |
} | |
}, | |
"aggs": { | |
"1": { | |
"avg": { | |
"field": "pcktloss" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
""" | |
def search(uri,query): | |
"""Simple Elasticsearch Query""" | |
query = json.loads(qq) | |
response = requests.post(uri, json=query) | |
results = json.loads(response.text) | |
return results | |
if __name__ == '__main__': | |
aa = search("http://172.21.168.120:9200/sla-db/_search",query=qq) | |
print(aa) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment