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 exists behind an OAuth reverse proxy or other zero-trust-network environment.

Project

Install

via PyPi

pip3 install elasticsearch-kibana-cli

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.2.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

elasticsearch_kibana_cli-0.2.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file elasticsearch_kibana_cli-0.2.1.tar.gz.

File metadata

  • Download URL: elasticsearch_kibana_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for elasticsearch_kibana_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7e01aa544c84f1ce81af97b83692f046bcfbd6c5d6d1f516038875b0cfea92d1
MD5 209839181c56388dfc775e229f756db8
BLAKE2b-256 01fcca88b9af9eef461ab3b7f631c85a6e62b5e228bd82c489fca6b9f67ffed0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: elasticsearch_kibana_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for elasticsearch_kibana_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69225fe8793fcbc1703d69c9fd953058fd76250bd1e6525b14734c8bc4e34c01
MD5 0ada0e4b7ea02813fa0be1987efcae59
BLAKE2b-256 0f77574a1002a544a385ae225148e4847234b1db8fa5b1a1d849ed5ffc025c63

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