# How to test if fieldNames contains specific caracter?

**URL:** <https://discuss.elastic.co/t/how-to-test-if-fieldnames-contains-specific-caracter/167645>\
**Category:** Logstash\
**Created:** [February 8, 2019, 2:18pm UTC](https://discuss.elastic.co/t/how-to-test-if-fieldnames-contains-specific-caracter/167645 "2019-02-08T14:18:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isilve28](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@Isilve28](https://discuss.elastic.co/u/Isilve28)\
**Post date:** [February 8, 2019, 2:18pm UTC](https://discuss.elastic.co/t/how-to-test-if-fieldnames-contains-specific-caracter/167645/1 "2019-02-08T14:18:28Z")

</div>

Hello everyone,

I want to use date filter for every fieldName ending with "Date" (and keeping the value in the same fieldName) because I'm using a kv filter at first and I don't know all the time if a field is numeric or temporal.

is there a syntax to test filedNames in Logstash ?

Thanks in advance !

---

<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:** [February 8, 2019, 3:22pm UTC](https://discuss.elastic.co/t/how-to-test-if-fieldnames-contains-specific-caracter/167645/2 "2019-02-08T15:22:26Z")

</div>

You can do it in ruby. For example,

```
input { generator { count => 1 message => '' } }
filter {
    mutate { add_field => { "someDate" => "2018-10-29 23:02:40" } }
    ruby {
        code => '
            event.to_hash.each { |k, v|
                if k.end_with? ("Date")
                    newv = Time.strptime(v, "%Y-%m-%d %H:%M:%S")
                    event.set(k, newv)
                end
            }
        '
    }
}
output { stdout {} }

```

gives me

```
  "someDate" => 2018-10-30T03:02:40.000Z,
```

---

<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:** [March 8, 2019, 3:22pm UTC](https://discuss.elastic.co/t/how-to-test-if-fieldnames-contains-specific-caracter/167645/3 "2019-03-08T15:22:36Z")

</div>

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