<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Ranger Audit Log (Add filter) in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Ranger-Audit-Log-Add-filter/m-p/182383#M144549</link>
    <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/19411/liuruibnu.html" nodeid="19411"&gt;@Rachel Rui Liu&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;This  can perform this with two solutions.&lt;/P&gt;&lt;P&gt;1.  Using the log back filter mechanism,&lt;/P&gt;&lt;P style="margin-left: 40px;"&gt;For
the Audit logs which has forbidden access -&amp;gt; you can see “result”:1 in the
response.&lt;/P&gt;&lt;P style="margin-left: 40px;"&gt;Which
mean we can configure the log back settings in nifi properties (where as log4j
in kafka ).&lt;/P&gt;&lt;P style="margin-left: 40px;"&gt;Here
I am giving the code snippet for the same ( may need to modify accordingly)&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;filter
class="ch.qos.logback.core.filter.EvaluatorFilter"&amp;gt;  &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;evaluator&amp;gt; &amp;lt;!-- defaults to
type ch.qos.logback.classic.boolex.JaninoEventEvaluator --&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;expression&amp;gt;return
message.contains('"result":1');&amp;lt;/expression&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/evaluator&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;OnMismatch&amp;gt;DENY&amp;lt;/OnMismatch&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;OnMatch&amp;gt;NEUTRAL&amp;lt;/OnMatch&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/filter&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 20px;"&gt;so
your nifi-node-logback-env file will have the following snippet&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;appender
name="RANGER_AUDIT"
class="ch.qos.logback.core.rolling.RollingFileAppender"&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;file&amp;gt;${org.apache.nifi.bootstrap.config.log.dir}/ranger_nifi_audit.log&amp;lt;/file&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;fileNamePattern&amp;gt;${org.apache.nifi.bootstrap.config.log.dir}/ranger_nifi_audit_%d{yyyy-MM-dd_HH}.%i.log&amp;lt;/fileNamePattern&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;maxFileSize&amp;gt;100MB&amp;lt;/maxFileSize&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;maxHistory&amp;gt;30&amp;lt;/maxHistory&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/rollingPolicy&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;immediateFlush&amp;gt;true&amp;lt;/immediateFlush&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;filter
class="ch.qos.logback.core.filter.EvaluatorFilter"&amp;gt;  &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;evaluator&amp;gt; &amp;lt;!-- defaults to
type ch.qos.logback.classic.boolex.JaninoEventEvaluator --&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;expression&amp;gt;return
message.contains('"result":1');&amp;lt;/expression&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/evaluator&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;OnMismatch&amp;gt;DENY&amp;lt;/OnMismatch&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;OnMatch&amp;gt;NEUTRAL&amp;lt;/OnMatch&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/filter&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;pattern&amp;gt;%date %level
[%thread] %logger{40} %msg%n&amp;lt;/pattern&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/encoder&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;/appender&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;in case of log4j that would be regular expression filter &lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;RegexFilter regex=".*\"result\" \: 1.*" onMatch="ACCEPT" onMismatch="DENY"/&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;More on This can be found at &lt;A target="_blank" href="https://logging.apache.org/log4j/2.0/manual/filters.html"&gt;log4j&lt;/A&gt; and &lt;A target="_blank" href="https://logback.qos.ch/manual/filters.html"&gt;logback&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2.  Using the out of the box solution
with simple shell script whchi will grep the result:1 lines and remev rest of
all on periodic interval&lt;/P&gt;&lt;P style="margin-left: 60px;"&gt;&lt;STRONG&gt;&lt;EM&gt;sed
'/”result”:1/!d' &amp;lt;logfile&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hope this helps !!&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jan 2018 05:04:47 GMT</pubDate>
    <dc:creator>bkosaraju</dc:creator>
    <dc:date>2018-01-08T05:04:47Z</dc:date>
    <item>
      <title>Ranger Audit Log (Add filter)</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Ranger-Audit-Log-Add-filter/m-p/182382#M144548</link>
      <description>&lt;P&gt;We had a  HDF Cluster with  customized settings to route all the audit log to file system&lt;/P&gt;&lt;P&gt;Long term plan is to feed the logs to central platform, but currently these logs are sitting at remote site, and the normal kafka message reading audit log is filling up  the server disk very quickly.&lt;/P&gt;&lt;PRE&gt;-rw-r--r-- 1 kafka hadoop 20067988960 Jan  3 16:28 ranger_kafka_audit.log 

