# Output based on metadata field is not working

**URL:** https://discuss.elastic.co/t/output-based-on-metadata-field-is-not-working/194787
**Category:** Logstash
**Created:** [August 12, 2019, 4:11am UTC](https://discuss.elastic.co/t/output-based-on-metadata-field-is-not-working/194787 "2019-08-12T04:11:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![rameshpasunoori](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rameshpasunoori](https://discuss.elastic.co/u/rameshpasunoori)
#### Post date: [August 12, 2019, 4:11am UTC](https://discuss.elastic.co/t/output-based-on-metadata-field-is-not-working/194787/1 "2019-08-12T04:11:20Z")

</div>

- Version: 7.3
- Operating System: Windows 10
- Config File (if you have sensitive info, please remove it):  
filter {mutate {  
add\_field =\> {  
"[[@metadata](https://github.com/metadata)][ingestInto]" =\> "${INGEST\_INTO:true}"  
}  
}

}

output {

```auto
file {
    path => "test.json"
    write_behavior => overwrite
}

**if [@metadata][ingestInto] != "true" {** 
    http {
            http_method => "post"
            url => "XXXXX"
            format => "message"
            headers => {"Content-Type" => "application/json"}
            content_type => "application/json"
            message => '%{message}'
            pool_max => 100
            pool_max_per_route => 100
    }
}
**else if [@metadata][ingestInto] != "false" {**

    elasticsearch {
        hosts => "${ES_HTTP_HOSTS}"
        index => "itoa1"
        document_id => "%{key}"
        document_type => "data"
    }       

}

```

}

- Sample Data:  
else if [[@metadata](https://github.com/metadata)][ingestInto] != "false" or true , always it trying to push data to elastic.

---

<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: [August 12, 2019, 12:26pm UTC](https://discuss.elastic.co/t/output-based-on-metadata-field-is-not-working/194787/2 "2019-08-12T12:26:31Z")

</div>

Use

```
output { stdout { codec => rubydebug { metadata => true } } }

```

What is the value of [@metadata][ingestInto]?

---

<div class="post-metadata">

### Author: ![rameshpasunoori](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rameshpasunoori](https://discuss.elastic.co/u/rameshpasunoori)
#### Post date: [August 13, 2019, 10:58am UTC](https://discuss.elastic.co/t/output-based-on-metadata-field-is-not-working/194787/3 "2019-08-13T10:58:06Z")

</div>

> [@Badger](#):
>
> ingestInto

Setting the environment variable  
set INGEST\_INTO\_JARVIS=true

mutate {  
add\_field =\> {  
"[@metadata][ingestIntoJarvis]" =\> "${INGEST\_INTO\_JARVIS:true}"   
} }

I have enable the output as suggested.

Nothing printed in [@metadata][ingestIntoJarvis] .

---

<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: [August 13, 2019, 12:50pm UTC](https://discuss.elastic.co/t/output-based-on-metadata-field-is-not-working/194787/4 "2019-08-13T12:50:47Z")

</div>

I cannot explain why the add\_field would not occur.

---

<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: [September 10, 2019, 12:51pm UTC](https://discuss.elastic.co/t/output-based-on-metadata-field-is-not-working/194787/5 "2019-09-10T12:51:45Z")

</div>

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