# Logstash with two dissect - only the first dissect is used now and then

**URL:** https://discuss.elastic.co/t/logstash-with-two-dissect-only-the-first-dissect-is-used-now-and-then/292794
**Category:** Logstash
**Created:** [December 23, 2021, 10:00am UTC](https://discuss.elastic.co/t/logstash-with-two-dissect-only-the-first-dissect-is-used-now-and-then/292794 "2021-12-23T10:00:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![stillfreem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stillfreem/32/85628_2.png) [@stillfreem](https://discuss.elastic.co/u/stillfreem)
#### Post date: [December 23, 2021, 10:00am UTC](https://discuss.elastic.co/t/logstash-with-two-dissect-only-the-first-dissect-is-used-now-and-then/292794/1 "2021-12-23T10:00:14Z")

</div>

Hi All,

I have the following conf

```auto
{
        syslog
        {
           host => "127.0.0.1"
           port => 5000
        }
}

filter
{
        if [program] == "github_auth" or [program == "github_gitauth"] or [program] == "github_access" {

        if [PID] == "" { mutate { update => { "PID" => "N/A" } } }
        else { mutate { gsub => ["PID", "[\[\]]", ""] } }

        if [message] =~ /^{/ {
                                        json { source => "message" }
                                        mutate { add_tag => "json" }
                                 }
        else if [message] =~ /.*=.*/ {
                                        dissect { mapping => { "message" => "%{D} [%{Date}] %{LogLevel} %{} : %{data}" } }
                                        kv { source => "data" }
                                        mutate { add_tag => "kv" }
                                         }
        else {
        		dissect { mapping => { "message" => "%{D} [%{Date}] %{LogLevel} %{} : %{data}" } }
                csv {
                        source => "data"
                        separator => " "
                    }
                mutate { add_tag => "csv" }
             }
        }
        else { drop{} }
}

output
{
        if [tags] =~ /fail/
        {
                stdout{}
        }
        else { exec { command => "echo OK" } }
}

```

As you can see depending on the log format (key/value or value only) I use respectively `kv` or `csv` filters. Those two filters relays on `dissect`.  
And I have a different variation of the dissect for each. Again respectively  
`dissect { mapping => { "message" => "%{D} [%{Date}] %{LogLevel} %{} : %{data}" } }`  
AND  
`dissect { mapping => { "message" => "%{Line} %{host} [%{Date}] %{data}" } }`

Mostly this works fine but sometimes I can see messages that are in the format of value only (that must have been caught by`csv`) to be caught by the `dissect` of the `kv`.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/f/dfe5a7cd42ea2e8c0e2620f1c51999d3c0fe8945.jpeg)

---

<div class="post-metadata">

### Author: ![stillfreem](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stillfreem/32/85628_2.png) [@stillfreem](https://discuss.elastic.co/u/stillfreem)
#### Post date: [December 23, 2021, 10:09am UTC](https://discuss.elastic.co/t/logstash-with-two-dissect-only-the-first-dissect-is-used-now-and-then/292794/2 "2021-12-23T10:09:14Z")

</div>

Got it 🙂  
My `kv` filter was too loose.  
Instead of `.*=.*` I used `\w+=\w+\s\w+=\w+`

---

<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: [January 20, 2022, 10:10am UTC](https://discuss.elastic.co/t/logstash-with-two-dissect-only-the-first-dissect-is-used-now-and-then/292794/3 "2022-01-20T10:10:03Z")

</div>

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