App-ElasticSearch-Utilities
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
- **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.
- **pattern**
A pattern to match the indexes. Can expand the following key words and characters:
'*' expanded to '.*'
'ANY' expanded to '.*'
'DATE' expanded to a pattern to match a date,
The indexes are compared against this pattern.
# HTTP Basic Authentication
HTTP Basic Authorization is only supported when the `proto` is set to **https**
as not to leak credentials all over.
The username is selected by going through these mechanisms until one is found:
--http-username
'http-username' in /etc/es-utils.yml or ~/.es-utils.yml
Netrc element matching the hostname of the request
CLI::Helpers prompt()
Once the username has been resolved, the following mechanisms are tried in order:
Netrc element matching the hostname of the request
Password executable defined by --password-exec
'password-exec' in /etc/es-utils.yml, ~/.es-utils.yml
CLI::Helpers prompt()
## Password Exec
It is **BAD** practice to specify passwords as a command line argument, or store it in a plaintext
file. There are cases where this may be necessary, but it is not recommended. The best method for securing your
password is to use the **password-exec** option.
This option must point to an executable script. That script will be passed two arguments, the hostname and the username
for the request. It expects the password printed to STDOUT as the last line of output. Here's an example password-exec setup
using Apple Keychain:
#!/bin/sh
HOSTNAME=$1;
USERNAME=$2;
/usr/bin/security find-generic-password -w -a "$USERNAME" -s "$HOSTNAME"
If we save this to "$HOME/bin/get-passwd.sh" we can execute a script
like this:
$ es-search.pl --http-username bob --password-exec $HOME/bin/get-passwd.sh \
--base secure-data --fields
Though it's probably best to set this in your ~/.es-utils.yml file:
---
host: secured-cluster.example.org
port: 443
proto: https
http-username: bob
password-exec: /home/bob/bin/get-passwd.sh
### CLI::Helpers and Password Prompting
If all the fails to yield a password, the last resort is to use CLI::Helpers::prompt() to ask the user for their
password. If the user is using version 1.1 or higher of CLI::Helpers, this call will turn off echo and readline magic
for the password prompt.
# INSTALL
**This library attempts to provide scripts compatible with version 0.19 through 1.1 of ElasticSearch**.
Recommended install with [CPAN Minus](http://cpanmin.us):
cpanm App::ElasticSearch::Utilities
( run in 1.307 second using v1.01-cache-2.11-cpan-39bf76dae61 )