Graphite client for Elixir with zero dependencies
If available in Hex, the package can be installed as:
- Add
graphitex
to your list of dependencies inmix.exs
:
def deps do
[{:graphitex, "~> 0.1.0"}]
end
- Ensure
graphitex
is started before your application:
def application do
[applications: [:graphitex]]
end
- Set up configuration in
config.config.exs
:
config :graphitex, host: '188.166.101.102', port: 2003
- API:
Graphitex.metric(4, "aws.cluster_one.avg_cpu")
# or
Graphitex.metric(4, ["aws", "cluster_one", "avg_cpu"])
# or
Graphitex.metric(41.0, [:aws, :cluster_one, :avg_cpu])
by default :os.system_time(:seconds)
used as timestamp, but you can pass ts
as an argument
Graphitex.metric(41, "aws.cluster_one.avg_cpu",:os.system_time(:seconds))
likewise there is a shortcut
Graphitex.metric(41, "aws.cluster_one.avg_cpu", Graphitex.now)
Insert batch:
[{4, "client.transactions.east"},
{2, "client.transactions.west"},
{5, "client.transactions.north", Graphitex.now}
]
|> Graphitex.metric_batch(batch)