# Logstash compare field with quotedstring fails

**URL:** https://discuss.elastic.co/t/logstash-compare-field-with-quotedstring-fails/277385
**Category:** Logstash
**Created:** [June 29, 2021, 8:55pm UTC](https://discuss.elastic.co/t/logstash-compare-field-with-quotedstring-fails/277385 "2021-06-29T20:55:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mtudisco](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@mtudisco](https://discuss.elastic.co/u/mtudisco)
#### Post date: [June 29, 2021, 8:55pm UTC](https://discuss.elastic.co/t/logstash-compare-field-with-quotedstring-fails/277385/1 "2021-06-29T20:55:44Z")

</div>

Hi,  
I'm parsing modsecurity messages from apache error log, one of the fields i get is ruleid that is parsed with a grok filter using the pattern QUOTEDSTRING. So in the field for instance i get a string with quotes: ""90999""  
When the value es 90999 i want to taker further action, but depending on how i write the "if" it works or not:

```auto
if [ruleid] == "90999" {
    # never gets into here even when ruleid is 90999
}

if [ruleid] == "\"90999\"" {
    # never gets into here even when ruleid is 90999
}

if [ruleid] =~ /\"90999\"/ {
    # now it works and when ruleid is 90999 it gets into the if
}

```

However third option that is working is not as precesite as first or second. Does anyone have an idea why second is not working?

Here is a summary of the document:

```auto
{
  "_index": "........",
  "_type": "_doc",
  "_id": "11qAWXoBgAYQIH4y4XnX",
  "_version": 1,
  "_score": null,
  "_source": {
    "type": "apache_error",
.........
    "ruleid": "\"90999\"",
    "ruletag4": "\"event-correlation\"",
    "modsecmessage": "Pattern match \"403\" at RESPONSE_STATUS.",
......
}

```

thanks

---

<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: [June 29, 2021, 9:13pm UTC](https://discuss.elastic.co/t/logstash-compare-field-with-quotedstring-fails/277385/2 "2021-06-29T21:13:28Z")

</div>

> [@mtudisco](#):
>
> Does anyone have an idea why second is not working?

Feels like a bug to me.

```
if [ruleid] == '"90999"' 

```

works just fine.

---

<div class="post-metadata">

### Author: ![mtudisco](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@mtudisco](https://discuss.elastic.co/u/mtudisco)
#### Post date: [June 30, 2021, 12:32pm UTC](https://discuss.elastic.co/t/logstash-compare-field-with-quotedstring-fails/277385/3 "2021-06-30T12:32:17Z")

</div>

Thanks! that worked!

---

<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: [July 28, 2021, 12:32pm UTC](https://discuss.elastic.co/t/logstash-compare-field-with-quotedstring-fails/277385/4 "2021-07-28T12:32:42Z")

</div>

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