# Csv filter : how to deal with missing field?

**URL:** <https://discuss.elastic.co/t/csv-filter-how-to-deal-with-missing-field/290147>\
**Category:** Logstash\
**Created:** [November 25, 2021, 9:21am UTC](https://discuss.elastic.co/t/csv-filter-how-to-deal-with-missing-field/290147 "2021-11-25T09:21:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Travis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/travis/32/54079_2.png) [@Travis](https://discuss.elastic.co/u/Travis)\
**Post date:** [November 25, 2021, 9:21am UTC](https://discuss.elastic.co/t/csv-filter-how-to-deal-with-missing-field/290147/1 "2021-11-25T09:21:20Z")

</div>

Hello !

I have the following data :

> \<188\>Nov 25 07:38:31 172.28.192.111 ts-swsan-p11 raslogd: 2021/11/25-07:38:31, [MAPS-1003], 28921, WWN 10:00:88:94:71:c4:c0:e0 | FID 128, WARNING, ts-swsan-p11, SW11\_TS\_VPLEX\_P01\_E1B2FC01, F-Port 28, Condition=ALL\_PORTS(DEV\_LATENCY\_IMPACT==IO\_PERF\_IMPACT), Current Value:[DEV\_LATENCY\_IMPACT, IO\_PERF\_IMPACT, (10 ms Frame Delay)], RuleName=defALL\_PORTS\_IO\_PERF\_IMPACT\_UNQUAR, Dashboard Category=Fabric Performance Impact.

> \<190\>Nov 25 07:39:31 172.28.192.111 ts-swsan-p11 raslogd: 2021/11/25-07:39:31, [MAPS-1004], 28922, WWN 10:00:88:94:71:c4:c0:e0 | FID 128, INFO, ts-swsan-p11, SW11\_TS\_VPLEX\_P01\_E1B2FC01, F-Port 28, Condition=ALL\_PORTS(DEV\_LATENCY\_IMPACT==IO\_LATENCY\_CLEAR), Current Value:[DEV\_LATENCY\_IMPACT, IO\_LATENCY\_CLEAR], RuleName=defALL\_PORTS\_IO\_LATENCY\_CLEAR, Dashboard Category=Fabric Performance Impact.

And the following pipeline :

```auto
filter
{

    csv {
      skip_empty_columns => true
      autogenerate_column_names => false
      columns => ["syslog_header","maps","to_define","switch_WWN","severity","device_name","port_name","port_number","condition","current_value","log_type","frame_delay","rule_name","dashboard_category"]

      }

}

```

In the second line of log, the one starting with \<190\>, the field (10 ms Frame Delay) ] is missing. And so, the parsing is shifted :

_I have this :_

**frame\_delay** =\> RuleName=defALL\_PORTS\_IO\_LATENCY\_CLEAR

_Instead of this :_

**frame\_delay** =\>  
**rule\_name** =\> RuleName=defALL\_PORTS\_IO\_LATENCY\_CLEAR

I tried **skip\_empty\_columns =\> true** but the field is not parsed as empty so it looks like this is not the solution

Any way to figure this out ?

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:** [November 25, 2021, 2:39pm UTC](https://discuss.elastic.co/t/csv-filter-how-to-deal-with-missing-field/290147/2 "2021-11-25T14:39:41Z")

</div>

That is not a CSV format, so a csv filter is the wrong tool. I would parse the constant format prefix to the message using dissect, or perhaps grok, then use a kv filter.

```
kv { value_split => "=" field_split_pattern => " (?=([A-Za-z]+=))" trim_value => ",." }

```

will result in

```
 "Condition" => "ALL_PORTS(DEV_LATENCY_IMPACT==IO_LATENCY_CLEAR), Current Value:[DEV_LATENCY_IMPACT, IO_LATENCY_CLEAR]",RuleName=defALL_PORTS_IO_LATENCY_CLEAR, Dashboard Category=Fabric Performance Impact.",
  "RuleName" => "defALL_PORTS_IO_LATENCY_CLEAR",
  "Category" => "Fabric Performance Impact"

```

which probably needs some tuning, but may get you started.

---

<div class="post-metadata">

**Author:** ![Travis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/travis/32/54079_2.png) [@Travis](https://discuss.elastic.co/u/Travis)\
**Post date:** [November 25, 2021, 4:09pm UTC](https://discuss.elastic.co/t/csv-filter-how-to-deal-with-missing-field/290147/3 "2021-11-25T16:09:17Z")

</div>

Thank you @Badger . I'm going to test this.

As a temporary workaround, I found this :

```auto
filter
{

grok {
  match => { "message" => "<%{POSINT:syslog_pri}>(%{SYSLOGTIMESTAMP:syslog_timestamp}) %{IP:syslog_host_ip} %{HOSTNAME:syslog_host} %{SYSLOGPROG:syslog_prog}: %{YEAR}/%{MONTHNUM}/%{MONTHDAY}-%{HOUR}:%{MINUTE}:%{SECOND}, (\[%{DATA:maps}\])?, %{INT:to_define}, %{DATA:wwn}, %{WORD:severity}, %{HOSTNAME:device_name}, %{DATA:port_name}, F-Port %{INT:port_number}, Condition=%{DATA:condition}, Current Value:\[(%{DATA:current_value_1})?, (%{DATA:current_value_2}])?, RuleName=%{DATA:rule_name}, Dashboard Category=%{DATA:dashboard_category}\." }
}

if [current_value_2] =~ ".*Delay.*" {
        grok {
                match => { "current_value_2" => "%{INT:frame_delay}"}
        }
}
}

```

---

<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:** [December 23, 2021, 4:10pm UTC](https://discuss.elastic.co/t/csv-filter-how-to-deal-with-missing-field/290147/4 "2021-12-23T16:10:12Z")

</div>

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