Run queries against Kibana's Elasticsearch that gets logs from Logstash.
Project description
elasticsearch-query
Run queries against Kibana's Elasticsearch that gets logs from Logstash. Forked from Wikia's kibana.py
.
pip install elasticsearch-query
Basic Usage
from elasticsearch_query import ElasticsearchQuery
es_query = ElasticsearchQuery(es_host='es.prod', since=12345, period=900)
es_host
needs to be specified with a host of Elasticsearch instance to connect.
Provide either since
(absolute timestamp) or period
(last N seconds):
since
: UNIX timestamp data should be fetched since (if None, then period specifies the last n seconds).period
: period (in seconds) before now() to be used when since is empty (defaults to last 15 minutes).
get_rows
Returns data matching the given query (provided as a
dict
).
es_query.get_rows(match={"tags": 'edge-cache-requestmessage'}, limit=2000)
match
: query to be run against log messages (ex. {"@message": "Foo Bar DB queries"}).limit
: the number of results (defaults to 10).
query_by_string
Returns data matching the given query string (provided as a Lucene query).
es_query.query_by_string(query='@message:"^PHP Fatal"', limit=2000)
es_query.query_by_string(query='@message:"^PHP Fatal"', fields=['@message', '@es_query_host'], limit=2000)
query
: query string to be run against log messages (ex.@message:"^PHP Fatal"
).fields
: optional list of fields to fetchlimit
: the number of results (defaults to 10).
get_to_timestamp
Returns the upper time boundary for the requested data.
es_query.get_to_timestamp()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for elasticsearch-query-2.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d588e99740666562c178c5c7c81471827ca143950cfd08107f1f61766372542b |
|
MD5 | a651dfe630678782317db84fc23faaac |
|
BLAKE2b-256 | a157f3382a8002cfc1dd3f56a454f689b42054d9093890dd86c0b3ab6807209f |