> For the complete documentation index, see [llms.txt](https://support.attackforge.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.attackforge.com/app/getting-started/configuring-splunk-integration.md).

# Configuring Splunk Integration

## AttackForge configuration

1. Create a dedicated service user for Splunk.

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FOB4Zfa5EV5wK7ircrEAs%2FScreenshot%202026-09-02%20at%201.43.49%E2%80%AFpm.png?alt=media&amp;token=cdf228d3-6e33-4bb4-8a0d-1e870c81809c" alt=""><figcaption></figcaption></figure>

2. Grant API access explicitly: `Users > (select user) > Access > Self-Service RESTful API > Add Access`. Grant `GetApplicationAuditLogs`.

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FAGLDFeSg5jqq0jYIbRJM%2FScreenshot%202026-09-02%20at%201.34.25%E2%80%AFpm.png?alt=media&amp;token=2244a620-596d-41db-81b5-7096baf6c97b" alt=""><figcaption></figcaption></figure>

3. Generate that user's API Key under user settings.

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FRCR4dtoTLW6XKjmtiSwz%2FScreenshot%202026-09-02%20at%201.38.01%E2%80%AFpm.png?alt=media&amp;token=aba6f4bf-c810-43c6-8b73-e8caa203b7e8" alt=""><figcaption></figcaption></figure>

4. The key goes in the `X-SSAPI-KEY` header, and all calls must be HTTPS.

## Splunk configuration

1. Create the App Directory Structure

Navigate to your Heavy Forwarder’s app directory and build this structure:

```
$SPLUNK_HOME/etc/apps/attackforge_app/
├── bin/
│   └── af_auditlogs.py
└── default/
    └── inputs.conf
```

2. Write the Script (`bin/af_auditlogs.py`)

```python
#!/usr/bin/env python3
import json, os, sys
import requests

BASE       = os.environ["AF_BASE_URL"]          # https://<tenant>.attackforge.com
API_KEY    = os.environ["AF_SSAPI_KEY"]
LIMIT      = 5000                                # max supported
CHECKPOINT = os.path.join(
    os.environ.get("SPLUNK_DB", "/opt/splunk/var/lib/splunk"),
    "modinputs", "af_auditlogs", "offset.json"
)

def read_offset():
    try:
        with open(CHECKPOINT) as fh:
            return int(json.load(fh)["skip"])
    except (OSError, ValueError, KeyError):
        return 0                                 # first run: start from the beginning

def write_offset(skip):
    os.makedirs(os.path.dirname(CHECKPOINT), exist_ok=True)
    tmp = CHECKPOINT + ".tmp"
    with open(tmp, "w") as fh:
        json.dump({"skip": skip}, fh)
        fh.flush()
        os.fsync(fh.fileno())
    os.replace(tmp, CHECKPOINT)                  # atomic; never leaves a half-written file

def main():
    skip    = read_offset()
    session = requests.Session()
    session.headers.update({
        "X-SSAPI-KEY": API_KEY,
        "Content-Type": "application/json",
        "Connection": "close",
    })

    while True:
        resp = session.get(
            f"{BASE}/api/ss/auditlogs",
            params={
                "skip": skip,
                "limit": LIMIT,
                "include_request_body": "true",
            },
            timeout=120,
        )
        resp.raise_for_status()

        logs = resp.json().get("logs", [])
        if not logs:
            break

        for entry in logs:
            sys.stdout.write(json.dumps(entry) + "\n")
        sys.stdout.flush()                       # get events out before advancing the offset

        skip += len(logs)
        write_offset(skip)

        if len(logs) < LIMIT:
            break                                # caught up; wait for the next interval

if __name__ == "__main__":
    try:
        main()
    except Exception as exc:
        # stderr from a scripted input lands in splunkd.log — offset stays put, so the
        # next run re-requests the same page rather than skipping it
        sys.stderr.write(f"ERROR af_auditlogs: {exc}\n")
        sys.exit(1)
```

3. Configure the Input (`default/inputs.conf`)

```
[script://$SPLUNK_HOME/etc/apps/attackforge_app/bin/af_auditlogs.py]
disabled = 1
interval = 300
index = security
sourcetype = attackforge:auditlog
source = attackforge:ssapi
python.version = python3
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://support.attackforge.com/app/getting-started/configuring-splunk-integration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
