# File output with data from field

**URL:** https://discuss.elastic.co/t/file-output-with-data-from-field/241895
**Category:** Logstash
**Created:** [July 20, 2020, 1:20pm UTC](https://discuss.elastic.co/t/file-output-with-data-from-field/241895 "2020-07-20T13:20:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![elk2](https://avatars.discourse-cdn.com/v4/letter/e/f14d63/32.png) [@elk2](https://discuss.elastic.co/u/elk2)
#### Post date: [July 20, 2020, 1:20pm UTC](https://discuss.elastic.co/t/file-output-with-data-from-field/241895/1 "2020-07-20T13:20:53Z")

</div>

I collect different logs from various sources.  
I replaced logstash timestamp with machine logs timestamp to have time based events into elasticsearch and I added a "processed\_at" field with a part of logstash timestamp.

This is my conf:

```
input {
       beats {
            port => 5044
       }
}
filter{
 mutate {
              add_field => { "processed_at" => "%{+YYYY-MM-dd_HH-mm}" }
              remove_field => ["beat","tags"]
      }
     date{
          match => ["sys_created_on", "dd/MM/yyyy HH:mm:ss"]
     }
}

output{
       file {
             path => "/var/log/%{processed_at}-test.log"
       }
elasticsearch {
                      index => "test-%{+YYYY.MM.dd}"
                      hosts => [localhost:9200]
                      }
}

```

Now I want to create elasticsearch indexes daily but with "processed\_at" date field and not with replaced timestamp.  
Can I use part of "processed\_at" field without hours and minute or I need to create another field.

---

<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: [July 20, 2020, 5:11pm UTC](https://discuss.elastic.co/t/file-output-with-data-from-field/241895/2 "2020-07-20T17:11:55Z")

</div>

> [@elk2](#):
>
> `index => "test-%{+YYYY.MM.dd}"`

That will always reference @timestamp. If you want to build an index name using a different field you could do it in a ruby filter using strftime.

---

<div class="post-metadata">

### Author: ![elk2](https://avatars.discourse-cdn.com/v4/letter/e/f14d63/32.png) [@elk2](https://discuss.elastic.co/u/elk2)
#### Post date: [July 21, 2020, 7:47am UTC](https://discuss.elastic.co/t/file-output-with-data-from-field/241895/3 "2020-07-21T07:47:47Z")

</div>

Thanks.

I thinked another field like this:

```
mutate {
              add_field => { "processed_time" => "%{+YYYY-MM-dd_HH-mm}" }
              add_field => { "processed_data" => "%{+YYYY-MM-dd}" }
      }
```

---

<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: [August 19, 2020, 9:05am UTC](https://discuss.elastic.co/t/file-output-with-data-from-field/241895/5 "2020-08-19T09:05:37Z")

</div>

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