Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The format can be modified by extending org.apache.log4j.Layout and using it in place of org.apache.hadoop.gateway.audit.log4j.layout.AuditLayout in log4j.appender.auditfile.layout property in KNOX/conf/gateway-log4j.properties

 

 

Component

Description

EVENT_PUBLISHING_TIME

Time when audit record was published.

ROOT_REQUEST_ID

The root request ID if this is a sub-request. Currently it is empty.

PARENT_REQUEST_ID

The parent request ID if this is a sub-request. Currently it is empty.

REQUEST_ID

A unique value representing the current, active request. If the current request id value is different from the current parent request id value then the current request id value is moved to the parent request id before it is replaced by the provided request id. If the root request id is not set it will be set with the first non-null value of either the parent request id or the passed request id.

LOGGER_NAME

The name of the logger

TARGET_SERVICE_NAME

Name of Hadoop service. Can be empty if audit record is not linked to any Hadoop service, for example, audit record for topology deployment.

USER_NAME

Name of user that initiated session with Knox

PROXY_USER_NAME

Mapped user name.

SYSTEM_USER_NAME

Currently is empty.

ACTION

Type of action that was executed. Following actions are defined: authentication, authorization, redeploy, deploy, undeploy, identity-mapping, dispatch, access.

RESOURCE_TYPE

Type of resource for which action was executed. Following resource types are defined: uri, topology, principal.

RESOURCE_NAME

Name of resource. For resource of type topology it is name of topology. For resource of type uri it is inbound or dispatch request path. For resource of type principal it is a name of mapped user.

OUTCOME

Action result type. Following outcomes are defined: success, failure, unavailable.

LOGGING_MESSAGE

Logging message. Contains additional tracking information.

 

Sample log events with DEBUG level logging,

// TODO

 

Sending Audit Messages to Kafka

Using the KafkaLog4jAppender, the gateway-audit.log messages for Knox can be send directly to Kafka with the following configurations,

 

Code Block
title$KNOX_HOME/conf/gateway-log4j.properties
# add KAFKA appender to the audit logger
log4j.logger.audit=INFO, auditfile, KAFKA

# kafka log4j appender configuration
log4j.appender.KAFKA_KNOX_AUDIT_LOG=kafka.producer.KafkaLog4jAppender
log4j.appender.KAFKA_KNOX_AUDIT_LOG.layout=org.apache.hadoop.gateway.audit.log4j.layout.AuditLayout
log4j.appender.KAFKA_KNOX_AUDIT_LOG.BrokerList=<HOST>:<PORT> # default port - 6667
log4j.appender.KAFKA_KNOX_AUDIT_LOG.Topic=knox_audit_log
log4j.appender.KAFKA_KNOX_AUDIT_LOG.Serializer=kafka.test.AppenderStringSerializer
log4j.appender.KAFKA_KNOX_AUDIT_LOG.compressionType=none
log4j.appender.KAFKA_KNOX_AUDIT_LOG.requiredNumAcks=0
log4j.appender.KAFKA_KNOX_AUDIT_LOG.syncSend=true

 

Following dependencies are required,

  1. kafka-<version>.jar
  2. kafka-clients-<version>.jar
  3. scala-library-<version>.jar

 

References

Apache Knox User Guide