splunk-hec-logging
Sends request logs to a Splunk HTTP Event Collector.
splunk-hec-loggingPriority 409What it does
splunk-hec-logging sends the records of the requests that reach the route or other object it is added to, to a Splunk HTTP Event Collector. The records are collected on the gateway node and sent in batches, each one a POST to the URI carrying the Token, so one call can carry several events.
The URI is the whole collector address, its path included, for example https://splunk.internal:8088/services/collector. Without a Log format here or in the plugin metadata, each event carries a fixed summary of the request and the response.
When to use it
- The security team searches the logs of the whole company in Splunk, and the request records of the orders API should be searchable there too.
- The operations team has created an HTTP Event Collector token for the gateway, and the gateway's records should arrive under it.
- Every route should send the same few fields, the client, method, path, status and time, set once in the plugin metadata.
- The collector expects the events on a channel of their own, named with each batch.
Not for records sent to an HTTP collector of your own — see http-logger (Sends request logs to an HTTP endpoint in batches), records kept in Elasticsearch — see elasticsearch-logger (Sends request logs to an Elasticsearch index) or records sent to a syslog server — see syslog (Sends request logs to a syslog server).
Set it up
Send request records to a Splunk HTTP Event Collector
Under Basics fill Endpoint as in the JSON below.
{
"endpoint": {
"uri": "https://splunk.internal:8088/services/collector",
"token": "<secret>"
}
}
More scenarios
Shape the event every route sends to Splunkenvironment-wide settings
Fill Log format as in the JSON below.
{
"log_format": {
"client": "$remote_addr",
"method": "$request_method",
"path": "$uri",
"status": "$status",
"at": "$time_iso8601"
}
}
Things to know
- URI — The events arrive as a
POSTto the path of this address,/services/collectorin the example. - URI — An address without its scheme,
http://orhttps://, is refused when you save. - URI — The whole collector address, its path included: nothing is added to it.
- Token — A token is required: an endpoint without one is refused when you save.
- Token — An empty token is accepted, and the batch then travels with an empty credential.
- Keepalive timeout — At least
1000milliseconds:999is refused when you save. - A Log format in the plugin metadata shapes the event of every route whose splunk-hec-logging names no Log format of its own. In the example each event carries
pathwith the path the client asked for. - Log format — With no format here or in the plugin's metadata the event carries a fixed request and response summary, and the extra below adds only the keys that summary does not carry.
- Log format extra — Added to the default record only: while a log format is set, on this object or in the plugin's metadata, the engine writes that format alone and reads nothing here.
- Batch size — A batch goes out when it holds Batch size records, when its first record has waited Buffer duration, or when nothing new arrived for Inactive timeout.
- In the plugin metadata, Pending entry limit caps the backlog. While more entries than this wait to be sent, new ones are dropped rather than queued.
- AdviceGive the collector an
https://address, as the example does, and keep SSL verify on.
Settings
The fields as the console shows them, section by section.
Basics
endpointobjectRequiredendpoint.tokenstringRequiredThe HEC token, sent as Splunk followed by the token with every batch. An empty token is accepted, and the batch then travels with an empty credential. Stored on the engine and shown only to roles that manage this object.
endpoint.uristringRequiredpattern
^[^\/]+:\/\/([\da-zA-Z.-]+|\[[\da-fA-F:]+\])(:\d+)?https://splunk.internal:8088/services/collectorendpoint.channelstringSent as the X-Splunk-Request-Channel header, and when empty no such header is sent.
endpoint.keepalive_timeoutintegerdefault 60000endpoint.timeoutintegerdefault 10Behavior
log_formatobject{"host":"$host","client":"$remote_addr","status":"$status","at":"$time_iso8601"}log_format_extraobject{"zone":"eu-west","gateway":"$hostname"}ssl_verifybooleandefault trueAdvanced
batch_max_sizeintegerdefault 1000buffer_durationintegerdefault 60inactive_timeoutintegerdefault 5max_retry_countintegerdefault 0retry_delayintegerdefault 1namestringdefault splunk-hec-loggingEnvironment-wide settings
Set once per environment, under Plugins › splunk-hec-logging. Every splunk-hec-logging in the environment uses these.
log_formatobject{"host":"$host","client":"$remote_addr","status":"$status","at":"$time_iso8601"}log_format_extraobject{"zone":"eu-west","gateway":"$hostname"}max_pending_entriesintegerdefault 8192How many log entries may wait to be sent. While the backlog is above this number, new entries are dropped rather than queued.