# Pipeline to parse SSL certificate data from httpd message lines?

**URL:** <https://discuss.elastic.co/t/pipeline-to-parse-ssl-certificate-data-from-httpd-message-lines/164533>\
**Category:** Logstash\
**Created:** [January 16, 2019, 8:16pm UTC](https://discuss.elastic.co/t/pipeline-to-parse-ssl-certificate-data-from-httpd-message-lines/164533 "2019-01-16T20:16:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![B\_TLJ](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@B\_TLJ](https://discuss.elastic.co/u/B_TLJ)\
**Post date:** [January 16, 2019, 8:16pm UTC](https://discuss.elastic.co/t/pipeline-to-parse-ssl-certificate-data-from-httpd-message-lines/164533/1 "2019-01-16T20:16:43Z")

</div>

I am new to ELK, and need to figure out a way to pull a username out of the httpd messages I am currently sending to logstash. the message lines look like this:

```
100.100.100.200 - - [16/Jan/2019:19:35:55 +0000] "GET /xx/api/notifications?cacheBuster=1547667357681 HTTP/1.1" 200 2 "https://www.testsite.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" SSL_DN='cn=userabc123,ou=Component,ou=XXX,ou=XXX,o=TheCompany,c=us' SSL_DUTY_AGENCY='' SSL_CITIZENSHIP='' SSL_ADMIN_ORG='' SSL_CLEARANCE='' 999999

```

I need to be able to parse out the userabc123 into a separate metric, but haven't found any pre-built code that can do it for me. Has anyone here come across a similar issue?

---

<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:** [January 16, 2019, 8:31pm UTC](https://discuss.elastic.co/t/pipeline-to-parse-ssl-certificate-data-from-httpd-message-lines/164533/2 "2019-01-16T20:31:16Z")

</div>

I would do that using dissect.

```
dissect { mapping => { "message" => "%{}SSL_DN='cn=%{user1},%{}" } }
```

---

<div class="post-metadata">

**Author:** ![B\_TLJ](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@B\_TLJ](https://discuss.elastic.co/u/B_TLJ)\
**Post date:** [January 16, 2019, 9:59pm UTC](https://discuss.elastic.co/t/pipeline-to-parse-ssl-certificate-data-from-httpd-message-lines/164533/3 "2019-01-16T21:59:54Z")

</div>

Thanks, Badger. I'll give that a try!

---

<div class="post-metadata">

**Author:** ![B\_TLJ](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@B\_TLJ](https://discuss.elastic.co/u/B_TLJ)\
**Post date:** [January 17, 2019, 12:19am UTC](https://discuss.elastic.co/t/pipeline-to-parse-ssl-certificate-data-from-httpd-message-lines/164533/4 "2019-01-17T00:19:08Z")

</div>

> [@Badger](#):
>
> ```auto
> dissect { mapping => { "message" => "%{}SSL_DN='cn=%{user1},%{}" } }
> 
> ```

So here is how I Implemented that into my pipeline file, but I'm clearly not doing it right - Any advice?

input {  
beats {  
port =\> 5044  
}  
}

filter {  
grok {  
match =\> { "dissect { mapping =\> { "message" =\> "%{}SSL\_DN='cn=%{user1},%{}" } } "}  
}

}

output {  
elasticsearch {  
hosts =\> "localhost:9200"  
manage\_template =\> false  
index =\> "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"  
}  
}

---

<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:** [January 17, 2019, 1:23am UTC](https://discuss.elastic.co/t/pipeline-to-parse-ssl-certificate-data-from-httpd-message-lines/164533/5 "2019-01-17T01:23:25Z")

</div>

> [@B\_TLJ](#):
>
> filter {  
> grok {  
> match =\> { "dissect { mapping =\> { "message" =\> "%{}SSL\_DN='cn=%{user1},%{}" } } "}  
> }  
> }

[grok](https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html) is one type of filter, [dissect](https://www.elastic.co/guide/en/logstash/current/plugins-filters-dissect.html) is another. Whilst grok solves a lot of pattern matching problems, dissect solves some of them more efficiently, so it is good to have both in your toolbox. Try

```
filter {
    dissect { mapping => { "message" => "%{}SSL_DN='cn=%{user1},%{}" } }
}

```

This assumes that the cn= field never contains a comma (it says that the comma ends the %{user1} field. But you would have the same fragility in grok. It looks like you could match "SSL\_DN='cn=%{WORD:user2}" but what if the user name is more complex than a WORD?

Either way, it should get you started.

---

<div class="post-metadata">

**Author:** ![B\_TLJ](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@B\_TLJ](https://discuss.elastic.co/u/B_TLJ)\
**Post date:** [January 17, 2019, 1:38pm UTC](https://discuss.elastic.co/t/pipeline-to-parse-ssl-certificate-data-from-httpd-message-lines/164533/6 "2019-01-17T13:38:55Z")

</div>

Exactly what I needed. Thanks for all the help!

---

<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:** [February 14, 2019, 1:39pm UTC](https://discuss.elastic.co/t/pipeline-to-parse-ssl-certificate-data-from-httpd-message-lines/164533/7 "2019-02-14T13:39:00Z")

</div>

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