# "If do" In Queries

**URL:** <https://discuss.elastic.co/t/if-do-in-queries/108692>\
**Category:** Kibana\
**Created:** [November 22, 2017, 10:05am UTC](https://discuss.elastic.co/t/if-do-in-queries/108692 "2017-11-22T10:05:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacesa](https://avatars.discourse-cdn.com/v4/letter/z/d07c76/32.png) [@zacesa](https://discuss.elastic.co/u/zacesa)\
**Post date:** [November 22, 2017, 10:05am UTC](https://discuss.elastic.co/t/if-do-in-queries/108692/1 "2017-11-22T10:05:01Z")

</div>

Hi, I'm wondering if it's possible to do an if do or sed in the queries.

For example,

```
message: foo

s/foo/bar/g

```

or something like

```
if {
    message: foo
    {
        flag:bar
    }
}
```

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [November 22, 2017, 2:21pm UTC](https://discuss.elastic.co/t/if-do-in-queries/108692/2 "2017-11-22T14:21:34Z")

</div>

Hi,

Where do you want to do this in queries? in Kibana or elasticsearch?

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![zacesa](https://avatars.discourse-cdn.com/v4/letter/z/d07c76/32.png) [@zacesa](https://discuss.elastic.co/u/zacesa)\
**Post date:** [November 22, 2017, 2:22pm UTC](https://discuss.elastic.co/t/if-do-in-queries/108692/3 "2017-11-22T14:22:57Z")

</div>

Hi,

In Kibana or Grafana. Thanks!

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [November 22, 2017, 2:38pm UTC](https://discuss.elastic.co/t/if-do-in-queries/108692/4 "2017-11-22T14:38:07Z")

</div>

Hi,

We don't know in grafana :). But it's definitely possible in Kibana. Kibana runs on elasticsearch. You have multiple ways of querying data in Kibana - using lucene or Kuery in 6.0 - which is Kibana's own query language.

Here are some tutorial examples for it: [https://www.youtube.com/watch?v=mMhnGjp8oOI](https://www.youtube.com/watch?v=mMhnGjp8oOI)  
Here is our Kibana documentation: [https://www.elastic.co/guide/en/kibana/current/search.html](https://www.elastic.co/guide/en/kibana/current/search.html)

Hope this helps.

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![zacesa](https://avatars.discourse-cdn.com/v4/letter/z/d07c76/32.png) [@zacesa](https://discuss.elastic.co/u/zacesa)\
**Post date:** [November 23, 2017, 12:27am UTC](https://discuss.elastic.co/t/if-do-in-queries/108692/5 "2017-11-23T00:27:22Z")

</div>

Hi,

All I see in those two links are about searching though. Nothing about searching and creating additional field with another value if a certain criteria is fulfilled.

---

<div class="post-metadata">

**Author:** ![zacesa](https://avatars.discourse-cdn.com/v4/letter/z/d07c76/32.png) [@zacesa](https://discuss.elastic.co/u/zacesa)\
**Post date:** [November 23, 2017, 3:02am UTC](https://discuss.elastic.co/t/if-do-in-queries/108692/6 "2017-11-23T03:02:39Z")

</div>

Thanks for the help @bhavyarm!

I've decided to use LogStash instead to do what I wanted.

For those curious, I used the below;

```
if "foo" in [message] {
     mutate { add_field => { "flag" => "bar" } }
}

```

Thank you!

---

<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:** [December 21, 2017, 3:02am UTC](https://discuss.elastic.co/t/if-do-in-queries/108692/7 "2017-12-21T03:02:42Z")

</div>

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