Skip to content

Commit 52115dc

Browse files
authored
Add Splunk HEC metrics example, taking metrics from telegraf (open-telemetry#64)
1 parent cceaaa6 commit 52115dc

File tree

5 files changed

+163
-0
lines changed

5 files changed

+163
-0
lines changed

examples/splunk-hec-metrics/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Splunk HEC Metrics Example
2+
3+
This example showcases how the collector can send data to a Splunk Enterprise deployment from a Telegraf instance.
4+
5+
The example runs as a Docker Compose deployment. The collector can be configured to send metrics to Splunk Enterprise.
6+
7+
Splunk is configured to receive data from the OpenTelemetry Collector using the HTTP Event collector. To learn more about HEC, visit [our guide](https://dev.splunk.com/enterprise/docs/dataapps/httpeventcollector/).
8+
9+
To deploy the example, check out this git repository, open a terminal and in this directory type:
10+
```bash
11+
$> docker-compose up
12+
```
13+
14+
Splunk will become available on port 18000. You can login on [http://localhost:18000](http://localhost:18000) with `admin` and `changeme`.
15+
16+
Once logged in, visit the [analytics workspace](http://localhost:18000/en-US/app/search/analytics_workspace) to see the metrics collected by Splunk.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: "3"
2+
services:
3+
telegraf:
4+
image: telegraf:1.17.0
5+
container_name: telegraf
6+
restart: always
7+
environment:
8+
HOST_PROC: /rootfs/proc
9+
HOST_SYS: /rootfs/sys
10+
HOST_ETC: /rootfs/etc
11+
volumes:
12+
- ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
13+
- /var/run/docker.sock:/var/run/docker.sock:ro
14+
- /sys:/rootfs/sys:ro
15+
- /proc:/rootfs/proc:ro
16+
- /etc:/rootfs/etc:ro
17+
# Splunk Enterprise server:
18+
splunk:
19+
image: splunk/splunk:latest
20+
container_name: splunk
21+
environment:
22+
- SPLUNK_START_ARGS=--accept-license
23+
- SPLUNK_HEC_TOKEN=00000000-0000-0000-0000-0000000000000
24+
- SPLUNK_PASSWORD=changeme
25+
ports:
26+
- 18000:8000
27+
healthcheck:
28+
test: ['CMD', 'curl', '-f', 'http://localhost:8000']
29+
interval: 5s
30+
timeout: 5s
31+
retries: 20
32+
volumes:
33+
- ./splunk.yml:/tmp/defaults/default.yml
34+
- /opt/splunk/var
35+
- /opt/splunk/etc
36+
# OpenTelemetry Collector
37+
otelcollector:
38+
image: otel/opentelemetry-collector-contrib-dev:latest #quay.io/signalfx/splunk-otel-collector:0.4.0
39+
container_name: otelcollector
40+
command: ["--config=/etc/otel-collector-config.yml", "--log-level=DEBUG"]
41+
volumes:
42+
- ./otel-collector-config.yml:/etc/otel-collector-config.yml
43+
depends_on:
44+
- splunk
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
receivers:
2+
splunk_hec:
3+
4+
exporters:
5+
splunk_hec/metrics:
6+
# Splunk HTTP Event Collector token.
7+
token: "00000000-0000-0000-0000-0000000000000"
8+
# URL to a Splunk instance to send data to.
9+
endpoint: "https://splunk:8088/services/collector"
10+
# Optional Splunk source: https://docs.splunk.com/Splexicon:Source
11+
source: "app"
12+
# Optional Splunk source type: https://docs.splunk.com/Splexicon:Sourcetype
13+
sourcetype: "telegraf"
14+
# Splunk index, optional name of the Splunk index targeted.
15+
index: "metrics"
16+
# Maximum HTTP connections to use simultaneously when sending data. Defaults to 100.
17+
max_connections: 20
18+
# Whether to disable gzip compression over HTTP. Defaults to false.
19+
disable_compression: false
20+
# HTTP timeout when sending data. Defaults to 10s.
21+
timeout: 10s
22+
# Whether to skip checking the certificate of the HEC endpoint when sending data over HTTPS. Defaults to false.
23+
# For this demo, we use a self-signed certificate on the Splunk docker instance, so this flag is set to true.
24+
insecure_skip_verify: true
25+
26+
processors:
27+
batch:
28+
queued_retry:
29+
30+
extensions:
31+
health_check:
32+
pprof:
33+
endpoint: :1888
34+
zpages:
35+
endpoint: :55679
36+
37+
service:
38+
extensions: [pprof, zpages, health_check]
39+
pipelines:
40+
metrics:
41+
receivers: [splunk_hec]
42+
processors: [batch, queued_retry]
43+
exporters: [splunk_hec/metrics]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
splunk:
2+
conf:
3+
indexes:
4+
directory: /opt/splunk/etc/apps/search/local
5+
content:
6+
metrics:
7+
coldPath: $SPLUNK_DB/metrics/colddb
8+
datatype: metric
9+
homePath: $SPLUNK_DB/metrics/db
10+
maxTotalDataSizeMB: 512000
11+
thawedPath: $SPLUNK_DB/metrics/thaweddb
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[agent]
2+
## Default data collection interval for all inputs
3+
interval = "10s"
4+
5+
[[inputs.cpu]]
6+
percpu = true
7+
totalcpu = true
8+
collect_cpu_time = false
9+
report_active = false
10+
[inputs.cpu.tags]
11+
index = "metrics"
12+
event = "metric"
13+
14+
15+
[[outputs.http]]
16+
## URL is the address to send metrics to
17+
url = "http://otelcollector:8088/services/collector"
18+
19+
## Timeout for HTTP message
20+
# timeout = "5s"
21+
22+
## HTTP method, one of: "POST" or "PUT"
23+
# method = "POST"
24+
25+
## HTTP Basic Auth credentials
26+
# username = "username"
27+
# password = "pa$$word"
28+
29+
## Optional TLS Config
30+
# tls_ca = "/etc/telegraf/ca.pem"
31+
# tls_cert = "/etc/telegraf/cert.pem"
32+
# tls_key = "/etc/telegraf/key.pem"
33+
## Use TLS but skip chain & host verification
34+
insecure_skip_verify = true
35+
36+
## Data format to output.
37+
## Each data format has it's own unique set of configuration options, read
38+
## more about them here:
39+
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
40+
data_format = "splunkmetric"
41+
## Provides time, index, source overrides for the HEC
42+
splunkmetric_hec_routing = true
43+
splunkmetric_multimetric = true
44+
45+
## Additional HTTP headers
46+
[outputs.http.headers]
47+
# Should be set manually to "application/json" for json data_format
48+
Content-Type = "application/json"
49+
Authorization = "Splunk 00000000-0000-0000-0000-0000000000000"

0 commit comments

Comments
 (0)