ELK 程式設計

curl

複習

curl http://localhost:9200

{
  "name" : "j-QtbbE",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "OCqS3wLWRfGL2spqUHQkrg",
  "version" : {
    "number" : "6.7.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "8453f77",
    "build_date" : "2019-03-21T15:32:29.844721Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

 

python

安裝

pip install elasticsearch

// or 

pip3 install elasticsearch

$ python3
Python 3.7.3 (default, Mar 27 2019, 09:23:15)
[Clang 10.0.1 (clang-1001.0.46.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from elasticsearch import Elasticsearch
>>>

試驗

$ python
Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 16:24:02)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> # make sure ES is up and running
... import requests
res = requests.get('http://localhost:9200')
print(res.content)
>>> res = requests.get('http://localhost:9200')
>>> print(res.content)
{
  "name" : "j-QtbbE",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "OCqS3wLWRfGL2spqUHQkrg",
  "version" : {
    "number" : "6.7.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "8453f77",
    "build_date" : "2019-03-21T15:32:29.844721Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

>>>

 

資料範例

Dev Tools

(kibana plugin 之一)

TimeLion

Made with Slides.com