Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Splunk HEC exporter example #266

Merged
merged 4 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ workflows:
filters:
tags:
only: /.*/
- build-examples-tracing:
- build-examples:
requires:
- setup
filters:
Expand Down Expand Up @@ -191,15 +191,15 @@ jobs:
root: ~/
paths: project/bin

build-examples-tracing:
build-examples:
docker:
- image: cimg/go:1.14
steps:
- restore_workspace
- setup_remote_docker
- run:
name: Build trace example
command: docker-compose -f examples/tracing/docker-compose.yml build
name: Build examples
command: make build-examples

cross-compile:
executor: golang
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,8 @@ otel-from-tree:
otel-from-lib:
# Sets opentelemetry core to be not be pulled from local source tree. (Undoes otel-from-tree.)
$(MAKE) for-all CMD="go mod edit -dropreplace go.opentelemetry.io/collector"

.PHONY: build-examples
build-examples:
docker-compose -f examples/tracing/docker-compose.yml build
docker-compose -f exporter/splunkhecexporter/example/docker-compose.yml build
15 changes: 15 additions & 0 deletions exporter/splunkhecexporter/example/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.14 AS build

WORKDIR /src
ADD . /src

RUN make otelcontribcol

FROM alpine:latest as certs
RUN apk --update add ca-certificates

FROM scratch
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /src/bin/otelcontribcol_linux_amd64 /otelcontribcol
ENTRYPOINT ["/otelcontribcol"]
EXPOSE 55680 55679
13 changes: 13 additions & 0 deletions exporter/splunkhecexporter/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# OpenTelemetry Collector Splunk demo

This demonstration shows how the OpenTelemetry Collector can send data to a Splunk instance.

Splunk runs as part of this docker-compose demo to show metrics data from your machine.

To build and run the demo, switch to this directory and run

`docker-compose up`

Hit `http://localhost:18000` and log in with `admin`/`opentelemetry`, then go to the [analytics workspace](http://localhost:18000/en-US/app/search/analytics_workspace).

You will see a list of analytics exposed by the host metrics collector, which captures simple metrics exposed inside the OpenTelemetry Collector Docker container.
31 changes: 31 additions & 0 deletions exporter/splunkhecexporter/example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "3"
services:

otel-collector:
build:
context: ../../..
dockerfile: exporter/splunkhecexporter/example/Dockerfile
container_name: otel
command: ["--config=/etc/otel-collector-config.yml"]
volumes:
- ./otel-collector-config.yml:/etc/otel-collector-config.yml
depends_on:
- splunk
splunk:
image: splunk/splunk:latest
container_name: splunk
environment:
- SPLUNK_START_ARGS=--accept-license
- SPLUNK_HEC_TOKEN=00000000-0000-0000-0000-0000000000000
- SPLUNK_PASSWORD=opentelemetry
ports:
- 18000:8000
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8000']
interval: 5s
timeout: 5s
retries: 20
volumes:
- ./splunk.yml:/tmp/defaults/default.yml
- /opt/splunk/var
- /opt/splunk/etc
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
receivers:
prometheus:
config:
scrape_configs:
- job_name: 'otel-collector'
scrape_interval: 10s
static_configs:
- targets: ['localhost:8890']
- targets: ['localhost:8889']
- targets: ['localhost:8888']
hostmetrics:
collection_interval: 5s
scrapers:
cpu:
report_per_cpu: true
disk:
load:
filesystem:
memory:
network:

exporters:
splunk_hec:
Expand All @@ -28,10 +29,11 @@ exporters:
# HTTP timeout when sending data. Defaults to 10s.
timeout: 10s
# Whether to skip checking the certificate of the HEC endpoint when sending data over HTTPS. Defaults to false.
insecure_skip_verify: false
# For this demo, we use a self-signed certificate on the Splunk docker instance, so this flag is set to true.
insecure_skip_verify: true

service:
pipelines:
metrics:
receivers: [prometheus]
receivers: [hostmetrics]
exporters: [splunk_hec]
11 changes: 11 additions & 0 deletions exporter/splunkhecexporter/example/splunk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
splunk:
conf:
indexes:
directory: /opt/splunk/etc/apps/search/local
content:
metrics:
coldPath: $SPLUNK_DB/metrics/colddb
datatype: metric
homePath: $SPLUNK_DB/metrics/db
maxTotalDataSizeMB: 512000
thawedPath: $SPLUNK_DB/metrics/thaweddb