<p>We're running Elastic + Fluentbit + Kibana stack on kubernetes for container logs and it was working correctly with daily rollover based on date(new-YYYY-MM-DD) but on high volume it caused over shard size issue so created ILM policy mentioned below so that it can rollover quickly. Bootstrapped index is writable but still the old index of (new-YYYY-MM-DD) is getting written instead of the new index new-YYYY-MM-DD-000001. I have mentioned the things tried but no luck yet.</p>
<pre><code>Created new policy with following condition:

PUT /_ilm/policy/new_policy
{
  &quot;policy&quot;: {
    &quot;phases&quot;: {
      &quot;hot&quot;: {
        &quot;actions&quot;: {
          &quot;rollover&quot;: {
            &quot;max_age&quot; : &quot;10m&quot; #just to test faster, actually want to set it to an hour.
          }
        }
      },
      &quot;delete&quot;: {
        &quot;min_age&quot;: &quot;20d&quot;,
        &quot;actions&quot;: {
          &quot;delete&quot;: {}
        }
      }
    }
  }
}

Created template:

PUT _template/new_template
{
  &quot;index_patterns&quot;: [&quot;new*&quot;], 
  &quot;settings&quot;: {
    &quot;number_of_shards&quot;: 1,
    &quot;number_of_replicas&quot;: 1,
    &quot;index.lifecycle.name&quot;: &quot;new_policy&quot;,
    &quot;index.lifecycle.rollover_alias&quot;: &quot;new-alias&quot; 
  }
}

Bootstrapped new index which is creating and rolling over correctly.

PUT /%3Cnew-%7Bnow%2Fd%7D-000001%3E
{
  &quot;aliases&quot;: {
    &quot;new-alias&quot;:{
      &quot;is_write_index&quot;: true 
    }
  }
}

Output plugin section inside fluentbit-configmap

[OUTPUT]
    Name            es
    Match           *
    Host            ${FLUENT_ELASTICSEARCH_HOST}
    Port            ${FLUENT_ELASTICSEARCH_PORT}
    HTTP_User       ${FLUENT_ELASTICSEARCH_USER}
    HTTP_Passwd     ${FLUENT_ELASTICSEARCH_PASSWORD}
    Logstash_Format On
    Logstash_Prefix new
    Trace_Error     On
    Replace_Dots    On
    Retry_Limit     False
    tls             On
    tls.verify      Off

Tried indexing but no luck.

POST _reindex
{
  &quot;source&quot;: {
    &quot;index&quot;: &quot;new-2021.09.30&quot; 
  },
  &quot;dest&quot;: {
    &quot;index&quot;: &quot;new-2021.09.30-000001&quot;, 
    &quot;op_type&quot;: &quot;create&quot; 
  }
}
</code></pre>
<p>Also, tried creating entire new index-pattern but it seems coming from any system defaults and not making my ILM index as default for new logs.</p>
<pre><code>alias           index                       filter routing.index routing.search is_write_index
new-alias new-2021.09.30-000001 -      -             -              false
new-alias new-2021.09.30-000002 -      -             -              false
new-alias new-2021.09.30-000003 -      -             -              false
new-alias new-2021.09.30-000004 -      -             -              false
new-alias new-2021.09.30-000005 -      -             -              false
new-alias new-2021.09.30-000006 -      -             -              false
new-alias new-2021.09.30-000007 -      -             -              false
new-alias new-2021.09.30-000008 -      -             -              false
new-alias new-2021.09.30-000009 -      -             -              false
new-alias new-2021.09.30-000010 -      -             -              false
new-alias new-2021.09.30-000011 -      -             -              false
new-alias new-2021.09.30-000012 -      -             -              false
new-alias new-2021.09.30-000013 -      -             -              true
</code></pre>

Mitesh Gangaramani
<p>In your Fluentbit configuration you need to change the following:</p>
<pre><code>Logstash_Format Off
Index new-alias
</code></pre>
<p>And remove <code>Logstash_Prefix new</code></p>
<p>That's it. Since ILM will take care of naming the indexes and rolling them over, you simply need to write to <code>new-alias</code> and ILM takes care of the rest. No need for Fluentbit to make up the index name anymore.</p>
