# Papertrail

This data source connector uses the Papertrail [Search API](https://help.papertrailapp.com/kb/how-it-works/search-api)
to import events matching the specified query from [Papertrail](https://www.papertrail.com/) 
(logs from apps, servers, and cloud services).

**Before you start**

You need:

- **A Papertrail API token (https://help.papertrailapp.com/kb/how-it-works/http-api#authentication).** You find it in your profile (https://papertrailapp.com/account/profile).

What each tab needs:

- **Prompt tab:** Kai, the **Kai Agent** button in the top bar, on supported stacks. A new Free Plan project has it from the start; elsewhere an organization admin turns it on once: Get started with Kai (/kai/getting-started/).
- **UI tab:** a browser.
- **CLI / API tab:** kbagent (/cli/getting-started/), connected to your project. The checks only read.

## Configuration
[Create a new configuration](https://help.keboola.com/components/configurations/#create-a-configuration) of the **Papertrail** connector.

To configure the connector, you need to provide a Papertrail API token, enter a search query and select a retention period.
Then select the data you wish to extract.

First, provide your Papertrail API token.

Then enter your [search query](https://help.papertrailapp.com/kb/how-it-works/search-syntax/#quick-reference). 
And finally, select a desired **retention period** from the dropdown menu (from 1 day to 1 month).

To configure what data you want to extract, select the configuration template. The only template available at the moment is **Basic**. 
This option downloads all records matching the query within the retention period. It incrementally adds new records each run.

![Screenshot - Papertrail configuration](https://help.keboola.com/components/extractors/other/papertrail/papertrail-1.png)

When done, **Save** the configuration.
You can also [switch to the JSON editor](https://help.keboola.com/components/extractors/generic-extractor/#template-mode).

**Important:** Data is always imported incrementally.

Click **Run Component**.

**Check:**

### Prompt

```text title="Prompt" wrap
Did the latest job of my Papertrail configuration succeed, and did it load the events table? Give its row count.
```

Kai only reads here, so it asks for no approval, and its answer links to what it found in your project.

### UI

The job ends with status **Success** and Storage has the `events` table with the events your query
matches.

### CLI / API

```bash
kbagent job list --component-id keboola.ex-papertrail --config-id 123456789 --limit 1
kbagent storage tables
```

Replace `123456789` with your configuration ID: `status` shows whether the job succeeded, and the tables it loaded have the latest `last_import_date`, with their rows in `rows_count`.

---
