A Clojure client for InfluxDB.
Follow the [download instructions on influxdb.com] (https://influxdata.com/downloads/) to install the latest version of InfluxDB.
Support for InfluxDB v0.8.x is removed starting with v0.6.0.
Capacitor is distributed via Clojars. Add the
following to your dependencies in project.clj:
:dependencies [[capacitor "0.6.0"]](use 'capacitor.core)(defclient (make-client {:db"mynewdb"}))The default-client options are:
{:host"localhost":scheme"http":port8086:username"root":password"root":db"testdb":version"0.9"}(version client)
;; => "0.11.0"(ping client)
;; => 2.479 (response time in ms)(create-db client)
;; => true(list-dbs client)
;; => ("_internal" "mynewdb")(create-db-user client "myuser""mypassword")
;; => true(list-db-users client)
;; => [{:columns ["user" "admin"], :values [["myuser" false]]}]You can also zipmap columns with their values adding a :results key:
(list-db-users client true)
;; => ({:results ({:admin false, :user "myuser"})})(defc (make-client {:db"mynewdb":username"myuser":password"mypassword"}))A point can be a map containing the following keys:
(write-point c
{:measurement"cpu_load":tags {"host""1""dc"1}
:fields {"value"1.1}
:timestamp1457624412})Which can be shortened to a vector:
(write-point c
;; measurement tags fields timestamp
["cpu_load" {"host""1""dc"1} {"value"1.2} 1457624413])You can write multiple points at once with write-points:
(write-points c
[{:measurement"cpu_load":tags {"host""2""dc"1}
:fields {"value"0.4}
:timestamp1457624412}
{:measurement"cpu_load":tags {"host""3""dc"1}
:fields {"value"0.8}
:timestamp1457624412}])Or use the vector form for points:
(write-points c
[["cpu_load" {"host""8""dc"2} {"value"0.7} 1457624412]
["cpu_load" {"host""9""dc"2} {"value"0.5} 1457624412]])(db-query c "SHOW SERIES"true)
(db-query c "SELECT * FROM cpu_load"true)
(db-query c "SELECT MAX(value) FROM cpu_load GROUP BY dc, host"true)Copyright © 2013–2016 Olivier Lauzon
Distributed under the Eclipse Public License.