# see the difference of the size after a few min. (almost 2G in 7 min)
-rw-r--r-- 1 kafka hadoop 18363271828 Jan  3 16:21 ranger_kafka_audit.log
&lt;/PRE&gt;&lt;P&gt;We are looking for a temp solution to only write the audit log with "forbidden" tag to the file.&lt;/P&gt;&lt;P&gt;Does anyone have idea of customize the configuration so that we can control the content to be logged?&lt;/P&gt;&lt;PRE&gt;# Turn on ranger kafka audit log
log4j.appender.RANGER_AUDIT=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RANGER_AUDIT.File=${kafka.logs.dir}/ranger_kafka_audit.log
log4j.appender.RANGER_AUDIT.layout=org.apache.log4j.PatternLayout
log4j.appender.RANGER_AUDIT.layout.ConversionPattern=%m%n
log4j.appender.RANGER_AUDIT.MaxFileSize=100MB
log4j.appender.R.MaxBackupIndex=30
log4j.logger.ranger.audit=INFO,RANGER_AUDIT
&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 10:38:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Ranger-Audit-Log-Add-filter/m-p/182382#M144548</guid>
      <dc:creator>liuruibnu</dc:creator>
      <dc:date>2018-01-05T10:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Ranger Audit Log (Add filter)</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Ranger-Audit-Log-Add-filter/m-p/182383#M144549</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/19411/liuruibnu.html" nodeid="19411"&gt;@Rachel Rui Liu&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;This  can perform this with two solutions.&lt;/P&gt;&lt;P&gt;1.  Using the log back filter mechanism,&lt;/P&gt;&lt;P style="margin-left: 40px;"&gt;For
the Audit logs which has forbidden access -&amp;gt; you can see “result”:1 in the
response.&lt;/P&gt;&lt;P style="margin-left: 40px;"&gt;Which
mean we can configure the log back settings in nifi properties (where as log4j
in kafka ).&lt;/P&gt;&lt;P style="margin-left: 40px;"&gt;Here
I am giving the code snippet for the same ( may need to modify accordingly)&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;filter
class="ch.qos.logback.core.filter.EvaluatorFilter"&amp;gt;  &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;evaluator&amp;gt; &amp;lt;!-- defaults to
type ch.qos.logback.classic.boolex.JaninoEventEvaluator --&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;expression&amp;gt;return
message.contains('"result":1');&amp;lt;/expression&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/evaluator&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;OnMismatch&amp;gt;DENY&amp;lt;/OnMismatch&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;OnMatch&amp;gt;NEUTRAL&amp;lt;/OnMatch&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/filter&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 20px;"&gt;so
your nifi-node-logback-env file will have the following snippet&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;appender
name="RANGER_AUDIT"
class="ch.qos.logback.core.rolling.RollingFileAppender"&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;file&amp;gt;${org.apache.nifi.bootstrap.config.log.dir}/ranger_nifi_audit.log&amp;lt;/file&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;fileNamePattern&amp;gt;${org.apache.nifi.bootstrap.config.log.dir}/ranger_nifi_audit_%d{yyyy-MM-dd_HH}.%i.log&amp;lt;/fileNamePattern&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;maxFileSize&amp;gt;100MB&amp;lt;/maxFileSize&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;maxHistory&amp;gt;30&amp;lt;/maxHistory&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/rollingPolicy&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt; 
&amp;lt;immediateFlush&amp;gt;true&amp;lt;/immediateFlush&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;filter
class="ch.qos.logback.core.filter.EvaluatorFilter"&amp;gt;  &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;evaluator&amp;gt; &amp;lt;!-- defaults to
type ch.qos.logback.classic.boolex.JaninoEventEvaluator --&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;expression&amp;gt;return
message.contains('"result":1');&amp;lt;/expression&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/evaluator&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;OnMismatch&amp;gt;DENY&amp;lt;/OnMismatch&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;OnMatch&amp;gt;NEUTRAL&amp;lt;/OnMatch&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/filter&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;pattern&amp;gt;%date %level
[%thread] %logger{40} %msg%n&amp;lt;/pattern&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;  &amp;lt;/encoder&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;/appender&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;in case of log4j that would be regular expression filter &lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;lt;RegexFilter regex=".*\"result\" \: 1.*" onMatch="ACCEPT" onMismatch="DENY"/&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-left: 80px;"&gt;More on This can be found at &lt;A target="_blank" href="https://logging.apache.org/log4j/2.0/manual/filters.html"&gt;log4j&lt;/A&gt; and &lt;A target="_blank" href="https://logback.qos.ch/manual/filters.html"&gt;logback&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2.  Using the out of the box solution
with simple shell script whchi will grep the result:1 lines and remev rest of
all on periodic interval&lt;/P&gt;&lt;P style="margin-left: 60px;"&gt;&lt;STRONG&gt;&lt;EM&gt;sed
'/”result”:1/!d' &amp;lt;logfile&amp;gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hope this helps !!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 05:04:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Ranger-Audit-Log-Add-filter/m-p/182383#M144549</guid>
      <dc:creator>bkosaraju</dc:creator>
      <dc:date>2018-01-08T05:04:47Z</dc:date>
    </item>
  </channel>
</rss>

