# Sprintf format in if statement

**URL:** <https://discuss.elastic.co/t/sprintf-format-in-if-statement/172087>\
**Category:** Logstash\
**Created:** [March 13, 2019, 8:35am UTC](https://discuss.elastic.co/t/sprintf-format-in-if-statement/172087 "2019-03-13T08:35:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcarre31](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@jcarre31](https://discuss.elastic.co/u/jcarre31)\
**Post date:** [March 13, 2019, 8:35am UTC](https://discuss.elastic.co/t/sprintf-format-in-if-statement/172087/1 "2019-03-13T08:35:58Z")

</div>

I try to use a sprintf format in a IF statement in output bloc but failled.

```auto
filter {
  mutate {
        add_field => { "systype" => "cpu" }
  }
}

output {
   if [event][dataset] == "system.%{systype}" {
    elasticsearch {
...

```

=\> never go into the elastic output

```auto
filter {
  mutate {
        add_field => { "systype" => "cpu" }
  }
  mutate {
    add_field => { "systype2" => "system.%{systype}" }
  }
}

output {
   if [event][dataset] == [systype2] {
    elasticsearch {
...

```

=\> It's OK

why ?

---

<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 10, 2019, 8:36am UTC](https://discuss.elastic.co/t/sprintf-format-in-if-statement/172087/2 "2019-04-10T08:36:04Z")

</div>

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