App-ElasticSearch-Utilities

 view release on metacpan or  search on metacpan

README.mkdn  view on Meta::CPAN


    1_000     -> "1.00 thousand",
    1_000_000 -> "1.00 million",

## es\_human\_size

Takes a number and returns the number as a string in bytes, Kb, Mb, Gb, or Tb using base 1024.

    1024        -> '1.00 Kb',
    1048576     -> '1.00 Mb',
    1073741824  -> '1.00 Gb',

## def('key')

Exposes Definitions grabbed by options parsing

## es\_local\_index\_meta(key => 'base' || 'index')

Fetch meta-data from the local config file, i.e. `~/.es-utils.yaml`.

Format is:

    ---
    meta:
      index_name:
        key: value
      index_basename:
        key: value

The most specific version is searched first, followed by the index stripped of
it's date, and then on through all the bases discovered with
`es_index_bases()`.

This is used by the `es-search.pl` utility to do lookups of the **timestamp**
field it needs to sort documents, i.e.:

    ---
    meta:
      logstash:
        timestamp: '@timestamp'
        host: es-cluster-01.int.example.com
      bro:
        timestamp: 'timestamp'

# ARGS

From App::ElasticSearch::Utilities:

    --local         Use localhost as the elasticsearch host
    --host          ElasticSearch host to connect to
    --port          HTTP port for your cluster
    --proto         Defaults to 'http', can also be 'https'
    --http-username HTTP Basic Auth username
    --password-exec Script to run to get the users password
    --insecure      Don't verify TLS certificates
    --cacert        Specify the TLS CA file
    --capath        Specify the directory with TLS CAs
    --cert          Specify the path to the client certificate
    --key           Specify the path to the client private key file
    --noop          Any operations other than GET are disabled, can be negated with --no-noop
    --timeout       Timeout to ElasticSearch, default 10
    --keep-proxy    Do not remove any proxy settings from %ENV
    --index         Index to run commands against
    --base          For daily indexes, reference only those starting with "logstash"
                     (same as --pattern logstash-* or logstash-DATE)
    --pattern       Use a pattern to operate on the indexes
    --days          If using a pattern or base, how many days back to go, default: 1

See also the "CONNECTION ARGUMENTS" and "INDEX SELECTION ARGUMENTS" sections from App::ElasticSearch::Utilities.

# ARGUMENT GLOBALS

Some options may be specified in the **/etc/es-utils.yaml**, **$HOME/.es-utils.yaml**
or **$HOME/.config/es-utils/config.yaml** file:

    ---
    base: logstash
    days: 7
    host: esproxy.example.com
    port: 80
    timeout: 10
    proto: https
    http-username: bob
    password-exec: /home/bob/bin/get-es-passwd.sh

# CONNECTION ARGUMENTS

Arguments for establishing a connection with the cluster.  Unless specified otherwise, these options
can all be set in the globals file.

- **local**

    Assume ElasticSearch is running locally, connect to localhost.

- **host**

    Use a different hostname or IP address to connect.

- **port**

    Defaults to 9200.

- **proto**

    Defaults to 'http', can also be 'https'.

- **http-username**

    If HTTP Basic Authentication is required, use this username.

    See also the ["HTTP Basic Authentication"](#http-basic-authentication) section for more details

- **password-exec**

    If HTTP Basic Authentication is required, run this command, passing the arguments:

        <command_to_run> <es_host> <es_username>

    The script expects the last line to contain the password in plaintext.

- **noop**

    Prevents any communication to the cluster from making changes to the settings or data contained therein.
    In short, it prevents anything but HEAD and GET requests, **except** POST requests to the \_search endpoint.

- **timeout**

    Timeout for connections and requests, defaults to 10.

- **keep-proxy**

    By default, HTTP proxy environment variables are stripped. Use this option to keep your proxy environment variables
    in tact.

- **insecure**

    Don't verify TLS certificates

- **cacert**

    Specify a file with the TLS CA certificates.

- **capath**

    Specify a directory containing the TLS CA certificates.

- **cert**

    Specify the path to the TLS client certificate file..

- **key**

    Specify the path to the TLS client private key file.

# INDEX SELECTION ARGUMENTS

- **base**

    In an environment using monthly, weekly, daily, or hourly indexes.  The base index name is everything without the date.
    Parsing for bases, also provides splitting and matching on segments of the index name delineated by the '-' character.
    If we have the following indexes:

        web-dc1-YYYY.MM.DD
        web-dc2-YYYY.MM.DD
        logstash-dc1-YYYY.MM.DD
        logstash-dc2-YYYY.MM.DD

    Valid bases would be:

        web
        web-dc1
        web-dc2
        logstash
        logstash-dc1
        logstash-dc2
        dc1
        dc2

    Combining that with the days option can provide a way to select many indexes at once.

- **days**

    How many days backwards you want your operation to be relevant.

- **datesep**

    Default is '.' Can be set to an empty string for no separator.

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.510 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )