# Splunk

The content type use most often for a Splunk integration is **Alert**. You may be able to use some of the other content types when you have Splunk set up as a Data Source.

We use the following endpoint to export Aisera Alerts (Events):

```
curl --location --request POST 'https://localhost:8089/services/search/v2/jobs/export' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic c3B....' \
--data-urlencode 'search=search * | head 100' \
--data-urlencode 'output_mode=xml'
```

## Integration Configuration <a href="#integration-configuration" id="integration-configuration"></a>

To create a new Splunk integration:

1. Choose **Settings > Integration** in the Aisera Admin UI.
2. Click the **+ New Integration** button.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F2cSHpw47GvvrZECSGAkW%2Fnew_integ_splunk.png?alt=media&#x26;token=690efb5c-c8fa-4784-a3c4-a8d9f9a5a9b4" alt="" width="375"><figcaption><p>Choose the Splunk Icon</p></figcaption></figure></div>

3. Select the Splunk icon.
4. Add a **Name** for the integration and type in the endpoint URL.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FMWHgbmdL2rIm5AKV8GPK%2Fsplunk2.png?alt=media&#x26;token=92086a94-084f-4b57-ab8a-fec7449c3160" alt="" width="563"><figcaption><p>Add the Integration Name and Endpoint</p></figcaption></figure></div>

5. The Splunk integration supports **Basic** authorization. Provide a username and password. \
   The port information is required, but will not be used. You can type any number is the Port field.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FiHFOrU15rdYBMwyNAo63%2Fsplunk3.png?alt=media&#x26;token=a6d63766-87d2-4cbb-b624-5c767c82ac8f" alt="" width="563"><figcaption><p>Choose the Auth Type and Add Basic Auth Information</p></figcaption></figure></div>

## Data Source Configuration

To create the Splunk Data Source:

1. Select **Settings > Data Source** in the Aisera Admin UI.
2. Click the **+ New Data Source** button.&#x20;
3. Search for Splunk.
4. Choose the Splunk icon.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FxhxibfXHL05UOcArYxT9%2Fsplunk_ds1.png?alt=media&#x26;token=27ea2891-1118-418a-8aac-c3dd60cc235f" alt="" width="375"><figcaption><p>Choose the Splunk Icon</p></figcaption></figure></div>

5. Give the data source a **Name**, select the Source **Type** (Upstream or Downstream), choose the name of the **Integration** you just created (in the previous steps), and set the **Schedule** configuration.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FidqiknqkHr93MU1MaEt6%2Fsplunk_ds3.png?alt=media&#x26;token=14e0cfab-2d06-41c5-a71a-4484cbe9f21d" alt="" width="563"><figcaption><p>Choose the Type, Integration, and Schedule</p></figcaption></figure></div>

6. Click **Next**.
7. Don't enter any values on the **Search Query** page in the **Configuration** tab.  The Search Query on this page is ignored.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FgtEC3H6ywLpqoZNYlunE%2Finteg_ds5.png?alt=media&#x26;token=79ac11a2-c318-465f-8a8d-5b0dd0aa6f86" alt="" width="563"><figcaption><p>Ignore the Configuration Tab Variables</p></figcaption></figure></div>

8. Click **OK**.
9. Provide the actual **Port Number** and the **Search Query** as an override configuration.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FFGQUBC6wgGeUbfeudKC7%2Finteg_ds6.png?alt=media&#x26;token=8c7a96f7-f171-4a3a-a821-5cbfd5cfe782" alt="" width="563"><figcaption><p>Override Parameters</p></figcaption></figure></div>

&#x20;The example in the screenshot above is:

```
{
  "contextParameters": {
    "port": "8089",
    "search_query":"search * | head 100"
  }
}
```

One easy option to fetch the last 100 events is:

```
search * | head 100
```

You can find the official Splunk documentation on SPL2 (the query language that Splunk uses) at the following link: [**SPL2 Command Quick Reference**](https://help.splunk.com/en/splunk-cloud-platform/search/spl2-search-reference/quick-reference-for-spl2-commands/spl2-command-quick-reference)

### **Field Maps**

The field maps for **Splunk Data Sources** may need to be manually configured, depending on the schema of the **Splunk Alerts**. Look at the [**Field Mapping**](https://docs.aisera.com/aisera-platform/data-ingestion#field-mapping) on the Data Sources page after the Alerts data has been ingested.
