Bug 982303

Summary: Unable to use Filter Expressions in filter-spec
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Petr Kremensky <pkremens>
Component: LoggingAssignee: Emmanuel Hugonnet (ehsavoie) <ehugonne>
Status: CLOSED CURRENTRELEASE QA Contact: Nikoleta Hlavickova <nziakova>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.1.1CC: cdewolf, ehugonne, kopiyo1967, myarboro
Target Milestone: ER4   
Target Release: EAP 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-15 16:22:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Kremensky 2013-07-08 15:38:40 UTC
Description of problem:
I am really not sure how to create logging filters using filter-spec.

I am able to use only: accept, deny, not and match expressions.

I tried to use deprecated filter attribute for help:
[standalone@localhost:9999 console-handler=CONSOLE] :write-attribute(name=filter, value={replace => {"pattern" => "JBAS","replacement" => "DUMMY","replace-all" => true}})

will create:
[standalone@localhost:9999 console-handler=CONSOLE] :read-resource
...
"filter-spec" => "substituteAll(\"JBAS\",\"DUMMY\")",
...

but: 
[standalone@localhost:9999 console-handler=CONSOLE] :write-attribute(name=filter-spec, value=substituteAll("JBAS","DUMMY"))
{
    "outcome" => "failed",
    "failure-description" => "JBAS014688: Wrong type for filter-spec. Expected [EXPRESSION, STRING] but was LIST",
    "rolled-back" => true
}

Did I overlook something? If yes, can you please create some simple example commands, so we can add this feature to EAP documentation.

I use community documentation here https://docs.jboss.org/author/display/AS72/Logging+Configuration#LoggingConfiguration-FilterExpressions

Version-Release number of selected component (if applicable):
EAP 6.1.1 ER2

Comment 1 James Perkins 2013-07-12 21:59:21 UTC
It's more likely an issue with the way CLI parses the value. Your value argument is correct. I'm not sure if it's possible to use in CLI which is a problem. I can't figure out the syntax at least. It tried escaping with " with \", but that didn't work.

Comment 4 Emmanuel Hugonnet (ehsavoie) 2013-08-01 07:49:18 UTC
https://github.com/jbossas/jboss-eap/pull/270

Comment 5 Petr Kremensky 2013-09-12 09:01:18 UTC
I am quite confused by this fix. You've just added test for filter (which is deprecated, filter-spec should be used instead). Filter expressions are still not working.
You can try examples from documentation - (13.1.5. Filter Expressions for Logging)
 - http://documentation-devel.engineering.redhat.com/docs/en-US/Red_Hat_JBoss_Enterprise_Application_Platform/6.1/html/Administration_and_Configuration_Guide/chap-The_Logging_Subsystem.html#Filter_Expressions_for_Logging

Comment 6 Emmanuel Hugonnet (ehsavoie) 2013-09-12 09:17:13 UTC
I thought you had an issue creating the filters through the cli which this test checks.
Could you be more precise on what you mean by 'not working' ?

Comment 7 Petr Kremensky 2013-09-12 09:45:20 UTC
I had an issue with creating filter-spec through the cli.

There are two attributes in every logging handler, filter and filter-spec.
Filter accepts type OBJECT, but it is deprecated now and filter-spec should be used as alternative.

see CLI read-resource output:
"filter" => {   "type" => OBJECT,
                "description" => "Defines a simple filter type.",
                "alternatives" => ["filter-spec"],
                "deprecated" => {
                    "since" => "1.2.0",
                    "reason" => "Use filter-spec."
                },
....

Filter-spec accepts Strings and should be able to cover functionality of original filter.

My problem is, that I am unable to create more complicated filters with filter-spec eg. :write-attribute(name=filter-spec, value=substituteAll("JBAS","DUMMY")).

Comment 8 Emmanuel Hugonnet (ehsavoie) 2013-09-13 14:55:09 UTC
The received command has lost the first escaped quote

Comment 9 Emmanuel Hugonnet (ehsavoie) 2013-09-18 16:08:58 UTC
/subsystem=logging/console-handler=CONSOLE:write-attribute(name=filter-spec, value=substituteAll("JBAS" \, "DUMMY")) is working

You have to escape the comma so the value is correctly assumed to be a String otherwise it would be parsed as a List.

Comment 10 JBoss JIRA Server 2013-09-27 08:29:46 UTC
Emmanuel Hugonnet <ehugonne> made a comment on jira WFLY-1791

The argument values are parsed a second time which means that the escaped char have been unescaped.
Changing this in the PR: https://github.com/wildfly/wildfly/pull/5159

Comment 12 JBoss JIRA Server 2013-10-02 15:27:02 UTC
Alexey Loubyansky <alex> made a comment on jira WFLY-1791

This has been merged.

Comment 16 Petr Kremensky 2013-12-05 09:46:45 UTC
Verified on EAP 6.2.0.CR3.

One can use filter expression with escaped comma like:
[standalone@localhost:9999 /] /subsystem=logging/console-handler=CONSOLE:write-attribute(name=filter-spec, value=substituteAll("JBAS"\,"SABJ"))

Comment 18 Ryan Owens 2020-09-03 11:36:38 UTC
Mostly people don't know what the author of this article wants to discuss here. But in simple words, I can explain my Filter product https://bestosmosissystems.com/best-water-softener-reviews/ site where I am busy selling my water filters. These filters make your water pure and healthy for drink.