Skip to content

Instantly share code, notes, and snippets.

@segphault
Last active October 5, 2018 08:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save segphault/ca421568506840e05a8d to your computer and use it in GitHub Desktop.
Save segphault/ca421568506840e05a8d to your computer and use it in GitHub Desktop.
Pipe data from a RethinkDB changefeed into Plotti

RethinkDB Changfeeds and Plottico

This example shows how to take the output of a RethinkDB changefeed and send it to Plottico, a microservice that generates embeddable streaming graphs. This example uses Plottico's hosted infrastructure, but you can also self-host your own Plottico server using the code from Plottico's GitHub repository.

require "net/http"
require "rethinkdb"
include RethinkDB::Shortcuts
conn = r.connect()
changes = r.db("rethinkdb").table("stats").get(["cluster"])
.changes()["new_val"]["query_engine"].run(conn)
changes.each do |stats|
data = [stats["queries_per_sec"],
stats["read_docs_per_sec"],
stats["written_docs_per_sec"]].join(",")
Net::HTTP.get(URI.parse("http://plotti.co/mygraph?d=#{data}"))
end
<html>
<body>
<h1>RethinkDB Plotti Sample</h1>
<object data="http://plotti.co/mygraph/plot.svg" type="image/svg+xml"></object>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment