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

# Defining Monitors

> Learn how to create and configure monitors to evaluate your LLM outputs

Monitors in Traceloop allow you to continuously evaluate your LLM outputs in real time. This guide walks you through the process of creating and configuring monitors for your specific use cases.

## Creating a Monitor

To create a monitor, you need to complete these steps:

<Steps>
  <Step title="Send Traces">
    Connect the SDK to your system and add decorators to your flow. See [OpenLLMetry](/openllmetry/introduction) for setup instructions.
  </Step>

  <Step title="Choose an Evaluator">
    Select the evaluation logic that will run on matching spans. You can define your own custom evaluators or use the pre-built ones by Traceloop. See [Evaluators](/evaluators/intro) for more details.
  </Step>

  <Step title="Define Span Filter">
    Set criteria that determine which spans the monitor will evaluate.
  </Step>

  <Step title="Configure Settings">
    Set up how the monitor operates, including sampling rates and other advanced options.
  </Step>
</Steps>

### Basic Monitor Setup

Navigate to the Monitors page and click the **New** button to open the Evaluator Library. Choose the evaluator you want to run in your monitor.
Next, you will be able to configure which spans will be monitored.

## Span Filtering

The span filtering modal shows the actual spans from your system, letting you see how your chosen filters apply to real data.
Add filters by clicking on the  <kbd>+</kbd>  button.

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/enrolla/f92M4jgLiPyzhzrI/img/monitor/monitor-filter-light.png?fit=max&auto=format&n=f92M4jgLiPyzhzrI&q=85&s=e882a9b6eb5ca662b5770f2c26fbebc5" width="2392" height="1406" data-path="img/monitor/monitor-filter-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/enrolla/f92M4jgLiPyzhzrI/img/monitor/monitor-filter-dark.png?fit=max&auto=format&n=f92M4jgLiPyzhzrI&q=85&s=5d7f6d15f3cc60cc9d4ded8660b4b3e5" width="2402" height="1408" data-path="img/monitor/monitor-filter-dark.png" />
</Frame>

### Filter Options

* **Environment**: Filter by a specific environment
* **Workflow Name**: Filter by the workflow name defined in your system
* **Service Name**: Target spans from specific services or applications
* **AI Data**: Filter based on LLM-specific attributes like model name, token usage, streaming status, and other AI-related metadata
* **Attributes**: Filter based on span attributes

<img className="block dark:hidden" src="https://mintcdn.com/enrolla/f92M4jgLiPyzhzrI/img/monitor/monitor-filter-options-light.png?fit=max&auto=format&n=f92M4jgLiPyzhzrI&q=85&s=7b9f0c7fa861ee4237a5b930079de105" style={{maxWidth: '500px'}} width="970" height="916" data-path="img/monitor/monitor-filter-options-light.png" />

<img className="hidden dark:block" src="https://mintcdn.com/enrolla/f92M4jgLiPyzhzrI/img/monitor/monitor-filter-options-dark.png?fit=max&auto=format&n=f92M4jgLiPyzhzrI&q=85&s=f43bbc0f8be5a83e76011f1c2acdbe4d" style={{maxWidth: '500px'}} width="964" height="922" data-path="img/monitor/monitor-filter-options-dark.png" />

## Monitor Settings

### Map Input

You need to map the appropriate span fields to the evaluator’s input schema.
This can be done easily by browsing through the available span field options—once you select a field, the real data is immediately displayed so you can see how it maps to the input.

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/enrolla/UIxmLWs2sJDl37WW/img/monitor/monitor-settings-light.png?fit=max&auto=format&n=UIxmLWs2sJDl37WW&q=85&s=32a441ef62772a8f23528fa2a8762153" width="2388" height="1390" data-path="img/monitor/monitor-settings-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/enrolla/UIxmLWs2sJDl37WW/img/monitor/monitor-settings-dark.png?fit=max&auto=format&n=UIxmLWs2sJDl37WW&q=85&s=ced02fcf7efcb0d7e00fdf5d0ffb2f7e" width="2402" height="1406" data-path="img/monitor/monitor-settings-dark.png" />
</Frame>

When the field data is not plain text, you can use JSON key mapping or Regex to extract the specific content you need.

For example, if your content is an array and you want to extract the "text" field from the object:

```json theme={null}
[{"type":"text","text":"explain who are you and what can you do in one sentence"}]
```

You can use JSON key mapping like `0.text` to extract just the text content. The JSON key mapping will be applied to the Preview table, allowing you to see the extracted result in real-time.

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/enrolla/f92M4jgLiPyzhzrI/img/monitor/monitor-json-light.png?fit=max&auto=format&n=f92M4jgLiPyzhzrI&q=85&s=41f7fd4b8d5e4a353d0c9e6e13857aee" width="2380" height="1404" data-path="img/monitor/monitor-json-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/enrolla/f92M4jgLiPyzhzrI/img/monitor/monitor-json-dark.png?fit=max&auto=format&n=f92M4jgLiPyzhzrI&q=85&s=d744d896c0d932044a6e298c0138db3c" width="2390" height="1398" data-path="img/monitor/monitor-json-dark.png" />
</Frame>

You can use Regex like `text":"(.+?)"` to extract just the text content. The regex will be applied to the Preview table, allowing you to see the extracted result in real-time.

<Frame>
  <img className="block dark:hidden" src="https://mintcdn.com/enrolla/UIxmLWs2sJDl37WW/img/monitor/monitor-regex-light.png?fit=max&auto=format&n=UIxmLWs2sJDl37WW&q=85&s=28cab1fcf3466cd3507b42757e8d4051" width="2386" height="1390" data-path="img/monitor/monitor-regex-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/enrolla/UIxmLWs2sJDl37WW/img/monitor/monitor-regex-dark.png?fit=max&auto=format&n=UIxmLWs2sJDl37WW&q=85&s=cf8eb05558708aaa81d9a8eac34b16ff" width="2392" height="1396" data-path="img/monitor/monitor-regex-dark.png" />
</Frame>

### Advanced

You can set a **Rate sample** to control the percentage of spans within the selected filter group that the monitor will run on.
