# Logstash filter if conditional fails to match string ended with "\\u0000"

**URL:** <https://discuss.elastic.co/t/logstash-filter-if-conditional-fails-to-match-string-ended-with-u0000/296248>\
**Category:** Logstash\
**Created:** [February 4, 2022, 3:23am UTC](https://discuss.elastic.co/t/logstash-filter-if-conditional-fails-to-match-string-ended-with-u0000/296248 "2022-02-04T03:23:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![juowong](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@juowong](https://discuss.elastic.co/u/juowong)\
**Post date:** [February 4, 2022, 3:23am UTC](https://discuss.elastic.co/t/logstash-filter-if-conditional-fails-to-match-string-ended-with-u0000/296248/1 "2022-02-04T03:23:42Z")

</div>

I am using logstash to receive network logs using `syslog` input module. I would like to drop the event if the log message is equal to `A10`. The pipeline is as follows:

```auto
input {
	syslog {
		ecs_compatibility => "v1"
		timezone => "Asia/Hong_Kong"
		port => "5000"
		type => "syslog"
		grok_pattern => "%{SYSLOG5424LINE}"
		tags => ["PAN-OS_syslog"]
	}
}

filter {
	# Drop A10 events
	if [message] == "A10" { 
		drop { } 
	}

	# Drop event if no "PAN-OS_syslog" tag
	if "PAN-OS_syslog" not in [tags] {
		drop { }
	}
}

output {
	if ([message] =~ /TRAFFIC/) {
		pipeline { send_to => "sys-log-traffic" }
	}	else if ([message] =~ /THREAT/) {
		pipeline { send_to => "sys-log-threat" }	
	} else {
		pipeline { send_to => "sys-log-wifi" }
	}
}

```

However, it fails to drop the event with the message `A10`. I checked the json object on Kibana, there is a special character `\u0000` attached

```auto
{
	"_index": "sys-wifi-2022.02-000002",
 	"_type": "_doc",
	# ...
	"message": "A10\u0000",
}

```

I tried to correct the pipeline to `if [message] == "A10\u0000"`, it does not filter the event as intended. I also tried to match the message with `if [message] =~ "A10"`, it works, but I don't want all messages that contain `"A10"` string to be filtered out.

Is there a way to match the string as I intended? Thank you in advance for your input.

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [February 4, 2022, 9:20am UTC](https://discuss.elastic.co/t/logstash-filter-if-conditional-fails-to-match-string-ended-with-u0000/296248/2 "2022-02-04T09:20:00Z")

</div>

I'm not sure if it works, but how about [gsub](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-gsub) or [strip](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-strip) option of mutate plugin before check the message == "A10".

---

<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 4, 2022, 5:59pm UTC](https://discuss.elastic.co/t/logstash-filter-if-conditional-fails-to-match-string-ended-with-u0000/296248/3 "2022-02-04T17:59:58Z")

</div>

Maybe `if [message] =~ "^A10.$" { drop {} }` which should drop any four character [message] that starts with A10.

---

<div class="post-metadata">

**Author:** ![juowong](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@juowong](https://discuss.elastic.co/u/juowong)\
**Post date:** [February 8, 2022, 5:49am UTC](https://discuss.elastic.co/t/logstash-filter-if-conditional-fails-to-match-string-ended-with-u0000/296248/4 "2022-02-08T05:49:39Z")

</div>

This does certainly solve my problem, thank you very much.

---

<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, 2022, 5:50am UTC](https://discuss.elastic.co/t/logstash-filter-if-conditional-fails-to-match-string-ended-with-u0000/296248/5 "2022-03-08T05:50:12Z")

</div>

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