Created
December 28, 2019 05:26
-
-
Save imlonghao/95ce3991118933818b087220918db9b6 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 python | |
import json | |
from elasticsearch import Elasticsearch | |
from elasticsearch.helpers import bulk | |
def g(): | |
with open('a.log') as f: | |
for i in f: | |
data = json.loads(i) | |
yield { | |
"_index": "fdns_a_20191129", | |
"type": data['type'], | |
"name": data['name'], | |
"value": data['value'], | |
} | |
es = Elasticsearch(hosts=["127.0.0.1:9200"], timeout=5000) | |
bulk(es, g()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment