Skip to main content
 
Splunk Lantern

Setting up the OpenTelemetry Demo in Docker

 

The OpenTelemetry demo application can be deployed using Docker.

Prerequisites

If you’d like to follow along, you’ll need the following software: 

  • git
  • Docker
  • Docker Compose (if not included with your instance of Docker) 
  • Splunk Observability Cloud 
  • Splunk Cloud Platform 

You’ll want to have at least 4 GB of RAM available on your machine to run the demo application. 

Create a new index

You can create a new index for the application logs. This is optional, but for our example, let’s create an index named “astronomyshop”.

  1. In Splunk Cloud Platform, navigate to Settings -> Indexes -> New Index. 
  2. Enter the index properties you want, as shown in the following screenshot. 

clipboard_e8838710b79d27e35e34d7eb187006d3e.png 

For further details on the index creation process, see Create events indexes.

Generate a Splunk HTTP Event Collector token

To use HTTP Event Collector (HEC) to send log data to Splunk Cloud Platform, we need to first generate a token. 

  1. In Splunk Cloud Platform, navigate to Settings -> Data Inputs -> HTTP Event Collector -> New Token.
  2. Provide a name for the token, such as “astronomyshop_token”.
    clipboard_ebee7cbc11cb27d3e8180996885120476.png
  3. Specify which index(es) you’d like the HEC token to send events to. In our case, we’ll send events to the “astronomyshop” index.
    clipboard_e2b1aa18a64140c943603dd7cc305c963.png
  4. After the token has been created successfully, make a note of its value for future reference. 

For further details on the token generation process, see Create an Event Collector token on Splunk Cloud Platform.

Generate a Splunk Observability Cloud access token

While we’ll send log data to Splunk Cloud Platform, we’ll be sending metrics and traces to Splunk Observability Cloud. This requires an access token.

  1. In Splunk Observability Cloud, navigate to the Settings Wheel ☸ -> Access Tokens -> New Token.
  2. Enter a name for the token such as “AstronomyShop Token”.
  3. Because we'll use this token for both ingest and API, select the options shown in the following screenshot.
    clipboard_ed8982073bff09ad39d07b0080edf04f4.png 
  4. Make a note of the token for future reference, as we’ll need it below.  

For further details on the creation process, see Create an access token

Install the OpenTelemetry Demo

Navigate to a directory where you’d like to work with the demo application code. For example: 

cd ~/Documents/Code/

Then, grab the source code for the demo repository by running the following commands: 

git clone https://github.com/dmitchsplunk/opentelemetry-demo.git

Navigate to this directory: 

cd opentelemetry-demo 

Configure the OpenTelemetry Demo

Set the following environment variables using the tokens created above: 

export SPLUNK_ACCESS_TOKEN=<ingest token> 
export SPLUNK_REALM=<your realm, e.g. us0, eu0>
export SPLUNK_HEC_TOKEN=<The Splunk HEC authentication token>
export SPLUNK_HEC_URL=<The Splunk HEC endpoint, e.g. https://abc.splunkcloud.com:port>
export SPLUNK_MEMORY_TOTAL_MIB=1024

Review the OpenTelemetry Collector service configuration

The docker-compose.yml file has already been updated to utilize the Splunk Distribution of the OpenTelemetry Collector rather than the collector-contrib distribution.

The resulting configuration looks as follows.

otelcol:
 image: quay.io/signalfx/splunk-otel-collector:latest
 container_name: otel-col
 environment:
   - SPLUNK_ACCESS_TOKEN=${SPLUNK_ACCESS_TOKEN}
   - SPLUNK_REALM=${SPLUNK_REALM}
   - SPLUNK_HEC_TOKEN=${SPLUNK_HEC_TOKEN}
   - SPLUNK_HEC_URL=${SPLUNK_HEC_URL}
   - SPLUNK_MEMORY_TOTAL_MIB=${SPLUNK_MEMORY_TOTAL_MIB}
 deploy:
   resources:
     limits:
       memory: 125M
 restart: unless-stopped
 command: [ "--config=/etc/splunk-otelcol-config.yml" ]
 volumes:
   - ./src/otelcollector/splunk-otelcol-config.yml:/etc/splunk-otelcol-config.yml
   - ./logs:/logs
   - ./checkpoint:/checkpoint
 ports:
   - "4317:4317"     # OTLP over gRPC receiver
   - "4318:4318"     # OTLP over HTTP receiver
   - "9464"          # Prometheus exporter
   - "8888"          # metrics endpoint
   - "13133"         # health check
   - "14250"         # jaeger gRPC receiver
   - "14268"         # jaeger thrift receiver
   - "6060"          # http forward extension
   - "9080"          # SignalFx forwarder
   - "9411"          # Zipkin endpoint
   - "9943"          # SignalFx receiver
 depends_on:
   - jaeger
 logging: *logging

The collector will utilize the configuration file stored at ./src/otelcollector/splunk-otelcol-config.yml. The collector is configured to export metrics and traces to Splunk Observability Cloud, using the environment variables set earlier.

Run the OpenTelemetry Demo

Run the demo application using the following command: 

docker compose up --no-build

In some environments, you may need to run docker-compose instead of docker compose. 

After a minute or so you should see the application components appearing on the service map by navigating to APM -> Explore in Splunk Observability Cloud.

clipboard_e2cc0859131a1ce55b2059b161a58a72b.png 

Next step

The Splunk Distribution of the OpenTelemetry Collector is running, and is sending metrics and traces to Splunk Observability Cloud. Now, we can get logs into Splunk Cloud Platform as well. Our Splunk OpenTelemetry Collector has already been configured to send data to Splunk Cloud Platform via the splunk_hec exporter.

exporters:
 
 # Logs 
 splunk_hec:
   token: "${SPLUNK_HEC_TOKEN}"
   endpoint: "${SPLUNK_HEC_URL}"
   source: "otel"
   sourcetype: "otel"
   index: "astronomyshop"
   profiling_data_enabled: false

However, our collector is not currently receiving logs. To initiate this process, see Getting Docker log data into Splunk Cloud Platform.

Splunk OnDemand Services: Use these credit-based services for direct access to Splunk technical consultants with a variety of technical services from a pre-defined catalog. Most customers have OnDemand Services per their license support plan. Engage the ODS team at OnDemand-Inquires@splunk.com if you require assistance.