Skip to content

splunk/splunk-connect-for-otlp

Repository files navigation

Splunk Connect for OTLP

This repository contains a technical addon that exposes a OTLP endpoint for consumption of logs, traces and metrics.

Usage

Installation

Add the .tgz file to your Splunk apps by following these instructions: Install an add-on in a single-instance Splunk Enterprise deployment

Configuration

Create a new OTLP input in the data inputs.

Picker

Configure the OTLP input ports and network interface.

Setup

The input is configured as a data input in the Splunk Data Input settings.

You can set:

  • The gRPC port and HTTP ports the OTLP receiver will listen on
  • The network interface address on which the OTLP input will listen.

HEC Token configuration

The OTLP addon inherits authentication and authorization associated with the HEC tokens defined on the Splunk instance.

Please define a HEC token as documented in Splunk docs.

Please make sure to allow indexes as needed ; any payload sending to indexes that are not allowed will be refused in its entirety.

Sending OTLP

Authentication

The OTLP endpoint is secured by a bearer token authentication, checking the Authorization header for a token authentication under the Splunk scheme.

Example of setup of the otlp_http exporter:

exporters:
    otlp_http:
      endpoint: "http://splunk:4318"
      headers:
        authorization: "Splunk <TOKEN>"

Attribute to event fields mapping

When sending OTLP data, this input interprets resource attributes to create HEC equivalents.

This table shows the resource attributes mapping:

Resource attribute HEC event field
com.splunk.index index
com.splunk.sourcetype sourcetype
com.splunk.source source
host.name host

OpenTelemetry protocol representation of a log record contains additional fields. The table below shows the mapping of those fields to HEC event indexed fields:

Log record field HEC event indexed field
Severity text otel.log.severity.text
Severity number otel.log.severity.number

All other resource and individual log record attributes are mapped to indexed fields.

This mapping follows the OpenTelemetry specification.

Example

Here is a collector configuration, reading logs from a file, sending OTLP data to a specific index mylogs:

receivers:
    filelog/output:
      include: [ /output/file.log ]

exporters:
    otlphttp:
      endpoint: "http://splunk:4318"
      headers:
        authorization: "Splunk 00000000-0000-0000-0000-0000000000000"

processors:
    resource:
        attributes:
          - key: com.splunk.index
            value: "mylogs"
            action: insert

service:
    pipelines:
      logs:
        receivers: [filelog/output]
        processors: [resource]
        exporters: [otlphttp]

Build

Prerequisites:

  • Go 1.24
  • Make

Run:

$> make tgz

This will build the binaries, and assemble the TA tar.gz archive.

The archive is created as splunk-connect-for-otlp.tgz.

Testing

Run a Splunk instance locally

You can run a local Splunk instance with:

make splunk

Log in with admin/changeme.

Install the application by going to Apps > Manage Apps > Install application from file.

Send via collector

See the example folder for a collector configuration.

Telemetrygen

You can generate a payload using telemetrygen.

Install telemetrygen with:

go install github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen@latest

Try running telemetrygen with:

$> telemetrygen metrics --otlp-insecure --otlp-endpoint 0.0.0.0:4317 --metrics 100 --workers 10
$> telemetrygen logs --otlp-insecure --otlp-endpoint 0.0.0.0:4317 --logs 100 --workers 10
$> telemetrygen traces --otlp-insecure --otlp-endpoint 0.0.0.0:4317 --traces 100 --workers 10

To try sending data to different indexes, add a resource attribute with the --otlp-attributes parameter.

Example to send to the foo metric index:

$> telemetrygen metrics --otlp-insecure --otlp-endpoint 0.0.0.0:4317 --metrics 100 --workers 10 --otlp-attributes com.splunk.index=\"foo\"

Binary File Declaration

The following binaries are written in Go present in the source repository:

  • linux_x86_64/bin/splunk-connect-for-otlp
  • windows_x86_64/bin/splunk-connect-for-otlp

About

Splunk Connect for OTLP

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors