Last active
November 27, 2018 18:01
-
-
Save shunkino/d8b75b7e3102a398b329e4cf3ed38a8f to your computer and use it in GitHub Desktop.
query to moloch example for my blog
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
from elasticsearch import Elasticsearch | |
es = Elasticsearch(['elasticsearch:9200']) | |
response = es.search( | |
index="sessions2-181016", | |
body={ | |
"size": 0, | |
"query": { | |
"bool": { | |
"filter": { | |
"bool": { | |
"must": { | |
"term": { | |
"tags": "sample" | |
} | |
}, | |
"should": [ | |
{ | |
"term": { | |
"dstPort": "80" | |
} | |
}, | |
{ | |
"term": { | |
"dstPort": "443" | |
} | |
} | |
] | |
} | |
} | |
} | |
}, | |
"aggs": { | |
"agg_terms_dstIp": { | |
"terms": { | |
"field": "dstIp", | |
"size": 100 | |
} | |
} | |
} | |
} | |
, request_timeout=100) | |
type(response) | |
response["aggregations"]["agg_terms_dstIp"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment