> For the complete documentation index, see [llms.txt](https://docs.dsyncstudios.store/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dsyncstudios.store/products/dsync-banking/integrations/audit-logging-datadog-discord.md).

# Audit Logging (Datadog / Discord)

## Audit Logging (Datadog / Discord)

Every banking action ships to a structured, filterable log the moment it happens. This is not optional bookkeeping bolted on after the fact — it is the same choke point every ledger mutation in the resource passes through, so nothing can move money without being logged.

### Categories

Each log carries a category so you can filter by action type:

```
Banking-Deposit        Banking-Withdrawal      Banking-Transfer
Banking-Savings        Banking-Society         Banking-Shared
Banking-Loan           Banking-Bill            Banking-Card
Banking-Account        Banking-Request         Banking-Scheduled
Banking-GiveCash       Banking-External        Banking-System
```

### Choosing a driver

Set `Config.logging.driver` to `'datadog'` or `'webhook'`.

#### Datadog

Uses ox\_lib's built-in batched logger — the exact same pipeline most ox-ecosystem resources (e.g. ox\_inventory) already use. If your server already ships inventory logs to Datadog, no additional setup is required here. Otherwise, add to `server.cfg`:

```cfg
set ox:logger "datadog"
set datadog:key "YOUR_DD_API_KEY"
set datadog:site "datadoghq.com"     # or datadoghq.eu, us5.datadoghq.com, etc.
```

Filter in the Datadog Logs explorer with:

```
service:Dsync-Banking event:Banking-Deposit
```

The JSON message body is auto-parsed by Datadog, so every field — `@amount`, `@amount_cents`, `@account`, `@issuer`, `@receiver`, `@balance_after` — becomes an independently queryable facet. This means you can build alerts like "any single withdrawal over $50,000" or "more than 10 failed PIN attempts from one account" directly on structured fields, without string-parsing a log line.

#### Discord webhooks

Batched embeds (up to 10 per POST, flushed on an interval) so a burst of activity can't trip Discord's rate limits.

```lua
logging = {
    driver = 'webhook',
    webhook = {
        flushInterval = 5000,
        default = 'https://discord.com/api/webhooks/...',
        categories = {
            -- Route specific categories to a different channel:
            ['Banking-Withdrawal'] = 'https://discord.com/api/webhooks/.../withdrawals',
            ['Banking-Loan']       = 'https://discord.com/api/webhooks/.../loans',
        },
    },
},
```

Any category without a specific entry in `categories` falls back to `default`. All pending embeds are flushed on resource stop, so a restart never silently drops queued logs.

### Silencing noisy categories

```lua
logging = {
    exclude = { 'Banking-Interest', 'Banking-System' },
},
```

Categories listed here are dropped before they ever reach the configured driver — useful for high-frequency, low-signal events like daily savings interest postings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.dsyncstudios.store/products/dsync-banking/integrations/audit-logging-datadog-discord.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
