Audit User Transactions

Audit User Transactions
calac41
API Server writes all transactions first to MongoDB. You can also have API Server write the transaction details to MongoDB after persistence to the 
userTxAudit
 admin database. The REST requests record the old and new value for change at nest level 0. Nest level 0 is the starting point. 
CA Live API Creator
stores transactions in a summary that touch other tables (cascaded updates or inserts).
The following occurs:
  1. CA Live API Creator
     posts the batch insert and records a transaction for the insert.
  2. API Server starts.
  3. A background thread starts. API Server uses this background thread to write to the MongoDB table every few seconds.
  4. API Server looks for the 
    _USER_TX_AUDIT_
     MongoDB resource. The server must respond for API Server to write to MongoDB again.
In this article:
Verify the Prerequisite
Before you can set up MongoDB, verify that you have enabled tracking and persistence of audit logs for all PUT, POST, and DELETE transactions written to the 
userTxAudit
 admin database (you have selected the 
Audit User Transactions
 checkbox that is on the API Properties 
Settings
 tab).
For more information about this API setting, see API Properties.
Create the MongoDB Resource
Create a 
_USER_TX_AUDIT_
 MongoDB resource that points to the MongoDB server, database, and collection that hold the audit user transaction summaries.
You can filter out Read requests.
Follow these steps:
  1. From the Create section, click 
    Resources
    .
  2. Above the Resource list, click 
    New Resource
    .
    The Add Resource window opens.
  3. Complete the following fields, and then click 
    Add
    :
    Resource Type
    Select 
    MongoDB Resource
    .
    Resource Name
    Enter 
    _USER_TX_AUDIT_
    .
  4. Complete the following fields, and then click
    Save
    :
    Is a collection
    Leave this checkbox selected.
    Mongo server
    (If you are using the single-user demonstration package of
    CA Live API Creator
     that is based on Derby) Enter 
    localhost
    .
    Mongo database name
    Enter 
    Audit
    .
    Mongo collection name
    Enter 
    userTxAudit
    .
    Filter
    Enter 
    {actionType: { $ne: 'R'}}
    .
The 
_USER_TX_AUDIT_
 MongoDB resource is created. 
Restart API Server
Restart API Server to take effect of the new MongoDB resource.
Test the MongoDB Resource in the REST LAB
The following image shows an example of testing the MongoDB resource for the
Demo
API in the REST Lab: