https://github.com/kopera/erlang-influxdb
Erlang/Elixir InfluxDB client
https://github.com/kopera/erlang-influxdb
Last synced: 11 months ago
JSON representation
Erlang/Elixir InfluxDB client
- Host: GitHub
- URL: https://github.com/kopera/erlang-influxdb
- Owner: kopera
- License: other
- Created: 2017-03-28T10:58:13.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2025-06-10T07:55:30.000Z (about 1 year ago)
- Last Synced: 2025-07-05T19:37:38.195Z (12 months ago)
- Language: Erlang
- Size: 17.6 KB
- Stars: 6
- Watchers: 1
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# erlang-influxdb
[InfluxDB](https://www.influxdata.com/time-series-platform/influxdb/) client library for Erlang.
## Building
$ rebar3 compile
## Interactive session
The output has been reformatted for readability.
Erlang/OTP 19 [erts-8.0.2] [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]
Eshell V8.0.2 (abort with ^G)
1> application:ensure_all_started(influxdb).
{ok, [jsone, influxdb]}
2> Config = influxdb_config:new(#{host => "localhost", username => "root", password => "root"}).
#{host => "localhost", password => "root", port => 8086, username => "root"}
3> influxdb:query(Config, "show databases").
{ok,[[#{name => <<"databases">>,
columns => [<<"name">>],
rows => [{<<"_internal">>}]}]]}
4> influxdb:query(Config, "create database test").
ok
5> influxdb:query(Config, "show databases").
{ok,[[#{name => <<"databases">>,
columns => [<<"name">>],
rows => [{<<"_internal">>}, {<<"test">>}]}]]}
6> influxdb:write(Config#{database => "test"}, [{"cpu_load_short",
#{"region" => "af-west", "host" => "server01"},
#{"value" => 0.64}}]).
ok
7> influxdb:write(Config#{database => "test"}, [{"cpu_load_short",
#{"region" => "af-west", "host" => "server02"},
#{"value" => 0.67}}]).
ok
8> influxdb:query(Config#{database => "test"}, "select * from cpu_load_short").
{ok,[[#{name => <<"cpu_load_short">>,
columns => [<<"time">>, <<"host">>, <<"region">>, <<"value">>],
rows => [
{1474124935934979502, <<"server01">>, <<"af-west">>, 0.64},
{1474124961985106195, <<"server02">>, <<"af-west">>, 0.67}]}]]}
9> influxdb:query(Config#{database => "test"}, "select * from cpu_load_short group by host").
{ok,[[#{name => <<"cpu_load_short">>,
tags => #{<<"host">> => <<"server01">>},
columns => [<<"time">>, <<"region">>, <<"value">>],
rows => [{1474124935934979502, <<"af-west">>, 0.64}]},
#{name => <<"cpu_load_short">>,
tags => #{<<"host">> => <<"server02">>},
columns => [<<"time">>, <<"region">>, <<"value">>],
rows => [{1474124961985106195, <<"af-west">>, 0.67}]}]]}
10> influxdb:query(Config#{database => "test"}, "select * from cpu_load_short group by host; select * from cpu_load_short").
{ok,[[#{name => <<"cpu_load_short">>,
tags => #{<<"host">> => <<"server01">>},
columns => [<<"time">>, <<"region">>, <<"value">>],
rows => [{1474124935934979502, <<"af-west">>, 0.64}]},
#{name => <<"cpu_load_short">>,
tags => #{<<"host">> => <<"server02">>},
columns => [<<"time">>, <<"region">>, <<"value">>],
rows => [{1474124961985106195, <<"af-west">>, 0.67}]}],
[#{name => <<"cpu_load_short">>,
columns => [<<"time">>, <<"host">>, <<"region">>, <<"value">>],
rows => [
{1474124935934979502, <<"server01">>, <<"af-west">>, 0.64},
{1474124961985106195, <<"server02">>, <<"af-west">>, 0.67}]}]]}