App-ElasticSearch-Utilities
view release on metacpan or search on metacpan
scripts/es-alias-manager.pl view on Meta::CPAN
This will allow you to split your cluster between datacenters (or whatever) and alias the split clusters
to a homogenous index that standard LogStash/Kibana interfaces will understand.
If I create the following in /etc/elasticsearch/aliases.yml
---
pickle: ~
logstash:
pattern: \*-logstash-{{DATE}}
daily: logstash-{{DATE}}
relative:
alias: logstash-{{PERIOD}}
periods:
today:
from:
days: 0
to:
days: 0
lastweek:
from:
days: 14
to:
days: 7
The C<pickle> alias is flagged as an alias to ignore in the addition/removal
process. This script will automatically ignore any alias that begins with a '.'.
Assuming today is the 2013.07.18 and I have 3 datacenters (IAD, NYC, AMS) with the following indices:
iad-logstash-2013.07.17
iad-logstash-2013.07.18
nyc-logstash-2013.07.17
nyc-logstash-2013.07.18
ams-logstash-2013.07.17
ams-logstash-2013.07.18
The following aliases would be created
logstash-2013.07.17
|- iad-logstash-2013.07.17
|- nyc-logstash-2013.07.17
`- ams-logstash-2013.07.17
logstash-2013.07.18
|- iad-logstash-2013.07.18
|- nyc-logstash-2013.07.18
`- ams-logstash-2013.07.18
logstash-today
|- iad-logstash-2013.07.18
|- nyc-logstash-2013.07.18
`- ams-logstash-2013.07.18
This lets you use index templates and the index.routing.allocation to isolate data by datacenter or another
parameter to certain nodes while allowing all the nodes to work together as cleanly as possible. This also facilitates
the default expectations of Kibana to have a single index per day when you may need more.
=head2 PATTERN VARIABLES
Patterns are used to match an index to the aliases it should have. A few symbols are expanded into
regular expressions. Those patterns are:
The '*' expands to match any number of any characters.
The '?' expands to match any single character.
{{DATE}} expands to match YYYY.MM.DD, YYYY-MM-DD, or YYYYMMDD
=head2 ALIAS VARIABLES
For daily indices, the following variables are available:
{{DATE}} - Expands to YYYY.MM.DD for the current day of the current index
For relative period indices, the following variable is B<required>.
{{PERIOD}} - Name of the period
=head1 OPTIONS
=over 8
=item B<config>
Location of the config file, default is /etc/elasticsearch/aliases.yml
=item B<skip>
Optionally skip a phase of alias management, valid phases are: add, remove
=back
=head1 AUTHOR
Brad Lhotsky <brad@divisionbyzero.net>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2026 by Brad Lhotsky.
This is free software, licensed under:
The (three-clause) BSD License
=cut
( run in 0.617 second using v1.01-cache-2.11-cpan-5623c5533a1 )