# How to use metadata id to condition check of Logstash output which use jdbc input?

**URL:** <https://discuss.elastic.co/t/how-to-use-metadata-id-to-condition-check-of-logstash-output-which-use-jdbc-input/154821>\
**Category:** Logstash\
**Created:** [October 31, 2018, 11:11am UTC](https://discuss.elastic.co/t/how-to-use-metadata-id-to-condition-check-of-logstash-output-which-use-jdbc-input/154821 "2018-10-31T11:11:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)\
**Post date:** [October 31, 2018, 11:11am UTC](https://discuss.elastic.co/t/how-to-use-metadata-id-to-condition-check-of-logstash-output-which-use-jdbc-input/154821/1 "2018-10-31T11:11:50Z")

</div>

Hi,

I am using ELK GA 6.3.0. I have a logstash input like;

```
input {
	jdbc {
		id => "jdbc1"
		.
		.
		.
		statement => "some sql statement"
		add_field => { "logtype" => "jdbc_log_1" }
	}
}

```

and I have multiple jdbc inputs, from different tables. The content from tables will go to their corresponding ES indices. I want to condition check to publish to elasticsearch. What I am currently doing is;

```
output{
	if[logtype] == "jdbc_log_1"{
		elasticsearch {
			.
			.
			.
			index => "jdbc_log_1-%{+YYYY-MM-dd}"
		}
	}
}

```

This works fine. But I want to do this with input id metadata field `jdbc1` and avoid `if[logtype] == "jdbc_log_1"{` . Is there any way to do this?

Thanks

---

<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:** [November 28, 2018, 11:11am UTC](https://discuss.elastic.co/t/how-to-use-metadata-id-to-condition-check-of-logstash-output-which-use-jdbc-input/154821/2 "2018-11-28T11:11:55Z")

</div>

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