# How to use Regex in Logstash config file to capture unidentified weblogicLogErrors

**URL:** <https://discuss.elastic.co/t/how-to-use-regex-in-logstash-config-file-to-capture-unidentified-weblogiclogerrors/137626>\
**Category:** Logstash\
**Created:** [June 27, 2018, 1:13pm UTC](https://discuss.elastic.co/t/how-to-use-regex-in-logstash-config-file-to-capture-unidentified-weblogiclogerrors/137626 "2018-06-27T13:13:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snehabh](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@snehabh](https://discuss.elastic.co/u/snehabh)\
**Post date:** [June 27, 2018, 1:13pm UTC](https://discuss.elastic.co/t/how-to-use-regex-in-logstash-config-file-to-capture-unidentified-weblogiclogerrors/137626/1 "2018-06-27T13:13:54Z")

</div>

Hi All,

## My requirement is to identify all unknown Error present in log file[or may occur in future] for which i am capturing all known Error logs and trying to achieve it using regex along with conditional if. Problem is it doesn't throw any error but it also doesn't capture and add a tag for the same as expected. please correct and help me NEW to ELK.Using 6.2.4 version

## CODE -Logstash config file

grok  
{  
match =\> ["message","\<%{DATA:wls\_timestamp}\> \<%{DATA:severity}\> \<%{DATA:wls\_engine}\> \<%{DATA:wls\_errorcode}\> \<%{GREEDYDATA:wls\_logmessage}\>"]  
}  
if "Error" in [severity]  
{ #1  
if "oracle.soa.adapter" in [wls\_engine]  
{  
if "BEA-000000" in [wls\_errorcode]  
{  
if [wls\_logmessage]=="UploadInvoiceToSharepoint[A-Za-z0-9':.[](),\s-\_!\*]\*/u01/mounts/mntNOWBATEU01/PrintQueue/"  
#here is the problem which doesn't add a tag please correct me where m i going wrong or best way to do it.  
{  
mutate  
{  
add\_tag =\> ["SharepointFileFail"]  
}

```
			}

```

#n no.of known errors maybe  
else if {}  
else{ # it is error but not from the known list  
mutate  
{  
add\_tag =\> ["Unknown Errors"]  
}  
}

* * *

## Sample log message

\<Jun 22, 2018 6:30:26 PM UTC\> \<oracle.soa.adapter\> \<JCABinding=\> UploadInvoiceToSharepointNOWReq:FileSyncReadInvoice [SynchRead\_ptt::SynchRead(Empty,opaque)] Could not invoke operation 'SynchRead' against the 'file' due to:  
BINDING.JCA-11007  
No Data to process.  
No Data to process.

File /u01/mounts/mntName/PrintQueue/

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 27, 2018, 7:29pm UTC](https://discuss.elastic.co/t/how-to-use-regex-in-logstash-config-file-to-capture-unidentified-weblogiclogerrors/137626/2 "2018-06-27T19:29:25Z")

</div>

This is the syntax for regexp conditionals:

```
if [fieldname] =~ /some regexp/ {

```

[https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals)

---

<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:** [July 25, 2018, 7:29pm UTC](https://discuss.elastic.co/t/how-to-use-regex-in-logstash-config-file-to-capture-unidentified-weblogiclogerrors/137626/3 "2018-07-25T19:29:27Z")

</div>

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