The crest command is a powerful and flexible custom Splunk search command that allows you to send HTTP requests directly from your Splunk searches.
It supports GET, POST, PUT, PATCH, and DELETE methods, allowing you to interact with RESTful APIs and web services. The command can run as a generating command (to start a search) or a streaming command (to act on existing results), making it a complete tool for API integration.
This command is shipped with the Custom REST Command app.
To install the Custom REST Command app and use the crest command:
- Download the App: Obtain the app package from Splunkbase.
- Access Splunk Web: Log in to your Splunk instance.
- Navigate to Manage Apps:
- Click on the Apps menu.
- Select Manage Apps.
- Install the App:
- Click on Install app from file.
- Upload the app package.
- Click Upload and follow the prompts.
- Restart Splunk: Some installations may require a restart. If prompted, restart your Splunk instance to complete the installation.
| crest url=<string> method=<string> [data=<string>] [headers=<string>] [auth_token=<string>] [auth_type=<string>] [parse_response=<boolean>] [json_path=<string>] [delimiter=<string>] [verify_ssl=<boolean>] [delay=<float>] [timeout=<int>] [debug=<boolean>]
- Note: Square brackets
[]denote optional parameters.
The crest command can operate in two distinct modes, depending on where it's placed in your SPL query.
This mode is used when crest is the first command in your search (i.e., starts with | crest ...). It runs once to fetch data from an external source and bring it into Splunk.
Use Case: Importing a threat intelligence feed, fetching a list of users from an API, or checking the status of an external service.
This mode is used when crest is placed after another command (e.g., | makeresults ... | crest ... or index=_internal | ... | crest ...). It runs once for every event piped into it.
Use Case: This is extremely powerful. You can use it to create multiple tickets, update assets in a CMDB, or enrich events one by one. This mode enables Token Substitution.
In streaming mode, you can use $field_name$ syntax in the url, data, and headers parameters to dynamically insert values from the incoming Splunk event.
- Example:
... | eval user="admin", id=123 | crest url="https://api.local/users/$id$" data="{'name': '$user$'}" - Result: The command will make a request to
https://api.local/users/123with the payload{'name': 'admin'}.
url(required): The endpoint URL to send the HTTP request to.- In Streaming Mode, supports token substitution (e.g.,
url=".../users/$id$").
- In Streaming Mode, supports token substitution (e.g.,
method(required): The HTTP method to use.- Supported:
get,post,put,patch,delete.
- Supported:
data(optional): The payload (body) to send withPOST,PUT, orPATCHrequests. This should be a string, typically formatted as JSON.- In Streaming Mode, supports token substitution (e.g.,
data="{'user': '$user_name$'}").
- In Streaming Mode, supports token substitution (e.g.,
headers(optional): Custom headers to include in the request. Should be a JSON-formatted string (e.g.,headers="{'X-API-Key': '123'}").- In Streaming Mode, supports token substitution.
auth_token(optional): A helper to easily add anAuthorizationheader. This is the token string itself.auth_type(optional): Specifies the type of token forauth_token.- Default:
Bearer. - Supported:
Bearer,Basic,Token. (e.g.,auth_type="Basic" auth_token="dXNlcjpwYXNz...").
- Default:
parse_response(optional): Set totrueto automatically parse the API response into Splunk events (a table).- Default:
false(returns a single event withstatus_codeandstatus_message). - Supported formats:
JSON(list of objects, or dict of objects),CSV,TSV(auto-detects delimiter), andXML.
- Default:
json_path(optional): Used withparse_response=truefor nested JSON. Specifies the key to find the list of results.- Example: If the response is
{"count": 10, "results": [...] }, usejson_path="results". - Supports dot notation for deeper nesting (e.g.,
json_path="data.items").
- Example: If the response is
delimiter(optional): Used withparse_response=true. Forces a specific delimiter for CSV parsing (e.g.,delimiter=";"). If not set, it auto-detects (comma, tab, semicolon, etc.).verify_ssl(optional): Set tofalseto disable SSL certificate verification.- Default:
true. - Warning: Only use
verify_ssl=falsein test environments or when you fully trust the endpoint (e.g.,localhostwith a self-signed cert).
- Default:
delay(optional): The number of seconds to wait between requests in Streaming Mode. Useful for rate limiting.- Default:
0(no delay). - Example:
delay=0.5(waits 500ms after each call).
- Default:
timeout(optional): The number of seconds to wait for the server to respond.- Default:
10.
- Default:
debug(optional): Set totrueto return the request details (URL, headers, data) without executing the request.- Default:
false.
- Default:
Fetches a simple GET request and returns the raw response.
| crest url="https://httpbin.org/get" method="get"
Result: A single event with status_code=200 and status_message containing the full JSON response.
Fetches a list of public APIs from an open API and parses the JSON response into a table.
| crest url="https://api.apis.guru/v2/list.json" method="get" parse_response=true
Result: A table of thousands of APIs. The json_parent_key column shows the API name, and other columns (added, preferred) are populated from the response.
Fetches a list of public APIs, but this time the list is nested inside a key named "entries".
| crest url="https://api.publicapis.org/entries" method="get" parse_response=true json_path="entries"
Result: A table of APIs with columns like API, Category, and Link. Using json_path is crucial here.
Fetches a threat intelligence feed in CSV format and automatically parses it into a table. The command will auto-detect the comma delimiter and skip the # comment lines.
| crest url="https://hole.cert.pl/domains/v2/domains.csv" method="get" parse_response=true
Result: A table of malicious domains with columns like hostname, ip, and classification.
Sends an authenticated request using the simple auth_token helper.
| crest url="https://httpbin.org/bearer" method="get" auth_token="my-secret-token-123"
Result: A single event. The status_message will show "authenticated": true and "token": "my-secret-token-123".
Creates three new tickets in an external system by piping events into crest. This demonstrates token substitution and the delay parameter for rate limiting.
| makeresults count=3
| streamstats count
| eval ticket_title = "Ticket " + count, user_email = "user" + count + "@example.com"
| crest url="https://api.my-helpdesk.com/v1/tickets" method="post" \
data="{'summary': '$ticket_title$', 'requester': '$user_email$', 'status': 'new'}" \
auth_token="my-api-key" \
delay=1
Result: This runs 3 times.
- POSTs to
/v1/ticketswith{'summary': 'Ticket 1', 'requester': 'user1@example.com', ...} - Waits 1 second.
- POSTs to
/v1/ticketswith{'summary': 'Ticket 2', 'requester': 'user2@example.com', ...} - Waits 1 second.
- ...and so on. The search results will show 3 events, each with the
status_codeof its respective API call.
Use the debug=true parameter to see what the command would send. This is essential for troubleshooting token substitution, headers, and data formatting.
| makeresults
| eval user="matheus", ticket_id=55
| crest url="https://api.local/tickets/$ticket_id$" method="put" \
data="{'assignee': '$user$'}" \
auth_token="123" \
debug=true
Result: A single event with fields showing the final values:
debug_url:https://api.local/tickets/55debug_data:{'assignee': 'matheus'}debug_headers:{'Authorization': 'Bearer 123'}debug_method:put
- HTTPS Enforcement: By default, the command requires
https://for all URLs exceptlocalhost. - SSL Verification: SSL verification is enabled by default. If you are querying an internal endpoint with a self-signed certificate, you must use
verify_ssl=false. - Localhost Session Auth: When making requests to
localhost(e.g., the local Splunk REST API), the command automatically includes your Splunk session key in theAuthorizationheader. You will likely need to useverify_ssl=falseas well.-
| crest url="https://localhost:8089/services/authentication/current-context" method="get" verify_ssl=false parse_response=true
-
- Timeouts: The default timeout is 10 seconds. You can increase this with the
timeoutparameter for long-running API calls. - Data Payloads: When writing JSON for
dataandheaders, you must use single quotes for the outer string and double quotes for the inner keys and values, as required by Splunk's SPL parser.- Correct:
data='{"user":"matheus","role":"admin"}' - Incorrect:
data="{\"user\":\"matheus\",\"role\":\"admin\"}"(This is valid but difficult to read and escape)
- Correct:
- Empty Responses (204 No Content): The command correctly handles successful but empty responses (like
204 No Content) and will not produce a parsing error.
This app is licensed under the MIT License.
Disclaimer: Use this command responsibly. Make sure you have permission to access the URLs you are querying, and be aware of the load and security implications of sending HTTP requests from your Splunk instance.