Skip to main content

CLI interface to query Elasticsearch backend via the Kibana frontend.

Project description

Elasticsearch Kibana CLI

PyPi Build Status

The Elasticsearch Kibana CLI provides a configurable shell interface to query the Elasticsearch backend via the Kibana frontend which is useful in situations where the Elasticsearch backend is not otherwise accessible. Configuration options are available that permit HTTP request header overrides that hence enable access to Kibana in more complex situations that may require additional authentication such as when Kibana is behind an OAuth reverse proxy.

Project

Install

via PyPi

pip3 install elasticsearch-kibana-cli

via Source

git clone https://github.com/ndejong/elasticsearch_kibana_cli
cd elasticsearch_kibana_cli
python3 -m venv venv
./venv/bin/activate
pip3 install -r requirements.txt

Configuration

The provided eskbcli-sample.yml demonstrates the configuration options available to create search_definitions. Under the hood, query strings are generated using the Q function from the standard elasticsearch-dsl Python library from Elastic. The search configuration parameter is loaded into the Q function wrapped within a bool and honours the must, must_not, should, should_not and filter attributes.

By example therefore, where a Python elasticsearch-dsl expression is written as such

s.query = Q('bool', must=[Q('match', title='python'), Q('match', body='best')])

then the YML configuration equivalent is therefore

  search:
    must:
      match:
        - title: "python"
        - body: "best"

This enables the user to define most forms of Elastic Search query in an Elastic standard way.

Environment Variables

Standard Environment Variables

The following environment variables are available

  • ELASTICSEARCHKIBANACLI_CONFIG_FILENAME alternative method to set or override the configuration file to be loaded. Has same effect as setting the -c argument.

  • ELASTICSEARCHKIBANACLI_LOGLEVEL adjust the level of logging output to stderr. Valid settings are CRITICAL, ERROR, WARNING, INFO, DEBUG

Configuration Import Environment Variables

Loading environment variables into the configuration is possible using the env name with an env: prefix, for example

    header_overrides:
      cookie: env:GCP_IAP_COOKIE

In this case the HTTP header override configuration value gets loaded from the GCP_IAP_COOKIE env value.

Usage

usage: eskbcli [-s <search>] [-o <filename>] [-sc <split-count>]
               [-hc <hit-count>] [-np] [-D] [-k <kbn_version>] [-c <filename>]
               [-d]

Elasticsearch Kibana CLI v0.1.0

optional arguments:
  -s <search>        The search_definition name from configuration to use and
                     execute (hint: use -D to list).
  -o <filename>      Filename to write output to, by default output it written
                     to stdout.
  -sc <split-count>  Number of splits to break the search into, overrides the
                     config value if set (default:1).
  -hc <hit-count>    Search hit count limit, overrides the config value if set
                     min=1, max=10000 (default:10000).
  -np, --noping      Do not ping the Kibana endpoint before using this
                     connection (default: False).
  -D, --defn         List the configured search_definitions sections in the
                     config and immediately exit.
  -k <kbn_version>   Kibana version override, useful in some debugging
                     situations.
  -c <filename>      Override the configuration file to read, else search for
                     eskbcli.yml in common paths.
  -d, --debug        Debug level logging output (default: False).

The Elasticsearch Kibana CLI provides a configurable shell interface to
query the Elasticsearch backend via the Kibana frontend which is useful in
situations where the Elasticsearch backend is not otherwise accessible.
Configuration options are available that permit HTTP request header overrides
that hence enable access to Kibana in more complex situations that may require
additional authentication such as when Kibana is behind an OAuth reverse
proxy.

Example

$ eskbcli -d -sc 10 -s example01 -o /tmp/example01.json
20190922Z024453 - INFO - elasticsearch_kibana_cli
20190922Z024453 - INFO - version 0.1.0
20190922Z024453 - INFO - Loaded configuration filename /etc/eskbcli/eskbcli.yml
20190922Z024453 - DEBUG - Using internal_proxy to connect https://kibana.internal
20190922Z024454 - DEBUG - kbn_metadata read from cache file /tmp/elasticsearch_kibana_cli-connection-6140f131-metadata.cache
20190922Z024454 - DEBUG - Connection definition setup http://127.0.0.1:59200
20190922Z024500 - INFO - Ping okay http://127.0.0.1:59200
20190922Z024501 - INFO - Search split into 10 requests based on "range" keyword
20190922Z024502 - INFO - 2905 available-hits; 2905 returned-hits; 290 average-hits-per-split; 10 msearch-splits

Authors

Nicholas de Jong

License

BSD-2-Clause - see LICENSE file for full details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elasticsearch-kibana-cli-0.1.5.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

elasticsearch_kibana_cli-0.1.5-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file elasticsearch-kibana-cli-0.1.5.tar.gz.

File metadata

  • Download URL: elasticsearch-kibana-cli-0.1.5.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for elasticsearch-kibana-cli-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a7824f7db82c316ba12f175fc2d704474b962e002cf2b80fb044decedebeb131
MD5 e11b3de701915795a1b1c0c7ebe2ead4
BLAKE2b-256 bd7c880c492652f018d4fafb46ab6561a02f1c23fac38cb5aadb089b365b10b7

See more details on using hashes here.

File details

Details for the file elasticsearch_kibana_cli-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: elasticsearch_kibana_cli-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for elasticsearch_kibana_cli-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 50d416c9f1345c1d9c3314407dfaee65065df0467b902b4fd99fbbed1db0465f
MD5 85cce8a18a9dfbee7992ebeb70c003a6
BLAKE2b-256 ba73852efc327cfe228a3860f2dc71b93f750bb7895f72d06793ae2fb0c0ec34

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page