feat: date-based Elasticsearch index names via strftime (#27) - #54
Merged
Conversation
`mysql_replicator_elasticsearch` resolves the index name from the tag. Now,
if that index-name segment contains strftime tokens (e.g. %Y%m%d), they are
expanded using the record's event time, enabling Logstash-style dated
indices like `myindex-20180831`.
Users opt in simply by putting the tokens in the index-name part of the
input plugin's `tag` (e.g. `tag myindex-%Y%m%d.mytype.${event}.${primary_key}`).
Index names containing no `%` are returned unchanged, so existing configs are
unaffected.
Add a unit test for the expansion (and an explicit pass-through test) and
document the feature, including the delete-vs-rotation caveat, in the README.
Closes #27
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 16, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #27: support Logstash-style date-based index names (e.g.
myindex-20180831).How it works
mysql_replicator_elasticsearchresolves the target index from the tag'sindex_namesegment. This PR expandsstrftimetokens in that segment usingthe record's event time:
Users opt in by putting the tokens in the index-name part of the input plugin's
tag:Index names without a
%are returned unchanged, so existing configurationsare unaffected (fully backward compatible).
Notes
indices suit insert-only data, since a delete targets the index for the
delete's own time).
Tests
test_expands_strftime_tokens_in_index_name— a%Y%m%dtag produces a dated index.test_index_name_without_token_is_unchanged— pass-through for plain names.Verified locally on Ruby 3.4 (
18 tests, 0 failures).Closes #27
🤖 Generated with Claude Code