# Logstash ODX input File - unconventional input file

**URL:** <https://discuss.elastic.co/t/logstash-odx-input-file-unconventional-input-file/225324>\
**Category:** Logstash\
**Created:** [March 27, 2020, 2:57am UTC](https://discuss.elastic.co/t/logstash-odx-input-file-unconventional-input-file/225324 "2020-03-27T02:57:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie001](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@newbie001](https://discuss.elastic.co/u/newbie001)\
**Post date:** [March 27, 2020, 2:57am UTC](https://discuss.elastic.co/t/logstash-odx-input-file-unconventional-input-file/225324/1 "2020-03-27T02:57:38Z")

</div>

Hi - I was hoping someone could help me regarding input in logstash. I am very new to logstash and I have a requirement where my logstash input file is an unconventional file.

How do I input an ODX input file? I think delimiter for the input file is "#" as we'd like to treat those with "#" as Columns/Fields.

Sample data:

#Customer Market  
250  
#Date of Export  
Mon Jan 20 08:41:12 2020  
#Current Device  
DigiMarkXP  
#Taskcounter  
1  
#----- Start Task -----

#Location  
FoodMarket\_001\Grocery\_XXX\118\_Cust  
#Customer ID  
0118  
#Cashier Counter  
1  
#Counter Name  
DigiMarkXP  
#Items  
20

Thanks in advance

---

<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:** [March 27, 2020, 5:27pm UTC](https://discuss.elastic.co/t/logstash-odx-input-file-unconventional-input-file/225324/2 "2020-03-27T17:27:50Z")

</div>

The approach I would take would be to use a multiline codec on the input to read the file as a single event (as shown at the end of [this](https://discuss.elastic.co/t/parsing-xml-log-file-with-logstash/167306/2) post). Then use a ruby scan function

```
    ruby {
        code => '
            s = event.get("message")
            m = s.scan(/#([^\n]*)\n([^\n]*)?(\n|$)/)
            m.each { |x|
                event.set(x[0], x[1])
            }
        '
    }

```

That does not quite work because

```
#----- Start Task -----

#Location

```

results in '#----- Start Task -----\n#Location\n' rather than '#----- Start Task -----\n\n#Location\n' and thus you lose the Location field. However, it does process most of the fields correctly.

```
       "Cashier Counter" => "1",
        "Current Device" => "DigiMarkXP",
           "Taskcounter" => "1",
           "Customer ID" => "0118",
       "Customer Market" => "250",

```

etc. It is probably possible to gsub in the missing \n and recover the Location field.

Obviously this does not retain any of the task definition or other orchestration information.

---

<div class="post-metadata">

**Author:** ![newbie001](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@newbie001](https://discuss.elastic.co/u/newbie001)\
**Post date:** [April 2, 2020, 5:46am UTC](https://discuss.elastic.co/t/logstash-odx-input-file-unconventional-input-file/225324/3 "2020-04-02T05:46:10Z")

</div>

this works. Thanks for the help Badger.

---

<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:** [April 30, 2020, 5:46am UTC](https://discuss.elastic.co/t/logstash-odx-input-file-unconventional-input-file/225324/4 "2020-04-30T05:46:14Z")

</div>

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