Uploaded image for project: 'Ranger'
  1. Ranger
  2. RANGER-4024

Adding requestId as part of Ranger logs via RangerMDCFilter when the request header contains request-Id

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.3.0
    • 3.0.0, 2.4.0
    • Ranger
    • Patch

    Description

      In Ranger, we do not have the correlation Id which needs to be stored in the logs whenever we get the requestId header from the caller microservice 
      Proposal:
      RangerMDCFilter will capture the  correlation Id which needs to be stored in the logs whenever we get the requestId header from the caller microservice 
      This RangerMDCFilter can be enabled in the web.xml and logging ConversionPattern  
       

      <filter>
      <filter-name>RangerMDCFilter</filter-name>
      <filter-class&amp;amp;gt;org.apache.ranger.security.web.filter.RangerMDCFilter</filter-class&amp;amp;gt;
      </filter>
      
      <filter-mapping>
      <filter-name>RangerMDCFilter</filter-name>
      <url-pattern>/service/*</url-pattern>
      </filter-mapping>

       
      and to change the conversion pattern to something like this, using the %X{} placeholder for each entry contained in the MDC we want to be logged:

      Example:

        <appender name="xa_log_appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
          <!--See http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
          <!--and http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy-->
          <!--for further documentation-->
          <file>${logdir}/ranger-admin-${hostname}-${user}.log</file>
          <append>true</append>
          <encoder>
            <pattern>%date [%thread] %level{5} [%file:%line] [requestId=%X{REQUEST_ID}] %msg%n</pattern>
          </encoder>
          <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${logdir}/ranger-admin-${hostname}-${user}.log.%d{yyyy-MM-dd}</fileNamePattern>
            <maxHistory>15</maxHistory>
            <cleanHistoryOnStart>true</cleanHistoryOnStart>
          </rollingPolicy>
        </appender>

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            ramackri Ramachandran Krishnan
            ramackri Ramachandran Krishnan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment