Reads Splunk events via the Splunk REST API
9.9K
Reads Splunk monitoring events and transactions via the Splunk REST API
go get -u github.com/Financial-Times/splunk-event-reader
cd $GOPATH/src/github.com/Financial-Times/splunk-event-reader
go build -mod=readonly .
Run the tests and install the binary:
go build -mod=readonly .
./splunk-event-reader
Run the binary (using the help flag to see the available optional arguments):
$GOPATH/bin/splunk-event-reader [--help]
Options:
--app-system-code="splunk-event-reader" System Code of the application ($APP_SYSTEM_CODE)
--app-name="Splunk Event Reader" Application name ($APP_NAME)
--port="8080" Port to listen on ($APP_PORT)
--environment="" Name of the cluster ($ENVIRONMENT)
--splunk-user="" Splunk user name ($SPLUNK_USER)
--splunk-password="" Splunk password ($SPLUNK_PASSWORD)
--splunk-url="" Splunk URL ($SPLUNK_URL)
3. Test:
Using curl:
curl http://localhost:8080/transactions | json_pp
go test -mod=readonly -race ./...
/{contentType}/transactions?[earliestTime={-relativeTime}][&latestTime={-relativeTime}][&uuid={uuid}]
Returns a set of unclosed transactions in a given interval
annotations are supported.-10m for earliestTime; now for latestTimeResponse example:
[{
transaction_id: "tid_h3pfihmzqd",
uuid: "919b15c0-f5a9-4288-89c1-2c0420529a7a",
closed_txn: "0",
start_time: "2017-09-12T11:56:50.765463097Z",
eventcount: 7,
events:
[
{
content_type: "",
event: "Ingest",
level: "info",
monitoring_event: "true",
service_name: "native-ingester-metadata",
@time: "2017-09-12T11:56:50.765463097Z",
transaction_id: "tid_h3pfihmzqd",
uuid: "919b15c0-f5a9-4288-89c1-2c0420529a7a"
},
{...}
]
},
{...}]
/{contentType}/events?lastEvent=true[&earliestTime={-relativeTime}]
Returns the last PublishEnd event within the interval
true, as this is the only functionality of the endpoint. Returns 403 otherwiseResponse example:
{
content_type: "Annotations",
event: "PublishEnd",
isValid: "true",
level: "info",
monitoring_event: "true",
service_name: "annotations-monitoring-service",
@time: "2017-09-13T08:27:34.051915987Z",
transaction_id: "tid_gkfnwqwybl",
uuid: "468b9400-97ff-11e7-a652-cde3f882dd7b"
}
Admin endpoints are:
/__gtg
/__health
/__build-info
These are the checks performed:
Endpoints on this service should be used in moderation, as there are both user level and system wide limits to concurrent searches. As Splunk requests may fail due to these (or other) limitation, a retry mechanism is in place that attempts each query up to 3 times in a row.
env app parameter, for all environments other than local logs are written to file.local./__build-info and /__gtg endpoints are not logged as they are called every second from varnish/vulcand
and this information is not needed in logs/splunk.Content type
Image
Digest
sha256:1bbaf4924…
Size
7.3 MB
Last updated
4 months ago
docker pull coco/splunk-event-reader