Skip to content
Clojure wrapper for the Java InfluxDB client
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

InfluxDB Clojure

Dependencies Status Downloads

A simple InfluxDB client for Clojure, implemented as a wrapper around the Java InfluxDB client. Compatible with InfluxDB >= 0.9.

If you are lookig for officially supported InfluxDB clients please refer to this list.


Artifacts are released to Clojars.

If you are using Maven, add the following repository definition to your pom.xml:


The Most Recent Release

With Leiningen:

Clojars Project

With Maven:


With Gradle:

compile "influxdb:influxdb-clojure:0.2.0"


Require the influxdb-clojure namespace:

(require '[influxdb-clojure.core :as influxdb])

Open a connection:

(def conn (influxdb/connect "http://localhost:8086" "root", "root"))

Create a database:

(influxdb/create-database conn "mydb")

Show existing databases:

(influxdb/databases conn)
=> ("_internal" "mydb")

Delete a database:

(influxdb/delete-database conn "mydb")
(influxdb/databases conn)
=> ("_internal")

Writing Data

Write a point to a database (retention policy "default"):

(def point {:measurement "cpu_load_short"
            :fields {:value 0.64}
            :time 1462428815668
            :tags {:host "server01"
                   :region "us-west"}})
(influxdb/write-points conn "mydb" [point])

(The time is optional and will be set to the current system time if not explicitly set.)

Optionally, retention policy and consistency level may be specified:

(def opts {:retention-policy "six_month_rollup", :consistency-level :quorum})
(influxdb/write-points conn "mydb" [point] opts)

Querying Data

(influxdb/query conn "SHOW DATABASES")
{:results [{:series [{:name "databases",
                      :colums ["name"],
                      :values [["_internal"] ["mydb"]]}]}]}
(influxdb/query conn "SELECT * FROM \"cpu_load_short\" WHERE host='server01'" "mydb")
{:results [{:series [{:name "cpu_load_short",
                      :colums ["time" "host" "region" "value"],
                      :values [["2016-05-05T06:06:46.996Z" "server01" "us-west" 0.64]]}]}]}

HTTP Client Configuration

In some cases it may be useful to customize certain HTTP client parameters such as connect timeout. Timeout parameters can be passed as part of an option map when the connection is created (in ms):

(def opts {:connect-timeout 1000
           :read-timeout    5000
           :write-timeout   1000})
(def conn (influxdb/connect "http://localhost:8086" "root", "root" opts))

In case additional configuration for the HTTP client is required, a client instance can be passed instead:

(import (retrofit.client OkClient)
        (com.squareup.okhttp OkHttpClient)
        (java.util.concurrent TimeUnit))
(def http-client (OkHttpClient.))
(.setConnectTimeout http-client 5000 (TimeUnit/MILLISECONDS))
(.setReadTimeout http-client 5000 (TimeUnit/MILLISECONDS))
(def client (OkClient. http-client))
(def conn (influxdb/connect "http://localhost:8086" "root", "root" {:client client}))


Copyright © 2016 Matthias Nüßler

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

You can’t perform that action at this time.