Objective
Publish all audit logs for changes done to CDAP entities so that other apps/tools like Cask Tracker, MDM, etc can use this as a source for audit information.
For 3.4 release, we'll limit the scope to publishing changes for Datasets and Streams.
Use Cases
Use cases and user stories are documented at Cask Tracker (formerly Cask Finder).
Design Choices
We chose Kafka to be the system where audit information gets published from CDAP. Other tools can subscribe to the Kafka feed to get audit information. Using Kakfa could make integrating external tools with CDAP easier.
However, publishing to Kafka has certain drawbacks limitations today that will need to be addressed later -
- Kafka publish does not happen in a transaction, so there is a chance that the audit log feed from Kafka may be inconsistent compared to what actually happened. CDAP-5109 has more discussion on it.
- There is no access control on who can publish audit information to Kafka (CDAP-5130).
- Messages in Kafka are transient. They will be deleted after a few days in most setups. The subscribers will have to consume the messages before they are deleted.
Audit Message Format
Audit feed will be a stream of audit messages as defined below.
Types of Audit Message
The following types of audit messages are published for an entity -
- CREATE
- UPDATE
- TRUNCATE
- DELETE
- ACCESS (sub types: READ, WRITE, BOTH, UNKNOWN)
- METADATA_CHANGE
Code Block |
---|
[ /** Dataset access operation **/ { "time": 14569566594691456956659468, "entityId": { "namespace": "ns1", "datasetstream": "ds1stream1", "entity": "DATASETSTREAM" }, "user": "cdapuser1", "type": "METADATA_CHANGEACCESS", "changepayload": { "additionsaccessType": ["WRITE", "accessor": { "scopenamespace": "USERns1", "propertiesapplication": {"app1", "type": "Flow", "key1program": "value1flow1", }, "run": "run1", "tagsentity": ["PROGRAM_RUN" } } "tag1" }, /** Explore stream ]access **/ { } "time": 1456956659469, ],"entityId": { "deletionsnamespace": ["ns1", "stream": "stream1", { "entity": "STREAM" "scope }, "user": "SYSTEMuser1", "type": "ACCESS", "propertiespayload": {}, "accessType": "UNKNOWN", "tags": [ "accessor": { "tag2service": "explore", ]"entity": "SYSTEM_SERVICE" } } } }, ] }/** Metadata change },**/ { "time": 1456956659470, "entityId": { "namespace": "ns1", "datasetapplication": "ds1app1", "entity": "DATASETAPPLICATION" }, "user": "cdapuser1", "type": "METADATA_CHANGE", "CREATEpayload": { }, "previous": { "timeUSER": 1456956659471, { "entityIdproperties": { "namespace "uk": "ns1uv", "datasetuk1": "ds1",uv2" }, "entitytags": [ "DATASET "ut1", "ut2" ] }, "SYSTEM": { "user": "cdap""properties": { "sk": "sv" }, "tags": [] } }, "typeadditions": { "ACCESS", "SYSTEM": { "accessproperties": { "sk": "type": "READ","sv" }, "tags": [ "t1", "entityId"t2" ] } }, "deletions": { "namespaceUSER": { "ns1",properties": { "applicationuk": "app1"uv" }, "typetags": [ "Flow", "ut1" ] } } } }, /** Dataset admin operation **/ { "time": 1456956659471, "entityId": { "programnamespace": "flow1ns1", "dataset": "ds1", "entity": "PROGRAM" "DATASET" }, "user": "user1", }"type": "CREATE", "payload": {} } ] |
...
Implementation
The Audit log information will be published to CDAP Kafka server when `audit.publish.enabled` config parameter is set to true.
- Dataset admin operations can be published by DatasetOpExecutor service.
- Stream admin operations can be published by StreamAdmin class
- Dataset and stream access information can be published by piggy backing on lineage capturing code.
- Metadata changes can be published by DefaultMetadataStore class.
Note: Publishing of metadata updates to Kafka introduced by CDAP-3518 for Navigator integration will be deprecated in 3.4 and removed in 3.5. We will need to move Navigator app to use audit log instead of metadata change updates.