> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloosphere.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Guardrail Logs

> Track sensitive info and content violation events detected and processed by guardrails

<Info>Admin › Monitoring › Guardrail Logs</Info>

Guardrail logs record **all events detected and processed** by guardrails configured on agents.

* Transparently track which user entered which sensitive info and how which guardrail processed it.

<Note>
  The same guardrail logs can also be viewed from [Admin > Code Gateway > Guardrail Logs](/en/admin/code-gateway).
</Note>

<Frame caption="Guardrail Logs main screen — filter area, log table">
  <img src="https://mintcdn.com/cloocus/Nim6rqpdwJuim_F0/images/monitoring/guardrail-logs-settings.png?fit=max&auto=format&n=Nim6rqpdwJuim_F0&q=85&s=c96c63a7bf94bf93d859356ff91d2e36" alt="Guardrail Logs main screen" width="1431" height="931" data-path="images/monitoring/guardrail-logs-settings.png" />
</Frame>

***

## What are Guardrail Logs?

When users converse with the AI, guardrails validate inputs and outputs.

* When sensitive info is detected, the configured strategy (block, redact, mask, etc.) is applied and the result is logged.

```mermaid theme={null}
flowchart LR
    A[User input · AI output] --> B[Guardrail validation]
    B --> C{Detected?}
    C -->|No| D[Process normally]
    C -->|Yes| E[Apply strategy]
    E --> F[Log]
    F --> G[Guardrail Logs]
```

***

## Log Entry Structure

Each guardrail log entry includes:

| Field                 | Description                                     |
| --------------------- | ----------------------------------------------- |
| **Timestamp**         | Detection event time                            |
| **User**              | Input user (name, email)                        |
| **Chat ID**           | Conversation session                            |
| **Message ID**        | Message identifier                              |
| **Guardrail name**    | Applied guardrail                               |
| **Action**            | Processing strategy (block, redact, mask, etc.) |
| **Detection Pattern** | Detection method (Rule-based / LLM-based)       |
| **Detection Detail**  | Specific detected content                       |
| **Original content**  | Original input text                             |
| **Processed Content** | Text after strategy applied                     |

***

## Action Types

| Action     | Description                                                  |
| ---------- | ------------------------------------------------------------ |
| **block**  | Block entire message                                         |
| **redact** | Replace sensitive info with label (e.g., `[REDACTED_EMAIL]`) |
| **mask**   | Show only some characters (e.g., `j***@***.com`)             |
| **hash**   | Convert to hash value                                        |
| **log**    | Log only without blocking                                    |

## Detection Pattern

Detection methods are grouped into two categories.

| Group          | Sources                             | Description                       |
| -------------- | ----------------------------------- | --------------------------------- |
| **Rule-based** | pii, custom\_pattern, blocked\_word | Regex/pattern-based detection     |
| **LLM-based**  | llm\_judge                          | LLM-based content risk assessment |

Individual source meanings:

| Source              | Description                                                |
| ------------------- | ---------------------------------------------------------- |
| **pii**             | Detect PII patterns (email, credit card, IP address, etc.) |
| **custom\_pattern** | Detect user-defined regex patterns                         |
| **blocked\_word**   | Detect prohibited words/phrases                            |
| **llm\_judge**      | LLM-based content risk assessment                          |

***

## Filter Options

| Filter                | Description                                   |
| --------------------- | --------------------------------------------- |
| **Time range**        | Start/end date range                          |
| **Action**            | block, redact, mask, hash, log (multi-select) |
| **Detection Pattern** | Rule-based / LLM-based group selection        |
| **User search**       | Search by user ID, email, or name             |
| **Chat ID**           | Logs for a specific chat session only         |
| **Source**            | Request origin filter (e.g., `code_gateway`)  |

***

## Log Detail View

Click a log entry to see details.

