Skip to content

Instantly share code, notes, and snippets.

@iandow
Last active November 30, 2018 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iandow/9935beb5b0888de44a3ab5dbfdfb8892 to your computer and use it in GitHub Desktop.
Save iandow/9935beb5b0888de44a3ab5dbfdfb8892 to your computer and use it in GitHub Desktop.

Create a docker network to bridge containers

docker network create mynetwork

Start StreamSets like this:

docker run -it -p 18630:18630 -d --name sdc --network mynetwork streamsets/datacollector

The start opentsdb+hbase like this:

docker run -dp 4242:4242 --name hbase --network mynetwork petergrace/opentsdb-docker

Wait a few minutes for the OpenTSDB hbase container to start. Validate that opentsdb is started by doing telnet localhost 4242, and then inside the telnet session type stats. If you don't get a telnet connection error, then opentsdb is ready. You can also validate opentsdb like this:

Write values to a metric

for i in `seq 1 5`; do curl -X POST --data '{"metric": "sys.ian.test", "timestamp": '`date +%s`',"value": '$RANDOM',"tags": {"host": "localhost"}}' "http://hbase:4242/api/put"; sleep 1; done

Read values from a metric:

wget -q -O- "http://hbase:4242/api/query?start=10d-ago&m=avg:sys.ian.test"

Then copy test data file to SDC like this:

docker cp mqtt.json sdc:/tmp/mqtt.json

And since that data file is huge, write just one line at a time to a file we'll tail in streamsets:

docker exec -it --user root sdc /bin/bash
cat /tmp/mqtt.json | while read line; do echo $line >> /tmp/here.json; sleep 1; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment