# Logstash configuration to globally mutate sub index patterns

**URL:** <https://discuss.elastic.co/t/logstash-configuration-to-globally-mutate-sub-index-patterns/275468>\
**Category:** Logstash\
**Created:** [June 9, 2021, 3:40pm UTC](https://discuss.elastic.co/t/logstash-configuration-to-globally-mutate-sub-index-patterns/275468 "2021-06-09T15:40:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![es-gabriele](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@es-gabriele](https://discuss.elastic.co/u/es-gabriele)\
**Post date:** [June 9, 2021, 3:40pm UTC](https://discuss.elastic.co/t/logstash-configuration-to-globally-mutate-sub-index-patterns/275468/1 "2021-06-09T15:40:50Z")

</div>

Hello,  
I have an ELK stack, with some configured index patterns. As part of internal requirements, I need to edit a json object (which is part of that index pattern), globally to "string".  
As of now, such json object is randomly populated by numerous sub-fields, like "date", "temps", and many more others.  
All of these are automatically managed by ELK, but I need all of them to be processed and converted (casted) as "strings".

So the basic configuration is as follows:

```auto
type A: "long"
type B: "int"
type C: "string"
type D: "json object"

```

where type D is a nested json object which includes (as sub fields) numerous other index patterns and fields, like (for example) "typeD.date", "typeD.temps", "typeD.extrastuff", and so on.

I need all of the "`typeD*`" objects to be casted and converted as strings. So far, I tried to use a .conf with logstash, but it did not work. I will paste my configuration after (numerous) attempts. I tried all these configuration in my own local docker environment.

The log which I tested logstash from was called log\_file.json and it contains numerous sample lines, including also the index patterns I want to edit globally with this mutate operation.

```auto
input {
    file{
      type => "json"
      path => "/home/container/logstash/log_file.json"
      start_position => "beginning"
      sincedb_path => "/dev/null"
      codec => json
  }
}

filter {
   if [message] =~ /\A\{.+\}\z/ {
     json {
       source => "message"
    }

  json {
    source => "[message][typeD]"
}

  mutate {
    convert => ["typeD.*","string"]
}
  }
}

output {
  elasticsearch {
    hosts => "http://localhost:9200"
    index => "logstash-test-%{+yyyy.MM.dd}"
 }
  stdout{}
}

```

Also, after logging in via Kibana, I can see that the (conf) file has been correctly created and loaded by logstash, but still it fails to convert the index patterns as strings.

I would need to know which edits are necessary for the configuration to work. Does the logstash config file need some edit? Is there anything wrong in the setup?

Thanks

---

<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:** [July 7, 2021, 3:40pm UTC](https://discuss.elastic.co/t/logstash-configuration-to-globally-mutate-sub-index-patterns/275468/2 "2021-07-07T15:40:55Z")

</div>

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