Last active
December 18, 2017 13:35
-
-
Save markuskont/76c15a4ef0a7c5810b6e06975264dbff to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python3 | |
from elasticsearch import Elasticsearch, helpers | |
import json | |
es = Elasticsearch( | |
hosts=[ | |
'host:9200' | |
] | |
) | |
# Initialize the scroll | |
res = helpers.scan(client = es, scroll = '1m', index = "logs-*") | |
with open("/home/user/data/logs.txt", "a") as f: | |
for i in res: | |
line = json.dumps(i["_source"]) + "\n" | |
f.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment