Forwarding logs to Splunk Enterprise
This guide would cover configuring your app builder application to forward application logs to your Splunk Enterprise deployment.
Prerequisites
- An index on your Splunk Enterprise instance. To create a new index, you can follow Splunk's guide here.
- Local development setup for your App Builder application.
- The latest version of AIO CLI. Check your version by running
aio --version
. To update runnpm install -g @adobe/aio-cli
.
Steps to configure Log Forwarding
1. Set up Splunk HTTP Event Collector
Go to your Splunk home and select Settings from the ribbon on top. On the Settings pane, select Data Inputs.
Click on the + Add New button corresponding to the HTTP Event Collector input type.
On the Select Source screen:
- Type in an input name. For example:
My App Builder Application
- Ensure that the Enable Indexer Acknowledgment checkbox is not ticked.
- Click the Next button on top.
- Type in an input name. For example:
On the Input Settings screen:
- Set the source type to
automatic
. The forwarded logs would be sent with thesourcetype
field set to_json
. - From the list of indexes, only select the index on which you wish to receive logs from your App Builder application.
- Click the Review button on top.
- Set the source type to
On the Done screen:
- Copy the value of the token value to be used later.
2. Getting Splunk Host and Port
To find out your
hostname
andport
number, read the Send data to HTTP Event Collector on Splunk Enterprise section on Splunk's documentation here.Confirm whether you have got the correct
hostname
andport
number by executing the following cURL request. If you get a200 OK
response, you are good to proceed.Copied to your clipboardcurl -X POST 'https://<hostname>:<port>/services/collector' \-H "Authorization: Splunk <token>" \-d '{"event": "hello world"}'Note: The
token
value is from step 1.5.1
3. Set up Log Forwarding in App Builder
Open terminal and navigate to the App Builder project directory on your machine.
Run the following command and supply the values from previous steps
Copied to your clipboardaio app config set log-forwarding? select log forwarding destination: Splunk HEC? host: <hostname>? port: <port_number>? index: <index>? hec_token: <token>Note:
- Make sure to not prefix the protocol (
http://
orhttps://
) before the hostname. - Replace the value of
hostname
andport
as ascertained in step 2.2.1. - Replace the value of
token
from step 1.5.1.
- Make sure to not prefix the protocol (
Verify that the config change has taken effect
Copied to your clipboardaio app config get log-forwardingExecute an action in your App Builder application workspace to generate logs.
Go to Splunk Home > Search and run the query
Copied to your clipboardindex=<index>If you don't see any logs in Splunk, please check the log forwarding errors.
Copied to your clipboardaio app config get log-forwarding errorsNote: If you are unable to set up log forwarding correctly, please visit our App Builder forums for support.