Splunk Enterprise Getting Data in 7.2.3: Set Up and Use HTTP Event Collector in Splunk Web
Splunk Enterprise Getting Data in 7.2.3: Set Up and Use HTTP Event Collector in Splunk Web
3
Set up and use HTTP Event Collector in Splunk Web
Generated: 8/28/2019 5:30 am
After you enable HEC, as a developer, you can use HEC tokens in your app to
send data to HEC. You do not need to include Splunk credentials in your app or
supported files.
HTTP Event Collector runs on Splunk Enterprise, and self-service and managed
Splunk Cloud. How it works depends on the type of Splunk instance you have.
HEC offers full configurability and functionality on the Splunk Enterprise platform
on-premises. It offers the following additional benefits on Splunk Enterprise over
the other Splunk types:
• HEC can accept events that you send to it over the HTTP protocol in
addition to the HTTPS protocol.
• HEC can forward events to another Splunk indexer with an optional
forwarding output group.
• You can use the deployment server to distribute HEC tokens across
indexers in a distributed deployment.
For instructions on how to enable and manage HEC on Splunk Enterprise, see
Configure HTTP Event Collector on Splunk Enterprise.
1
• You cannot change the network port that HEC listens on for connections.
• You cannot forward data that HEC receives to another set of Splunk
indexers as Splunk Cloud does not support forwarding output groups.
For instructions on how to enable and manage HEC on managed Splunk Cloud,
see Configure HTTP Event Collector on managed Splunk Cloud.
Tokens are entities that let logging agents and HTTP clients connect to the HEC
input. Each token has a unique value, which is a 128-bit number that is
represented as a 32-character globally unique identifier (GUID). Agents and
clients use a token to authenticate their connections to HEC. When the clients
connect, they present this token value. If HEC receives a valid token, it accepts
the connection and the client can deliver its payload of application events in
either text or JavaScript Object Notation (JSON) format.
HEC receives the events and Splunk Enterprise indexes them based on the
configuration of the token. HEC uses the source, source type, and index that was
2
specified in the token. If a forwarding output group configuration exists on a
Splunk Enterprise instance, HEC forwards the data to indexers in that output
group.
To index large amounts of data, you will likely need multiple indexers. You can
specify groups of indexers to handle indexing your HTTP Event Collector data.
These are called output groups. You can use output groups to, for example,
index only certain kinds of data or data from certain sources. Though using
output groups to route data to specific indexers is similar to the routing and
filtering capabilities built into Splunk Enterprise, output groups allow you to
specify groups of indexers on a token-by-token basis. When you configure output
groups with multiple indexers, Splunk Enterprise evenly distributes data among
the servers in your output group. You configure output groups in the
outputs.conf file. Specifically, for HTTP Event Collector, edit the outputs.conf
file at $SPLUNK_HOME/etc/apps/splunk_httpinput/local/
(%SPLUNK_HOME%\etc\apps\splunk_httpinput\local\ on Microsoft Windows
hosts). If either the local directory or the outputs.conf file doesn't exist at this
location, create it (or both).
HTTP Event Collector is not an app, but it stores its configuration in the
$SPLUNK_HOME/etc/apps/splunk_httpinput/ directory
(%SPLUNK_HOME%\etc\apps\splunk_httpinput\ on Windows) so that its
configuration can be easily deployed using built-in app deployment capabilities.
Before you can use Event Collector to receive events through HTTP, you must
enable it. For Splunk Enterprise, enable HEC through the Global Settings dialog
box.
3
4. In the All Tokens toggle button, select Enabled.
5. (Optional) Choose a Default Source Type for all HEC tokens. You can
also type in the name of the source type in the text field above the
drop-down before choosing the source type.
6. (Optional) Choose a Default Index for all HEC tokens.
7. (Optional) Choose a Default Output Group for all HEC tokens.
8. (Optional) To use a deployment server to handle configurations for HEC
tokens, click the Use Deployment Server check box.
9. (Optional) To have HEC listen and communicate over HTTPS rather than
HTTP, click the Enable SSL checkbox.
10. (Optional) Enter a number in the HTTP Port Number field for HEC to
listen on. Note: Confirm that no firewall blocks the port number that you
specified in the HTTP Port Number field, either on the clients or the
Splunk instance that hosts HEC.
11. Click Save.
4
9. Click Next.
10. (Optional) Confirm the source type and the index for HEC events.
11. Click Review.
12. Confirm that all settings for the endpoint are what you want.
13. If all settings are what you want, click Submit. Otherwise, click < to make
changes.
14. (Optional) Copy the token value that Splunk Web displays and paste it into
another document for reference later.
For information about HEC tokens, see About Event Collector tokens.
5
You can make changes to an HEC token after you have created it.
6
8. (Optional) Choose a different index by selecting it in the Available
Indexes pane of the Select Allowed Indexes control.
9. (Optional) Choose a different output group from the Output Group
drop-down.
10. (Optional) Choose whether you want indexer acknowledgment enabled for
the token.
11. Click Save.
You can delete an HEC token. Deleting an HEC token does not affect other HEC
tokens, nor does it disable HEC.
You cannot undo this action. Clients that use this token to send data to your
Splunk deployment can no longer authenticate with the token. You must
generate a new token and change the client configuration to use the new token.
You can enable or disable a single HEC token from within the HEC management
page. Changing the status of one token does not change the status of other
tokens. To enable or disable all tokens, use the Global Settings dialog. See
Enable the HTTP Event Collector.
7
Enable HTTP Event Collector
8
12. If all settings are what you want, click Submit. Otherwise, click < to make
changes.
13. (Optional) Copy the token value that Splunk Web displays and paste it into
another document for reference later.
For information about HEC tokens, see About Event Collector tokens.
You can make changes to an HEC token after you have created it.
9
1. Choose a category.
2. Select a source type in the pop-up menu that appears.
3. (Optional) You can also type in the name of the source type in the
text box at the top of the drop-down.
You can delete an HEC token. Deleting an HEC token does not affect other HEC
tokens, nor does it disable the HEC endpoint.
You cannot undo this action. Clients that use this token to send data to your
Splunk deployment can no longer authenticate with the token. You must
generate a new token and change the client configuration to use the token.
10
Enable and disable Event Collector tokens
You can enable or disable an HEC token from within the HEC management
page. Changing the status of one token does not change the status of other
tokens. To enable or disable all tokens, use the Global Settings dialog. See
Enable the HTTP Event Collector.
To use HEC, you must configure at least one token. In managed Splunk Cloud
instances, the token is distributed across the deployment. The token is not ready
for use until distribution has completed.
11
13. (Optional) Click Track deployment progress to see progress on how the
token has been deployed to the rest of the Splunk Cloud deployment.
When you see a status of "Done", you can then use the token to send
data to HEC.
For information about HEC tokens, see About Event Collector tokens.
You can check the distribution status of an HEC token from the HEC token page.
When a distribution is in progress, the page displays "Operation in progress" and
a progress bar. Otherwise, the page displays "Last deployment status."
You can make changes to an HEC token after it has been created.
12
7. (Optional) Choose a different source type by selecting it in the Source
Type drop-down.
1. Choose a category.
2. Select a source type in the pop-up menu that appears.
3. (Optional) You can also type in the name of the source type in the
text box at the top of the drop-down.
8. (Optional) Choose a different index by selecting it in the Available
Indexes pane of the Select Allowed Indexes control.
9. (Optional) Choose whether you want indexer acknowledgment enabled for
the token.
10. Click Save.
You can delete an HEC token. Deleting an HEC token does not affect other HEC
tokens, nor does it disable the HEC endpoint.
You cannot undo this action. Clients that use this token to send data to your
Splunk deployment can no longer authenticate with the token. You must
generate a new token and change the client configuration to use the new value.
You can enable or disable a token from within the HEC management page.
Changing the active status of one token does not change the status of other
tokens.
13
Send data to HTTP Event Collector
You must satisfy all of the following conditions when you send data to HEC:
There are several options for sending data to HTTP Event Collector:
• You can make an HTTP request using your favorite HTTP client and send
your JSON-encoded events.
• As a developer, you can use the Java, JavaScript (node.js), and .NET
logging libraries in your application to send data to HEC. These libraries
are compatible with popular logging frameworks. See Java, JavaScript
(Node.js), and .NET on the Splunk Dev Portal.
You send data to a specific Uniform Resource Indicator (URI) for HEC.
The standard form for the HEC URI in Splunk Enterprise is as follows:
<protocol>://<host>:<port>/<endpoint>
Where:
Depending on the type of Splunk Cloud that you use, you must send data using a
specific URI for HEC.
14
The standard form for the HEC URI in self-service Splunk Cloud is as follows:
<protocol>://input-<host>:<port>/<endpoint>
The standard form for the HEC URI in managed Splunk Cloud is as follows:
<protocol>://http-inputs-<host>:<port>/<endpoint>
Where:
If you do not include these prefixes before your Splunk Cloud hostname when
you send data, the data cannot reach HEC.
The following example makes a HTTP POST request to the HEC on port 8088
and uses HTTPS for transport. This example uses the curl command to
generate the request, but you can use a command line or other tool that better
suits your needs.
You can configure the network port and HTTP protocol settings independently of
settings for other instances of HEC in your Splunk Enterprise or self-service
Splunk Cloud deployment.
The following cURL command uses an example HTTP Event Collector token
(B5A79AAD-D822-46CC-80D1-819F80D7BFB0), and uses
https://hec.example.com as the hostname. Replace these values with your
own before running this command.
15
JSON request and response
When you make a JSON request to send data to HEC, you must specify the
"event" key in the command.
curl -k https://hec.example.com:8088/services/collector/event -H
"Authorization: Splunk B5A79AAD-D822-46CC-80D1-819F80D7BFB0" -d
'{"event": "hello world"}'
{"text": "Success", "code": 0}
More information on HEC for developers
16