Skip to content

emqx/opentsdb-client-erl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opentsdb-client-erl

opentsdb-client-erl is an client which connects and pushes metrics to opentsdb server.

Both synchronous and asynchronous modes of operation are supported.

We will support more methods in opentsdb and more kinds of tsdb soon.

Basic usage

Start opentsdb-client-erl

To start in the console run:

$ erl -pa ebin -pa deps/*/ebin

To start opentsdb-client-erl:

Opts = [{url, "http://127.0.0.1:4242"},
		{summary, true},
		{details, false},
		{max_batch_size, 20}]
{ok, Pid} = opentsdb:start_link(Opts).

Sync put one or more metric

1> {ok, StatusCode, BodyMap} = opentsdb:put(Pid, #{metric => <<"sys.cpu.nice">>, value => 19, tags => #{host => web01}).

2> {ok, StatusCode, BodyMap} = opentsdb:put(Pid, [#{metric => <<"sys.cpu.nice">>, 
                                                    value => 19, 
                                                    tags => #{host => web01}},
                                                  #{metric => <<"sys.cpu.nice">>, 
                                                    timestamp => opentsdb:unix_timestamp(),
                                                    value => 13, 
                                                    tags => #{host => <<"web02">>}}]).

StatusCode is HTTP status code returned by opentsdb server.

The format of BodyMap is similar to:

#{<<"failed">> => 0, <<"success">> => 1}

Async put one or more metric

Just replace opentsdb:put to opentsdb:async_put.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •