Skip to content

Instantly share code, notes, and snippets.

@chenchun
Last active July 1, 2016 08:14
Show Gist options
  • Save chenchun/c80bcba8e92dc6947475a96c2db621e3 to your computer and use it in GitHub Desktop.
Save chenchun/c80bcba8e92dc6947475a96c2db621e3 to your computer and use it in GitHub Desktop.
opentsdb
rest api
http://localhost:4242/api/query?start=1466564936&m=avg:20s-max:rate:cpu_usage_total{queue=gaia_queue,user=11,appName=rami_test,instance=3}
curl 'http://localhost:4242/api/query?start=1466564936&m=avg:20s-max:rate:cpu_usage_total\{queue=root.demo,user=null,appName=rami,instanceId=1\}'
put sys.cpu.user 1356998400 1 h=w1 c=0
put sys.cpu.user 1356998401 3 h=w1 c=1
put sys.cpu.user 1356998400 5 h=w2 c=0
put sys.cpu.user 1356998402 7 h=w2 c=1

###tsdb-uid

  • sort(tagk1,tagk2...)
  • key compress
  • 正向/反向索引
rowkey column family:id column family:name
metrics tagk tagv metrics tagk tagv
00 1 2 4
000001 sys.cpu.user c 0
000002 h w1
000003 1
000004 w2
0 000001
1 000003
c 000001
h 000002
sys.cpu.user 000001
w1 000002
w2 000004

###tsdb

  • timestamp%3600
  • len(rowkey)=3(metrix)+4(timestamp)+(3(tagk)+3(tagv))*2(num)=19bytes
  • key均匀散列
  • row compress
rowkey column family:t
metric timestamp tagk tagv tagk tagv +0 +1 +2 ... +3599
000001 50E22700 000001 000001 000002 000002 1
000001 50E22700 000001 000001 000002 000004 5
000001 50E22700 000001 000003 000002 000002 3
000001 50E22700 000001 000003 000002 000004 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment