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.
Last active
October 5, 2018 08:22
-
-
Save segphault/ca421568506840e05a8d to your computer and use it in GitHub Desktop.
Pipe data from a RethinkDB changefeed into Plotti
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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