I'm trying to set up a local development environment with Docker Compose that bootstraps a Splunk Enterprise server and uses the splunk logging driver on an app server.
Versions:
- Docker Engine: 18.06.1-ce
- Compose: 1.22.0
- Compose File: 3.7
- Splunk Enterprise: 7.2.0
My docker-compose.yml
file looks like this:
version: "3.7"
services:
app:
build: ./app
command: bash -c "npm run start:docker"
depends_on:
- splunk
environment:
- NODE_ENV=development
- SERVER_PORT=8080
logging:
driver: splunk
options:
splunk-format: "json"
splunk-insecureskipverify: "true"
splunk-source: "app"
splunk-token: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
splunk-url: "http://splunk:8088"
tag: "{{.ImageName}}/{{.Name}}/{{.ID}}"
ports:
- "80:8080"
volumes:
- "./app:/usr/src/app"
splunk:
environment:
- SPLUNK_ENABLE_LISTEN=9997
- SPLUNK_START_ARGS=--accept-license --no-prompt --answer-yes
- SPLUNK_USERNAME=admin
- SPLUNK_PASSWORD=password
hostname: splunk
image: splunk/splunk:7.2.0
ports:
- "8000:8000"
- "8088:8088"
- "9997:9997"
restart: always
In order for this to work as intended, I need to generate an HTTP Event Collector token and make it available to the app service somehow.
I've seen that you can use the environment variable SPLUNK_CMD
to run commands, presumably after the Splunk service is up and running, but when I tried using that to generate a token with the CLI, nothing happened. I saw no failure in the logs, and no token under Settings > Data Inputs.
Another issue is that Splunk takes some time to start up, and before it starts listening the app service fails to build because the logging driver cannot connect.
Is it possible to do what I'm trying to do? If so, how?