Skip to content
Audit & ReportsMarkdown

Get started with Audit & Reports

Read everything that happened for one user and for one agent on the realm's audit trail, with every call.

AvailableAPI

In this walkthrough you read the audit trail of the user maya in the realm foobar: her sign-ins, the tokens issued to her apps, and what agents did in her name. Then you read the trail of the agent invoice-agent: every token it was issued or refused, every exchange it made, and every change to its record.

  • You hold READ on the realm foobar: RealmOwner includes it, and RealmViewer gives it with no right to change anything. To give an auditor that access, see Give an auditor read-only access.
  • You are signed in with your session in $CVYUH_SESSION: Call the API shows how. Everything here is done in the API.
  • The trail names each principal by its id, the id the realm gave it when it was made, not the name you address it by. The first step of each part looks it up.
  1. Look up the user’s id. Read maya and note her id:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/am/objects/v1/user/maya \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
    {
    "id": "<maya's id>",
    "objectId": "maya",
    "typeName": "user",
    "rev": 4,
    "attributes": { "…": "…" }
    }
  2. Read her trail. Name her with person:

    Terminal window
    curl "https://foobar.cvyuh.com/api/v0/am/audit/v1/trail?person=<maya's id>&pageSize=20" \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
    {
    "principal": "<maya's id>",
    "kind": "person",
    "events": {
    "data": [
    { "eventType": "TOKEN_ISSUED", "result": "SUCCESSFUL", "…": "…" },
    { "eventType": "LOGIN", "result": "SUCCESSFUL", "…": "…" }
    ],
    "page": 1,
    "pageSize": 20,
    "totalCount": 37,
    "totalPages": 2
    },
    "changes": { "data": [], "…": "…" }
    }

    events are newest first by eventTime. Each says what happened (eventType), when, how it went (result), who acted (principals), its context and, for a sign-in, each step in entries. A full LOGIN record looks like this:

    {
    "id": "<record id>",
    "eventType": "LOGIN",
    "eventTime": "<event time>",
    "result": "SUCCESSFUL",
    "userId": "<maya's id>",
    "principals": ["maya"],
    "context": {
    "authLevel": 0, "maxSessionSecs": 7200, "maxIdleSecs": 1800, "name": "maya"
    },
    "entries": [
    { "position": 0, "moduleId": "nativeStore", "result": "succeeded",
    "info": { "authControlFlag": "REQUIRED", "authLevel": 0,
    "ipAddress": "203.0.113.24", "moduleClass": "NativeStore" } }
    ],
    "trackingIds": {
    "sessionName": "<session name>", "sid": "<sign-in id>",
    "authId": "<sign-in attempt id>", "ctxId": "<session context id>"
    },
    "traceId": "<trace id>",
    "spanId": "<span id>",
    "parentSpanId": null,
    "transactionId": "<transaction id>",
    "component": "authentication",
    "realm": "<your realm>"
    }

    Its trackingIds.sid is the same as the sid on every TOKEN_ISSUED record that sign-in led to: see Record fields and examples.

  3. Look up the agent’s id. Read invoice-agent and note its id:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/am/objects/v1/agent/invoice-agent \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
  4. Read the agent’s trail. Name it with agent:

    Terminal window
    curl "https://foobar.cvyuh.com/api/v0/am/audit/v1/trail?agent=<invoice-agent's id>" \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

    The answer has the same shape, with "kind": "agent". events holds every token the agent was issued or refused, every exchange it made with the chain of agents behind it, and every policy decision it was in.

  5. Read the changes to the agent’s record. A quarantine or a change of status is in its change history, with the values before and after:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/am/objects/v1/agent/invoice-agent/history \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

    The trail’s own changes part comes back empty today.

  • events.totalCount says how many records there are in all; ask for the next page with page=2.

  • Sign in as maya and read your own trail with no id to know:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/am/audit/v1/trail/me \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"