Skip to content

Commit 6b3597e

Browse files
authored
Merge pull request #19 from nvtkaszpir/opentsdb
OpenTSDB updates
2 parents db1addb + 3cc93dc commit 6b3597e

9 files changed

+255
-30
lines changed

charts/opentsdb/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ maintainers:
99
1010
name: cgiraldo
1111
name: opentsdb
12-
version: 0.1.1
12+
version: 0.1.2

charts/opentsdb/ci/basic.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
daemons: 2

charts/opentsdb/ci/custom-values.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
env:
3+
init: # env values for init container
4+
BLOOMFILTER: "ROW"
5+
META_TABLE: "month-tsdb-meta"
6+
TREE_TABLE: "month-tsdb-tree"
7+
TSDB_TABLE: "month-tsdb"
8+
UID_TABLE: "month-tsdb-uid"
9+
COMPRESSION: "GZ" # Use one of LZO ZSTD GZ LZ4 NONE Algorithm BZIP2 SNAPPY, based on your hbase and hadoop config
10+
TSDB_TTL: "2592000" # 30d
11+
DATA_BLOCK_ENCODING: "DIFF"
12+
opentsdb:
13+
14+
init_hbase_script: |
15+
create '$UID_TABLE',
16+
{NAME => 'id', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'},
17+
{NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'}
18+
create '$TSDB_TABLE',
19+
{NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING', TTL => '$TSDB_TTL'}
20+
create '$TREE_TABLE',
21+
{NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'}
22+
create '$META_TABLE',
23+
{NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'}
24+
25+
antiAffinity: "hard"
26+
daemons: 3
27+
28+
conf:
29+
# tsd.storage.hbase.zk_quorum: "zk-zookeeper:2181"
30+
tsd.http.request.enable_chunked: "true"
31+
tsd.http.request.max_chunk: "262144"
32+
tsd.query.skip_unresolved_tagvs: "true"
33+
tsd.http.request.cors_domains: "*"
34+
tsd.storage.hbase.data_table: "month-tsdb"
35+
tsd.storage.hbase.meta_table: "month-tsdb-meta"
36+
tsd.storage.hbase.tree_table: "month-tsdb-tree"
37+
tsd.storage.hbase.uid_table: "month-tsdb-uid"
38+
39+
# empty entries, force all logging to debug level
40+
logback:
41+
level_root:
42+
level_treshold:
43+
level_querylog:
44+
level_hbase:
45+
level_stumbleupon:
46+
level_core:
47+
level_graph:
48+
level_meta:
49+
level_search:
50+
level_stats:
51+
level_tools:
52+
level_tree:
53+
level_tsd:
54+
level_conn_mgr:
55+
level_graph_handler:
56+
level_query:
57+
level_uid:
58+
level_utils:
59+
pattern:
60+
61+
62+
# hbase configmap, needed to create tables in hbase
63+
# hbaseConfigMapName: "hbase-hbase"
64+
65+
# dependencies
66+
hbase:
67+
enabled: true
68+
antiAffinity: "hard"
69+
hbase:
70+
master:
71+
replicas: 3
72+
regionServer:
73+
replicas: 3
74+
hdfs:
75+
enabled: true
76+
antiAffinity: "hard"
77+
dataNode:
78+
replicas: 5
79+
persistence:
80+
nameNode:
81+
enabled: true
82+
accessMode: ReadWriteOnce
83+
size: 5Gi
84+
dataNode:
85+
enabled: true
86+
accessMode: ReadWriteOnce
87+
size: 10Gi
88+
zookeeper:
89+
enabled: true
90+
replicaCount: 3
91+
affinity:
92+
podAntiAffinity:
93+
requiredDuringSchedulingIgnoredDuringExecution:
94+
- topologyKey: "kubernetes.io/hostname"
95+
labelSelector:
96+
matchLabels:
97+
release: zookeeper
98+
persistence:
99+
enabled: true
100+
accessMode: ReadWriteOnce
101+
size: 1Gi
Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#!/bin/sh
2-
set -e
3-
COMPRESSION=GZ
1+
#!/bin/bash
2+
#set -x # increase verbosity
3+
set -e # exit on error
4+
set -a # export vars as env vars
45
# Small script to setup the HBase tables used by OpenTSDB.
6+
# notice that this can be also set as ENV var inside of container image (as in dockerfile)
57
test -n "$HBASE_PREFIX" || {
68
echo >&2 'The environment variable HBASE_PREFIX must be set'
79
exit 1
@@ -18,37 +20,48 @@ TREE_TABLE=${TREE_TABLE-'tsdb-tree'}
1820
META_TABLE=${META_TABLE-'tsdb-meta'}
1921
BLOOMFILTER=${BLOOMFILTER-'ROW'}
2022
# LZO requires lzo2 64bit to be installed + the hadoop-gpl-compression jar.
21-
COMPRESSION=${COMPRESSION-'LZO'}
23+
COMPRESSION=${COMPRESSION-'GZ'}
2224
# All compression codec names are upper case (NONE, LZO, SNAPPY, etc).
23-
COMPRESSION=`echo "$COMPRESSION" | tr a-z A-Z`
25+
COMPRESSION=${COMPRESSION^^}
26+
# DIFF encoding is very useful for OpenTSDB's case that many small KVs and common prefix.
27+
# This can save a lot of storage space.
28+
DATA_BLOCK_ENCODING=${DATA_BLOCK_ENCODING-'DIFF'}
29+
DATA_BLOCK_ENCODING=${DATA_BLOCK_ENCODING^^}
30+
# set 'time to live' in seconds for data, allows automatic data retention which will be handled by HBase itself
31+
TSDB_TTL=${TSDB_TTL-'FOREVER'}
2432

2533
case $COMPRESSION in
26-
(NONE|LZO|GZIP|SNAPPY) :;; # Known good.
34+
(NONE|LZO|GZ|SNAPPY) :;; # Known good.
2735
(*)
2836
echo >&2 "warning: compression codec '$COMPRESSION' might not be supported."
2937
;;
3038
esac
31-
echo "checking if opentsdb $UID_TABLE hbase table exists"
39+
# test if compression algorithm is supported by hbase installation (lowercase compression var)
40+
echo "Checking if given compression is supported..."
41+
$HBASE_PREFIX/bin/hbase org.apache.hadoop.hbase.util.CompressionTest file:///tmp/testfile ${COMPRESSION,,}
42+
43+
case $DATA_BLOCK_ENCODING in
44+
(NONE|PREFIX|DIFF|FAST_DIFF|ROW_INDEX_V1) :;; # Know good
45+
(*)
46+
echo >&2 "warning: encoding '$DATA_BLOCK_ENCODING' might not be supported."
47+
;;
48+
esac
49+
50+
# render hbase script to fill in env vars
51+
( echo "cat <<EOF" ; cat /tmp/init/hbase_script.txt ; echo ; echo EOF ) | bash > $HBASE_PREFIX/conf/hbase_script_parsed.txt
52+
echo "HBase script:"
53+
echo "----"
54+
cat $HBASE_PREFIX/conf/hbase_script_parsed.txt
55+
echo "----"
56+
57+
echo "Checking if opentsdb $UID_TABLE hbase table exists"
3258
ret=$( echo "exists '$UID_TABLE'" | $HBASE_PREFIX/bin/hbase shell -n )
3359
if [[ $ret == *"true"* ]];
3460
then
3561
echo "OpenTSDB tables already created."
3662
exit 0
3763
else
3864
echo "Creating OpenTSDB hbase tables:"
39-
$HBASE_PREFIX/bin/hbase shell -n << EOF
40-
create '$UID_TABLE',
41-
{NAME => 'id', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'},
42-
{NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}
43-
44-
create '$TSDB_TABLE',
45-
{NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}
46-
47-
create '$TREE_TABLE',
48-
{NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}
49-
50-
create '$META_TABLE',
51-
{NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}
52-
EOF
53-
echo "DONE"
54-
fi
65+
$HBASE_PREFIX/bin/hbase shell -n $HBASE_PREFIX/conf/hbase_script_parsed.txt
66+
echo "DONE"
67+
fi
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration debug="true" scan="true" scanPeriod="60 seconds" >
3+
<!-- reference https://logback.qos.ch/manual/appenders.html -->
4+
<!--<jmxConfigurator/>-->
5+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
6+
<!--
7+
deny all events with a level below INFO, that is TRACE and DEBUG
8+
https://logback.qos.ch/manual/filters.html
9+
-->
10+
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
11+
<level>{{ default "DEBUG" .Values.logback.level_treshold }}</level>
12+
</filter>
13+
<encoder>
14+
<pattern>
15+
{{ default "%d{ISO8601} %-5level [%thread] %logger{0}: %msg%n" .Values.logback.pattern }}
16+
</pattern>
17+
</encoder>
18+
</appender>
19+
<logger name="net.opentsdb.core" level="{{ default "DEBUG" .Values.logback.level_core }}"/>
20+
<logger name="net.opentsdb.graph" level="{{ default "DEBUG" .Values.logback.level_graph }}"/>
21+
<logger name="net.opentsdb.meta" level="{{ default "DEBUG" .Values.logback.level_meta }}"/>
22+
<logger name="net.opentsdb.search" level="{{ default "DEBUG" .Values.logback.level_search }}"/>
23+
<logger name="net.opentsdb.stats" level="{{ default "DEBUG" .Values.logback.level_stats }}"/>
24+
<logger name="net.opentsdb.tools" level="{{ default "DEBUG" .Values.logback.level_tools }}"/>
25+
<logger name="net.opentsdb.tree" level="{{ default "DEBUG" .Values.logback.level_tree }}"/>
26+
<logger name="net.opentsdb.tsd" level="{{ default "DEBUG" .Values.logback.level_tsd }}"/>
27+
<logger name="net.opentsdb.tsd.ConnectionManager" level="{{ default "DEBUG" .Values.logback.level_conn_mgr }}"/>
28+
<logger name="net.opentsdb.tsd.GraphHandler" level="{{ default "DEBUG" .Values.logback.level_graph_handler }}"/>
29+
<logger name="net.opentsdb.tsd.HttpQuery" level="{{ default "DEBUG" .Values.logback.level_query }}"/>
30+
<logger name="net.opentsdb.uid" level="{{ default "DEBUG" .Values.logback.level_uid }}"/>
31+
<logger name="net.opentsdb.utils" level="{{ default "DEBUG" .Values.logback.level_utils }}"/>
32+
<!-- Per class logger levels -->
33+
<logger name="QueryLog" level="{{ default "DEBUG" .Values.logback.level_querylog }}" additivity="false">
34+
<appender-ref ref="STDOUT"/>
35+
</logger>
36+
<logger name="org.hbase.async" level="{{ default "DEBUG" .Values.logback.level_hbase }}"/>
37+
<logger name="com.stumbleupon.async" level="{{ default "DEBUG" .Values.logback.level_stumbleupon }}"/>
38+
<!-- Fallthrough root logger and router -->
39+
<root level="{{ default "DEBUG" .Values.logback.level_root }}">
40+
<appender-ref ref="STDOUT"/>
41+
</root>
42+
</configuration>

charts/opentsdb/templates/opentsdb-configmap.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ metadata:
88
data:
99
opentsdb.conf: |-
1010
{{ tpl (.Files.Get "resources/config/opentsdb.conf") . | indent 4 }}
11+
logback.xml: |
12+
{{ tpl (.Files.Get "resources/config/logback.xml") . | indent 4 }}

charts/opentsdb/templates/opentsdb-init-configmap.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ metadata:
77
{{- include "opentsdb.labels" . | nindent 4 }}
88
data:
99
create_hbase_tables.sh: |-
10-
{{ tpl (.Files.Get "resources/config/create_hbase_tables.sh") . | indent 4 }}
10+
{{ tpl (.Files.Get "resources/config/create_hbase_tables.sh") . | indent 4 }}
11+
hbase_script.txt: |-
12+
{{ .Values.init_hbase_script | indent 4 }}

charts/opentsdb/templates/opentsdb-statefulset.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ spec:
4141
- name: opentsdb-create-hbase-tables
4242
image: "{{ .Values.hbaseImage.repository }}:{{ .Values.hbaseImage.tag }}"
4343
command: ['bash', '/tmp/init/create_hbase_tables.sh']
44+
env:
45+
{{- range $key, $value := .Values.env.init }}
46+
- name: {{ $key | quote }}
47+
value: {{ $value | quote }}
48+
{{- end }}
4449
volumeMounts:
4550
- name: opentsdb-init
4651
mountPath: /tmp/init
@@ -50,11 +55,16 @@ spec:
5055
- name: opentsdb
5156
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
5257
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
58+
env:
59+
{{- range $key, $value := .Values.env.opentsdb }}
60+
- name: {{ $key | quote }}
61+
value: {{ $value | quote }}
62+
{{- end }}
5363
resources:
5464
{{ toYaml .Values.resources | indent 10 }}
5565
readinessProbe:
5666
httpGet:
57-
path: /
67+
path: /stats # it triggers connection to hbase
5868
port: 4242
5969
initialDelaySeconds: 60
6070
timeoutSeconds: 15

charts/opentsdb/values.yaml

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,76 @@ hbaseImage:
1414
repository: gradiant/hbase-base
1515
tag: 2.0.1
1616

17-
hbaseConfigMapName: # Default hbaseConfigMapName is {{ .Release.Name}}-hbase
17+
hbaseConfigMapName: # Default hbaseConfigMapName is {{ .Release.Name}}-hbase
1818

19-
# Select antiAffinity as either hard or soft, default is soft
19+
# Select antiAffinity as either hard or soft, default is 'soft'
20+
# 'hard' is for production setups
2021
antiAffinity: "soft"
2122

22-
# Initial number of tsd daemons
23+
# Initial number of tsd replicas
2324
daemons: 1
2425
port: 4242
2526
nodePort:
2627
enabled: false
2728
externalPort: 31042
2829

30+
# pass env vars to the opentsdb or init-container
31+
env:
32+
init: # env values for init container
33+
# BLOOMFILTER: 'ROW'
34+
# META_TABLE: 'tsdb-meta'
35+
# TREE_TABLE: 'tsdb-tree'
36+
# TSDB_TABLE: 'tsdb'
37+
# UID_TABLE: tsdb-uid'
38+
COMPRESSION: "GZ" # Use one of LZO ZSTD GZ LZ4 NONE Algorithm BZIP2 SNAPPY
39+
# TSDB_TTL: 'FOREVER'
40+
# DATA_BLOCK_ENCODING: 'DIFF'
41+
opentsdb:
42+
43+
# hbase init script to create hbase tables, where $VARS are env vars from env.init (above), if empty then default will be used
44+
init_hbase_script: |
45+
create '$UID_TABLE',
46+
{NAME => 'id', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'},
47+
{NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}
48+
create '$TSDB_TABLE',
49+
{NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}
50+
create '$TREE_TABLE',
51+
{NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}
52+
create '$META_TABLE',
53+
{NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'}
54+
55+
# configure /etc/opentsdb/opentsdb.conf contents
2956
conf:
3057
tsd.storage.hbase.zk_quorum: # default is "{{.Release.Name}}-zookeeper:2181"
3158
tsd.core.auto_create_metrics: true
3259
tsd.core.auto_create_tagks: true
3360
tsd.core.auto_create_tagvs: true
61+
# tsd.storage.hbase.data_table: tsdb
62+
# tsd.storage.hbase.meta_table: tsdb-meta
63+
# tsd.storage.hbase.tree_table: tsdb-tree
64+
# tsd.storage.hbase.uid_table: tsdb-uid
65+
66+
# configure /etc/opentsdb/logback.xml contents
67+
logback:
68+
level_root: "DEBUG" # main java logger level
69+
level_treshold: "WARN" # change to INFO to see more in the logs itself
70+
level_querylog: "WARN"
71+
level_hbase: "WARN"
72+
level_stumbleupon: "WARN"
73+
level_core: "INFO"
74+
level_graph: "INFO"
75+
level_meta: "INFO"
76+
level_search: "INFO"
77+
level_stats: "INFO"
78+
level_tools: "INFO"
79+
level_tree: "INFO"
80+
level_tsd: "INFO"
81+
level_conn_mgr: "WARN"
82+
level_graph_handler: "WARN"
83+
level_query: "WARN"
84+
level_uid: "INFO"
85+
level_utils: "INFO"
86+
pattern: "%d{ISO8601} %-5level [%thread] %logger{0}: %msg%n"
3487

3588
resources:
3689
requests:
@@ -40,6 +93,6 @@ resources:
4093
memory: "2048Mi"
4194
cpu: "1000m"
4295

96+
# manage hbase from dependencies
4397
hbase:
4498
enabled: true
45-

0 commit comments

Comments
 (0)