# Part of the indices are created with this name "%{\[kubernetes\]\[namespace\]}"

**URL:** <https://discuss.elastic.co/t/part-of-the-indices-are-created-with-this-name-kubernetes-namespace/267426>\
**Category:** Logstash\
**Created:** [March 16, 2021, 10:02pm UTC](https://discuss.elastic.co/t/part-of-the-indices-are-created-with-this-name-kubernetes-namespace/267426 "2021-03-16T22:02:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![doronshai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/doronshai/32/85643_2.png) [@doronshai](https://discuss.elastic.co/u/doronshai)\
**Post date:** [March 16, 2021, 10:02pm UTC](https://discuss.elastic.co/t/part-of-the-indices-are-created-with-this-name-kubernetes-namespace/267426/1 "2021-03-16T22:02:33Z")

</div>

Hi Team,

I am using this configuration for logstash:

```
input
{
  beats {port => 6600
      type => "K4"
      codec => "json"
  }
}
filter
{
 if [type] == "K4"
     { json {source => "message"} }
}

output
{
 if [type] == "K4"
{ elasticsearch
      { hosts => ["very.nice.url:9200"]
        index => "%{[kubernetes][namespace]}-%{+YYYY.MM.dd}"
        cacert => "/etc/elasticsearch/root-ca.pem"
        user => "great_user_name"
        password => "great_password"
        ssl => true
        ssl_certificate_verification => false
}
}
}

```

and here is the filebeat configuration

```
filebeat.inputs:
- type: container
  paths:
    - /var/log/containers/*.log
  processors:
    - add_kubernetes_metadata:
        host: ${NODE_NAME}
        matchers:
        - logs_path:
            logs_path: "/var/log/containers/"
processors:
  - add_cloud_metadata:
  - add_host_metadata:
cloud.id: ${ELASTIC_CLOUD_ID}
cloud.auth: ${ELASTIC_CLOUD_AUTH}
output.logstash:
  hosts: ['logstash-prod.service.consul:6600']
# username: ${ELASTICSEARCH_USERNAME}
# password: ${ELASTICSEARCH_PASSWORD}

```

many indexes are created correctly, but also many indexes are created like these:

- %{[kubernetes][namespace]}-2021.03.14
- %{[kubernetes][namespace]}-2021.03.15
- %{[kubernetes][namespace]}-2021.03.16

any idea what is the reason here?

I wanted to comment this topic but it was closed

> [@Separate indexes for each kubernetes namespace](https://discuss.elastic.co/t/separate-indexes-for-each-kubernetes-namespace/169131):
>
> Hi Team Setup: ELK cluster is setup using docker-compose on one beefy bare metal server. On the kubernetes side I am running filebeat as a DaemonSet to ship container logs to logstash. Our K8S cluster will have around 50 namespaces and each namespace will have around 10 pods running. Question: I want to have a separate index created for each kubernetes namespace. Also whenever a new namespace is added, an index has to be auto-created as well. How do i achieve it ? Configurations below. F…

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [March 17, 2021, 12:23am UTC](https://discuss.elastic.co/t/part-of-the-indices-are-created-with-this-name-kubernetes-namespace/267426/2 "2021-03-17T00:23:39Z")

</div>

> [@doronshai](#):
>
> %{[kubernetes][namespace]}-2021.03.14

Look at the documents in that index. Do any of them have a field called [kubernetes][namespace]? If not, that is what causes them to be named that way.

The indentation of the second processors: option looks wrong to me, and yaml is notoriously picky about indentation. In fact the existence of a second processors: option looks wrong.

---

<div class="post-metadata">

**Author:** ![doronshai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/doronshai/32/85643_2.png) [@doronshai](https://discuss.elastic.co/u/doronshai)\
**Post date:** [March 17, 2021, 6:27am UTC](https://discuss.elastic.co/t/part-of-the-indices-are-created-with-this-name-kubernetes-namespace/267426/3 "2021-03-17T06:27:06Z")

</div>

> [@Badger](#):
>
> ok at the documents in that index. Do any of them have a field called [kubernetes][namespace]? If not, that is what causes them to be named that way.
> 
> The indentation of the second processors: o

look like removing the 2nd processors and make its content indented correctly solved it

Thanks!!!

---

<div class="post-metadata">

**Author:** ![doronshai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/doronshai/32/85643_2.png) [@doronshai](https://discuss.elastic.co/u/doronshai)\
**Post date:** [March 18, 2021, 4:52pm UTC](https://discuss.elastic.co/t/part-of-the-indices-are-created-with-this-name-kubernetes-namespace/267426/4 "2021-03-18T16:52:29Z")

</div>

I thought it solved the issue, but it didn't.

here is the updated filebeat.yaml

```
apiVersion: v1
data:
  filebeat.yml: |-
    filebeat.inputs:
    - type: container
      paths:
        - /var/log/containers/*.log
      processors:
        - add_kubernetes_metadata:
            host: ${NODE_NAME}
            matchers:
            - logs_path:
                logs_path: "/var/log/containers/"
        - add_cloud_metadata:
        - add_host_metadata:

    cloud.id: ${ELASTIC_CLOUD_ID}
    cloud.auth: ${ELASTIC_CLOUD_AUTH}
    output.logstash:
      hosts: ['10.16.14.31:6600','10.16.14.36:6600','10.16.14.43:6600','10.16.14.45:6600']

```

any idea what could it be?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 15, 2021, 4:52pm UTC](https://discuss.elastic.co/t/part-of-the-indices-are-created-with-this-name-kubernetes-namespace/267426/5 "2021-04-15T16:52:45Z")

</div>

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