I'm new to OpenTSDB. I somehow managed to install and configure OpenTSDB, but I don't know how to put data into OpenTSDB from client. Can anyone of you help me?
The short answer is that those "put name timestamp value [tags]
" commands are the network protocol for adding data to OpenTSDB over TCP/IP. So from your Java program, you can open a TCP socket to the TSD port and start writing commands to add your data.
Obviously, that still leaves a lot of details an an excercise to the reader.
You didn't specify in your question how, or even if, you're collecting time series data that you want to store. How complicated it is to periodically push data into TSD from your application will depend on what you're doing there. If you're using the excellent Yammer/Coda Hale Metrics library to collect data (and in Java, there really isn't a slicker way to do it, that I know of)
Metrics includes a reporter interface with several implementations for other statistics repositories like Graphite and Ganglia. You can easily implement one for OpenTSDB (in fact, someone already has - I'm trying to find the pull request on github but failing; I'll update this when I find it).
Have you read the getting started guide
You have several options. Once started, and metrics created via ./tsdb mkmetric mymetric.data_1 mymetric.data_2
, you can batch import files written in the form
metric_name timestamp value tags e.g.
mymetric.data_1 1295643636 48 a=foo
then you can ./tsdb import file
An other way is to "telnet" commands to the server in the same form as above, but with the put keyword, like echo "put mymetric.data_1 1295643636 48 a=foo" | nc -w 15 tsdHost tsdPort
(linux way :-) )
Check out the OpenTSDB 2.0 documentation: http://opentsdb.net/docs/build/html/ This will provide better insight in adding data into openTSDB. Moreover, openTSDB2.0 has HTTP api to put data.
You can read Input Methods in the documentation. Also I find it useful for me to read Data Specification, to understand what every time series consists of.
来源:https://stackoverflow.com/questions/8520612/how-to-insert-data-in-opentsdb-time-series-database