WatcherのIndex Actionで、Index名を可変にする方法がないか


例: 6月1日にWatcherが実行され、watcher_201905というIndexが作成される

"trigger": {
"schedule": {
"monthly": {"on":1,"at":"midnight"} //毎月月初に実行
"input": {
"condition": {
"actions": {
"index_payload": {
"index": {
"index": "watcher", //Indexの末尾に、”YYYYMM”という形で、実行日の前月の年月を付記したい
"doc_type": "doc"



You can use date math in index names, and just always go one month back with, see this example from the above link



1 Like


Thank you for your replay.
Sorry that my description was not enough. The above code I posted is not for config file (like logstash.conf) or the part of API but the script for the watcher. So in my understand, it cannot contain such characters.
In case, I executed and I got following message.

message": "[watch_{now/M-1M{yyyy.MM}}] InvalidIndexNameException[Invalid index name [watch_{now/M-1M{yyyy.MM}}], must not contain the following characters [ , ", *, \, <, |, ,, >, /, ?]]",

Best regards.

this is supposed to be the index name so it can go straight into your watch. Judging from the error message the <> brackets are missing. Can you share the whole watch again including your changes, so one can try to reproduce locally? Thanks!

1 Like

Finally worked! As you told me, the problem was just lacking of <>.
Thank you for your swift and helpful advice.

My latest code is like below.

"actions" : {
   "index_payload" : {
       "transform" : { ... },
       "index" : {
            "index" : "<logstash-{now/M-1M{yyyy.MM}}>",
            "doc_type" : "doc"
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.