{ "info": { "author": "Maciej Brencz", "author_email": "macbre@wikia-inc.com", "bugtrack_url": null, "classifiers": [], "description": "elasticsearch-query\n===================\n\n[![PyPI](https://img.shields.io/pypi/v/elasticsearch-query.svg)](https://pypi.python.org/pypi/elasticsearch-query)\n[![Build Status](https://travis-ci.org/macbre/elasticsearch-query.svg?branch=master)](https://travis-ci.org/macbre/elasticsearch-query)\n\nRun queries against Kibana's Elasticsearch that gets logs from Logstash. Forked from [Wikia's `kibana.py`](https://github.com/Wikia/python-commons/blob/master/wikia/common/kibana/kibana.py).\n\n```\npip install elasticsearch-query\n```\n\n## Basic Usage\n\n```python\nfrom elasticsearch_query import ElasticsearchQuery\nes_query = ElasticsearchQuery(es_host='es.prod', since=12345, period=900, index_prefix='logstash-my-app')\n```\n\n`es_host` needs to be specified with a host of Elasticsearch instance to connect.\n\nProvide either `since` (absolute timestamp) or `period` (last N seconds):\n\n* `since`: UNIX timestamp data should be fetched since (if None, then period specifies the last n seconds).\n* `period`: period (in seconds) before now() to be used when since is empty (defaults to last 15 minutes).\n\n`index_prefix` argument will be used to build indices names to query in.\nThey should follow the `index-name-YYYY.MM.DD` naming convention, e.g. `logstash-my-app-2014.08.19`.\n\n### `get_rows`\n\n> Returns data matching the given query (provided as a `dict`).\n\n```python\nes_query.get_rows(match={\"tags\": 'edge-cache-requestmessage'}, limit=2000)\n```\n\n* `match`: query to be run against log messages (ex. {\"@message\": \"Foo Bar DB queries\"}).\n* `limit`: the number of results (defaults to 10).\n\n### `query_by_string`\n\n> Returns data matching the given query string (provided as a [Lucene query](https://lucene.apache.org/core/2_9_4/queryparsersyntax.html)).\n\n```python\nes_query.query_by_string(query='@message:\"^PHP Fatal\"', limit=2000)\nes_query.query_by_string(query='@message:\"^PHP Fatal\"', fields=['@message', '@es_query_host'], limit=2000)\n```\n\n* `query`: query string to be run against log messages (ex. `@message:\"^PHP Fatal\"`).\n* `fields`: optional list of fields to fetch\n* `limit`: the number of results (defaults to 10).\n\n### `query_by_sql`\n\n> Returns data matching the given [SQL query](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-commands.html).\n\nThis feature [requires](https://www.elastic.co/blog/opening-x-pack-phase-1-complete) **non-OSS version** of Elasticsearch (\"To be clear, while the X-Pack source code is now available in the public repositories, it isn\u2019t under an Open Source license\").\n\n```python\nes_query.query_by_sql(sql='SELECT host FROM \"app-requests\" WHERE host = \\'app2.prod\\'')\n```\n\n* `sql`: [SQL query](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-commands.html) to be run\n\n### `count`\n\n> Returns number of matching entries\n\n```python\nes_query.count(query='@message:\"^PHP Fatal\"')\n```\n\n## Integration tests\n\n`elasticsearch-query` comes with integration tests suite. `.travis.yml` will install elasticsearch OSS version and run them.\n\nBut you can also run it locally. Simply pass `ES_TEST_HOST=` env variable when running tests (`make test`).", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/macbre/elasticsearch-query", "keywords": "logstash kibana elasticsearch logging", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "elasticsearch-query", "package_url": "https://pypi.org/project/elasticsearch-query/", "platform": "", "project_url": "https://pypi.org/project/elasticsearch-query/", "project_urls": { "Homepage": "https://github.com/macbre/elasticsearch-query" }, "release_url": "https://pypi.org/project/elasticsearch-query/2.4.0/", "requires_dist": null, "requires_python": "", "summary": "Run queries against Kibana's Elasticsearch that gets logs from Logstash.", "version": "2.4.0" }, "last_serial": 4573044, "releases": { "2.3.0": [ { "comment_text": "", "digests": { "md5": "a651dfe630678782317db84fc23faaac", "sha256": "d588e99740666562c178c5c7c81471827ca143950cfd08107f1f61766372542b" }, "downloads": -1, "filename": "elasticsearch-query-2.3.0.tar.gz", "has_sig": false, "md5_digest": "a651dfe630678782317db84fc23faaac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5538, "upload_time": "2018-12-04T21:46:14", "url": "https://files.pythonhosted.org/packages/a1/57/f3382a8002cfc1dd3f56a454f689b42054d9093890dd86c0b3ab6807209f/elasticsearch-query-2.3.0.tar.gz" } ], "2.4.0": [ { "comment_text": "", "digests": { "md5": "e276d00353f02042dfdd783d2b43660c", "sha256": "1b90afd45f5ad0427af87583f9d3ce1c699aa09043fc0f72d36e6d666a968821" }, "downloads": -1, "filename": "elasticsearch-query-2.4.0.tar.gz", "has_sig": false, "md5_digest": "e276d00353f02042dfdd783d2b43660c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6388, "upload_time": "2018-12-07T19:16:33", "url": "https://files.pythonhosted.org/packages/dc/4a/86ce2ef588b3815c751f721b859462edd95e44e9e2ed64e431049f7468fc/elasticsearch-query-2.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e276d00353f02042dfdd783d2b43660c", "sha256": "1b90afd45f5ad0427af87583f9d3ce1c699aa09043fc0f72d36e6d666a968821" }, "downloads": -1, "filename": "elasticsearch-query-2.4.0.tar.gz", "has_sig": false, "md5_digest": "e276d00353f02042dfdd783d2b43660c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6388, "upload_time": "2018-12-07T19:16:33", "url": "https://files.pythonhosted.org/packages/dc/4a/86ce2ef588b3815c751f721b859462edd95e44e9e2ed64e431049f7468fc/elasticsearch-query-2.4.0.tar.gz" } ] }