Elasticsearch

[Python] Elasticsearch Monitoring

Pydole 2018. 7. 22. 22:56

파이썬을 이용하여 Elasticsearch에 index 생성하고, 삭제하는 방법으로 모니터링

 

try:
    es = Elasticsearch(hosts=' ', port=' ')
    doc = '''
    {
    "mappings": {
        "testindex": {
        "properties": {
            "msg": {
            "type": "keyword"
            }
           }
          }
         }
       }'''

    res = es.indices.create(index='testindex', body=doc)
    print('index create : %s' %res['acknowledged'])

    res = es.indices.delete(index='testindex')
    print('index delete : %s' %res['acknowledged'])

except Exception as e:
    print(e)

------------------------------------------------------------------
index create : True
index delete : True