<Frame caption="Guardrail log detail modal — detection info, original content, and the Trace button at the bottom-right">
  <img src="https://mintcdn.com/cloocus/iRgCRr3H3czOaMhv/images/monitoring/guardrail-logs-detail.png?fit=max&auto=format&n=iRgCRr3H3czOaMhv&q=85&s=4f848867c2dc187652919666d84f717a" alt="Guardrail log detail modal — action, detection source, detection detail, original content, and Trace button" width="832" height="415" data-path="images/monitoring/guardrail-logs-detail.png" />
</Frame>

<Tabs>
  <Tab title="Detection Details">
    | Item                  | Description                                                             |
    | --------------------- | ----------------------------------------------------------------------- |
    | **Guardrail**         | Applied guardrail name and ID                                           |
    | **Detection Pattern** | Rule-based (PII, custom pattern, blocked word) or LLM-based (LLM Judge) |
    | **Detection Detail**  | Specific detected pattern or item                                       |
    | **Original content**  | User-entered original                                                   |
    | **Processed Content** | Result after strategy applied                                           |
  </Tab>

  <Tab title="Context">
    | Item           | Description                       |
    | -------------- | --------------------------------- |
    | **User**       | Name, email                       |
    | **Chat ID**    | Conversation session identifier   |
    | **Message ID** | Message identifier                |
    | **Metadata**   | Additional context (source, etc.) |
  </Tab>
</Tabs>

***

## Tracing Integration

In guardrail log details, the **Trace** button lets you see the complete processing of that message.

<Steps>
  <Step title="Pick an entry in Guardrail Logs">
    Click the log entry for the guardrail event you're investigating.
  </Step>

  <Step title="Click Trace">
    Click the **Trace** button at the bottom-right of the detail modal.
  </Step>

  <Step title="View full processing">
    The **Trace Detail** screen opens, showing the full Run tree — including the guardrail check for that message. Guardrail Runs are shown with red **GD** badges.

    <Frame caption="Trace Detail — guardrail steps (GD badges) in the left Run tree and per-step input/output on the right">
      <img src="https://mintcdn.com/cloocus/iRgCRr3H3czOaMhv/images/monitoring/guardrail-logs-trace.png?fit=max&auto=format&n=iRgCRr3H3czOaMhv&q=85&s=05515e2f4c827eb6382d6d10cce2b8a4" alt="Trace Detail modal — Run tree with guardrail:pii and test-guardrail GD badges, embedding input/output on the right" width="1332" height="956" data-path="images/monitoring/guardrail-logs-trace.png" />
    </Frame>
  </Step>
</Steps>

***

## Use Cases

<Accordion title="Guardrail Policy Tuning">
  1. Set a time range and view logs by **Detection Pattern**
  2. Review `log` action events to gauge false positive rate
  3. Adjust regex or exclude patterns with many false positives
  4. Add new patterns or blocked words for missed detections
</Accordion>

<Accordion title="Security Incident Response">
  1. Look up a specific user's guardrail events via user search
  2. Check repeated `block` patterns
  3. Review original content to determine intentional sensitive info leak attempts
  4. Cross-analyze with related audit logs for full context
</Accordion>

<Accordion title="LLM Judge Effectiveness Analysis">
  1. Filter **Detection Pattern** to `LLM-based`
  2. Review original content of blocked messages
  3. If excessive blocking, strengthen allow examples in the Judge prompt
  4. If missing blocks, add block examples
</Accordion>

***

## Guardrail Settings Integration

Improve guardrail settings based on patterns found in guardrail logs.

| Log Analysis Finding                  | Recommended Action                                    |
| ------------------------------------- | ----------------------------------------------------- |
| Specific PII type detected frequently | Strengthen that type's strategy from `log` → `redact` |
| Frequent false positives              | Narrow custom pattern regex                           |
| LLM Judge over-blocking               | Add allow examples to Judge prompt                    |
| New sensitive info pattern found      | Add regex via custom pattern                          |

<Note>
  See [Guardrails](/en/workspace/guardrails) for guardrail configuration.
</Note>
