Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output plugin for timescaleDB #966

Open
poojabms opened this issue Jan 22, 2020 · 2 comments
Open

output plugin for timescaleDB #966

poojabms opened this issue Jan 22, 2020 · 2 comments

Comments

@poojabms
Copy link

Hi,

We are looking at sending alerts generated by riemann to timescaleDB(an extension to postgresDB). We don't see any plugin available already. Is there any plan of implementing one in near future? If not, what would be the best way to send the data to any database for which a plugin is not available? We don't have any expertise on clojure. so writing a clojure plugin would be the last option for us. Appreciate any other pointers/suggestions.

Thanks in advance.

@serge-medvedev
Copy link
Contributor

serge-medvedev commented Feb 6, 2020

You could send your events to RabbitMQ (or Kafka), pull them out via programming language of choice, process and then put into TimescaleDB.
Using RabbitMQ, though, would require functionality proposed in #968 .

@sanel
Copy link
Contributor

sanel commented Aug 26, 2021

I haven't used TimescaleDB and I'm not sure if TimescaleDB has fixed schema, but from this [1] it looks like the schema is designed ad-hoc.

I think this might work, assuming you have time, host, service and metric colums (can be adjusted down below).

(add-dependencies
 :coordinates [[org.clojure/java.jdbc "0.7.12"]]
 :repositories {"clojars" "https://clojars.org/repo"})

(require '[clojure.java.jdbc :as j])

(defn timescaledb [db-spec table]
 (fn [events]
   (doseq [event events]
     (j/insert! db-spec table
       ;; adjust columns if necessary
       {:host    (:host event)
        :service (:service event)
        :metric  (:metric event)
        :time    (:time event)}))))

(def timescale
  (timescaledb {:dbtype "postgresql"
                :dbname "mydatabase"}
               "mytable"))
(streams
 timescale)

[1] https://docs.timescale.com/timescaledb/latest/quick-start/java/#insert_rows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants