├── .github └── workflows │ └── docker-image.yml ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── docker-compose.yml └── files ├── create_tsdb_tables.sh ├── entrypoint.sh ├── hbase-site.xml ├── opentsdb.conf ├── start_hbase.sh └── start_opentsdb.sh /.github/workflows/docker-image.yml: -------------------------------------------------------------------------------- 1 | name: Docker Image CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Login to dockerhub 18 | uses: docker/login-action@v1 19 | with: 20 | username: ${{ secrets.HUB_DOCKER_USERNAME }} 21 | password: ${{ secrets.HUB_DOCKER_PAT }} 22 | - name: run makefile 23 | run: make gh-build 24 | shell: bash 25 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | ENV TINI_VERSION v0.18.0 4 | ENV TSDB_VERSION 2.4.0 5 | ENV HBASE_VERSION 1.4.4 6 | ENV GNUPLOT_VERSION 5.2.4 7 | ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk 8 | ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/bin/ 9 | ENV ALPINE_PACKAGES "rsyslog bash openjdk8 make wget libgd libpng libjpeg libwebp libjpeg-turbo cairo pango lua" 10 | ENV BUILD_PACKAGES "build-base autoconf automake git python3-dev cairo-dev pango-dev gd-dev lua-dev readline-dev libpng-dev libjpeg-turbo-dev libwebp-dev sed" 11 | ENV HBASE_OPTS "-XX:+UseConcMarkSweepGC -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap" 12 | ENV JVMARGS "-XX:+UseConcMarkSweepGC -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -enableassertions -enablesystemassertions" 13 | 14 | # Tini is a tiny init that helps when a container is being culled to stop things nicely 15 | ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-amd64 /tini 16 | RUN chmod +x /tini 17 | ENTRYPOINT ["/tini", "--"] 18 | 19 | # Add the base packages we'll need 20 | RUN apk --update add apk-tools \ 21 | && apk add ${ALPINE_PACKAGES} \ 22 | # repo required for gnuplot \ 23 | --repository http://dl-cdn.alpinelinux.org/alpine/v3.0/testing/ \ 24 | && mkdir -p /opt/opentsdb 25 | 26 | WORKDIR /opt/opentsdb/ 27 | 28 | # Add build deps, build opentsdb, and clean up afterwards. 29 | RUN set -ex && apk add --virtual builddeps ${BUILD_PACKAGES} 30 | 31 | RUN ln -s /usr/bin/python3 /usr/bin/python 32 | 33 | RUN wget --no-check-certificate \ 34 | -O v${TSDB_VERSION}.zip \ 35 | https://github.com/OpenTSDB/opentsdb/archive/v${TSDB_VERSION}.zip \ 36 | && unzip v${TSDB_VERSION}.zip \ 37 | && rm v${TSDB_VERSION}.zip \ 38 | && cd /opt/opentsdb/opentsdb-${TSDB_VERSION} \ 39 | && echo "tsd.http.request.enable_chunked = true" >> src/opentsdb.conf \ 40 | && echo "tsd.http.request.max_chunk = 1000000" >> src/opentsdb.conf 41 | 42 | RUN cd /opt/opentsdb/opentsdb-${TSDB_VERSION} \ 43 | && find . | xargs grep -s central.maven.org | cut -f1 -d : | xargs sed -i "s/http:\/\/central/https:\/\/repo1/g" \ 44 | && find . | xargs grep -s repo1.maven.org | cut -f1 -d : | xargs sed -i "s/http:\/\/repo1/https:\/\/repo1/g" \ 45 | && ./build.sh \ 46 | && cp build-aux/install-sh build/build-aux \ 47 | && cd build \ 48 | && make install \ 49 | && cd / \ 50 | && rm -rf /opt/opentsdb/opentsdb-${TSDB_VERSION} 51 | 52 | RUN cd /tmp && \ 53 | wget https://sourceforge.net/projects/gnuplot/files/gnuplot/${GNUPLOT_VERSION}/gnuplot-${GNUPLOT_VERSION}.tar.gz && \ 54 | tar xzf gnuplot-${GNUPLOT_VERSION}.tar.gz && \ 55 | cd gnuplot-${GNUPLOT_VERSION} && \ 56 | ./configure && \ 57 | make install && \ 58 | cd /tmp && rm -rf /tmp/gnuplot-${GNUPLOT_VERSION} && rm /tmp/gnuplot-${GNUPLOT_VERSION}.tar.gz 59 | 60 | RUN apk del builddeps && rm -rf /var/cache/apk/* 61 | 62 | #Install HBase and scripts 63 | RUN mkdir -p /data/hbase /root/.profile.d /opt/downloads 64 | WORKDIR /opt/downloads 65 | RUN wget -O hbase-${HBASE_VERSION}.bin.tar.gz http://archive.apache.org/dist/hbase/${HBASE_VERSION}/hbase-${HBASE_VERSION}-bin.tar.gz \ 66 | && tar xzvf hbase-${HBASE_VERSION}.bin.tar.gz \ 67 | && mv hbase-${HBASE_VERSION} /opt/hbase \ 68 | && rm -r /opt/hbase/docs \ 69 | && rm hbase-${HBASE_VERSION}.bin.tar.gz 70 | 71 | # Add misc startup files 72 | RUN ln -s /usr/local/share/opentsdb/etc/opentsdb /etc/opentsdb \ 73 | && rm /etc/opentsdb/opentsdb.conf \ 74 | && mkdir /opentsdb-plugins 75 | ADD files/opentsdb.conf /etc/opentsdb/opentsdb.conf.sample 76 | ADD files/hbase-site.xml /opt/hbase/conf/hbase-site.xml.sample 77 | ADD files/start_opentsdb.sh /opt/bin/ 78 | ADD files/create_tsdb_tables.sh /opt/bin/ 79 | ADD files/start_hbase.sh /opt/bin/ 80 | ADD files/entrypoint.sh /entrypoint.sh 81 | 82 | # Fix ENV variables in installed scripts 83 | RUN for i in /opt/bin/start_hbase.sh /opt/bin/start_opentsdb.sh /opt/bin/create_tsdb_tables.sh; \ 84 | do \ 85 | sed -i "s#::JAVA_HOME::#$JAVA_HOME#g; s#::PATH::#$PATH#g; s#::TSDB_VERSION::#$TSDB_VERSION#g;" $i; \ 86 | done 87 | 88 | RUN echo "export HBASE_OPTS=\"${HBASE_OPTS}\"" >> /opt/hbase/conf/hbase-env.sh 89 | 90 | 91 | #4242 is tsdb, rest are hbase ports 92 | EXPOSE 60000 60010 60030 4242 16010 16070 93 | 94 | 95 | #HBase is configured to store data in /data/hbase, vol-mount it to persist your data. 96 | VOLUME ["/data/hbase", "/tmp", "/opentsdb-plugins"] 97 | 98 | CMD ["/entrypoint.sh"] 99 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2016 Twitter, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | docker build -t petergrace/opentsdb-docker . 5 | 6 | gh-build: HASH=$(shell git rev-parse --short HEAD) 7 | gh-build: 8 | docker build -t petergrace/opentsdb-docker:$(HASH) . 9 | docker tag petergrace/opentsdb-docker:$(HASH) petergrace/opentsdb-docker:latest 10 | docker push petergrace/opentsdb-docker:$(HASH) 11 | docker push petergrace/opentsdb-docker:latest 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # THIS PROJECT IS NOW ARCHIVED 2 | This project was relevant early on in the progression of opentsdb and bosun development but it is now arguable 3 | that this docker container could be done in many better ways. I'm archiving for posterity's sake but no new 4 | attention will be delivered to this repository. Thanks everyone for your issues, PRs, and encouragement! 5 | 6 | # opentsdb-docker 7 | 8 | Files required to make a trusted opentsdb Docker such that opentsdb can be used for other projects (e.g. scollector, bosun) 9 | 10 | ## How it works 11 | This image automatically starts HBase, waits a configurable number of seconds, then 12 | attempts to create the opentsdb tables in hbase and then fires up opentsdb. 13 | Make sure that you export port 4242 so that you can access opentsdb outside of the container. 14 | 15 | ## Usage 16 | 17 | ### "I just want to play with opentsdb as soon as possible!" 18 | `docker run -dp 4242:4242 petergrace/opentsdb-docker` 19 | 20 | ### "I want my data to persist even if the container is deleted!" 21 | Use the supplied docker-compose.yml file to start the container. Data will be persisted in ./data 22 | 23 | `docker-compose up -d` 24 | 25 | **NOTE: When stopping the container, please use the -t option to give more time for hbase to shutdown, 26 | otherwise data corruption may result. At least 30 seconds is suggested.** 27 | 28 | Example: `docker-compose stop -t 30` 29 | 30 | ### I want to use my own opentsdb.conf file! 31 | You can volume-mount it into the docker container at /etc/opentsdb/opentsdb.conf. If entrypoint.sh 32 | already sees a file there it will not copy over the default. 33 | 34 | ### I want to use my own hbase-site.xml file! 35 | Similarly to the opentsdb.conf file, volume-mount your version at /opt/hbase/conf/hbase-site.xml. 36 | 37 | ### I want to use specific opentsdb plugins! 38 | Volume-mount the plugins into /opentsdb-plugins (most people wont be using these) 39 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | opentsdb: 3 | hostname: otsdb-host 4 | image: petergrace/opentsdb-docker:latest 5 | environment: 6 | - WAITSECS=30 7 | ports: 8 | - 4242:4242 9 | - 60030:60030 10 | volumes: 11 | - "./data:/data/hbase" 12 | -------------------------------------------------------------------------------- /files/create_tsdb_tables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export COMPRESSION="NONE" 4 | export HBASE_HOME=/opt/hbase 5 | export TSDB_VERSION="::TSDB_VERSION::" 6 | export JAVA_HOME="::JAVA_HOME::" 7 | 8 | # https://github.com/OpenTSDB/opentsdb/issues/1481 9 | sed -i "s/, TTL => '\$TSDB_TTL'//g" /usr/local/share/opentsdb/tools/create_table.sh 10 | 11 | /usr/local/share/opentsdb/tools/create_table.sh 12 | touch /data/hbase/opentsdb_tables_created.txt 13 | -------------------------------------------------------------------------------- /files/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | cleanup() 5 | { 6 | echo "SIGTERM received, trying to gracefully shutdown." 7 | echo "diediedie" | nc localhost 4242 8 | sleep 2 9 | /opt/hbase/bin/stop-hbase.sh 10 | } 11 | trap cleanup TERM 12 | 13 | if [ ! -f "/etc/opentsdb/opentsdb.conf" ] 14 | then 15 | echo "OpenTSDB config not imported, using defaults." 16 | cp /etc/opentsdb/opentsdb.conf.sample /etc/opentsdb/opentsdb.conf 17 | fi 18 | 19 | if [ ! -f "/opt/hbase/conf/hbase.xml" ] 20 | then 21 | echo "HBase config not imported, using defaults." 22 | cp /opt/hbase/conf/hbase-site.xml.sample /opt/hbase/conf/hbase-site.xml 23 | fi 24 | 25 | 26 | WAITSECS=${WAITSECS:-15} 27 | echo "starting hbase and sleeping ${WAITSECS} seconds for hbase to come online" 28 | /opt/bin/start_hbase.sh & 29 | sleep ${WAITSECS} 30 | touch /data/hbase/hbase_started 31 | 32 | echo "Starting opentsdb. It should be available on port 4242 momentarily." 33 | /opt/bin/start_opentsdb.sh & 34 | 35 | while [ 1 ] 36 | do 37 | sleep 1 38 | done 39 | -------------------------------------------------------------------------------- /files/hbase-site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | hbase.rootdir 6 | file:////data/hbase 7 | 8 | 9 | hbase.zookeeper.dns.interface 10 | default 11 | 12 | 13 | hbase.regionserver.dns.interface 14 | default 15 | 16 | 17 | hbase.master.dns.interface 18 | default 19 | 20 | 21 | -------------------------------------------------------------------------------- /files/opentsdb.conf: -------------------------------------------------------------------------------- 1 | tsd.network.port = 4242 2 | tsd.http.staticroot = /usr/local/share/opentsdb/static/ 3 | tsd.http.cachedir = /tmp/opentsdb 4 | tsd.core.plugin_path = /opentsdb-plugins 5 | tsd.core.auto_create_metrics = true 6 | -------------------------------------------------------------------------------- /files/start_hbase.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export JAVA_HOME="::JAVA_HOME::" 3 | export PATH="::PATH::" 4 | trap "echo stopping hbase;/opt/hbase/bin/hbase master stop>>/var/log/hbase-stop.log 2>&1; exit" HUP INT TERM EXIT 5 | echo "starting hbase" 6 | /opt/hbase/bin/hbase master start 7 | -------------------------------------------------------------------------------- /files/start_opentsdb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export TSDB_VERSION="::TSDB_VERSION::" 3 | 4 | echo "listing /data/hbase" 5 | ls -lhat /data/hbase 6 | 7 | if [ ! -e /data/hbase/opentsdb_tables_created.txt ]; then 8 | echo "creating tsdb tables" 9 | bash /opt/bin/create_tsdb_tables.sh 10 | echo "created tsdb tables" 11 | fi 12 | 13 | echo "starting opentsdb" 14 | /usr/local/bin/tsdb tsd --port=4242 --staticroot=/usr/local/share/opentsdb/static --cachedir=/tmp --auto-metric 15 | --------------------------------------------------------------------------------