# Logstash SPLIT plugin discards/strips empty strings at the end

**URL:** <https://discuss.elastic.co/t/logstash-split-plugin-discards-strips-empty-strings-at-the-end/120473>\
**Category:** Logstash\
**Created:** [February 19, 2018, 2:44pm UTC](https://discuss.elastic.co/t/logstash-split-plugin-discards-strips-empty-strings-at-the-end/120473 "2018-02-19T14:44:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BariscanElkama](https://avatars.discourse-cdn.com/v4/letter/b/f14d63/32.png) [@BariscanElkama](https://discuss.elastic.co/u/BariscanElkama)\
**Post date:** [February 19, 2018, 2:44pm UTC](https://discuss.elastic.co/t/logstash-split-plugin-discards-strips-empty-strings-at-the-end/120473/1 "2018-02-19T14:44:47Z")

</div>

Hello,

I'm trying to parse a log data where each line is constructed with string fields that are separated with a "/t" delimeter. I'm forwarding logs with Filebeat to Logstash and in logstash, I get each line as a GREEDYDATA since each line may contain different number of fields with actual data in it ( some of them may be null). I use SPLIT plugin with "/t" delimeter to split data into an array. However, if there's a log line with null fields at the end, SPLIT field automatically discards those fields. Is there any way that I can set those fields with the NULL/Emptystring value?

**My Input data looks like this:**

- A/tB/tC/t/t/t

Normally, I should be able to extract 6 fields with "/t" delimeter. However, I'm only getting 3 fields because the ones at the end got discarded.

**How my Grok looks like:**

```
            grok
        	{
                        match => ["message", "%{GREEDYDATA:trx}"]
                }

```

**How Mutate&Split looks like:**

```
			mutate
			{
				split => 
				{
					"trx" => "	"
				}
				add_field => {"fieldA" => "%{[trx][0]}"}
				add_field => {"fieldB"=> "%{[trx][1]}"}
				add_field => {"fieldC"=> "%{[trx][2]}"}
				add_field => {"fieldD"=> "%{[trx][3]}"}
				add_field => {"fieldE"=> "%{[trx][4]}"}
				add_field => {"fieldF"=> "%{[trx][5]}"}

			}

```

Is there any way I can get all the fields even if they are empty and at the end?

---

<div class="post-metadata">

**Author:** ![immavalls](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/immavalls/32/146501_2.png) [@immavalls](https://discuss.elastic.co/u/immavalls)\
**Post date:** [February 20, 2018, 3:04am UTC](https://discuss.elastic.co/t/logstash-split-plugin-discards-strips-empty-strings-at-the-end/120473/2 "2018-02-20T03:04:34Z")

</div>

Hi,  
I would recomend a dissect filter:

```
dissect {
      mapping => {
        "message" => "%{+fieldA}/t%{+fieldB}/t%{+fieldC}/t%{fieldD}/t%{fieldE}/t%{fieldF}"
      }
}

```

Hope this helps.

---

<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 20, 2018, 3:05am UTC](https://discuss.elastic.co/t/logstash-split-plugin-discards-strips-empty-strings-at-the-end/120473/3 "2018-03-20T03:05:05Z")

</div>

Closed on March 20, 2018, 3:05am UTC

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