Seven Story Rabbit Hole

Sometimes awesome things happen in deep rabbit holes. Or not.

   images

Graphing Time Series Data With Seriesly and Cubism

This will walk you through the basics of putting data into seriesly and visualizing it with cubism.

You will end up with this in your browser:

screenshot

Install seriesly

1
go get -u -v -t github.com/dustin/seriesly

Run seriesly

1
seriesly -flushDelay=1s -root=/tmp/seriesly-data

and leave it running in the background.

Create a db

In another shell:

1
curl -X PUT http://localhost:3133/testdb

Write docs to db

This script will write json docs with random values for the purpose of visualization.

Copy the following to add_seriesly_docs.rb

1
2
3
4
5
6
7
8
9
#!/usr/bin/env ruby

6000.times do |count|
  randomNumber = rand() # random number between 0 and 1
  cmd = "curl -X POST -d '{\"index\":#{randomNumber}}' http://localhost:3133/testdb"
  puts cmd
  system(cmd)
  system("sleep 1")
end

and then run it

1
chmod +x add_seriesly_docs.rb && ./add_seriesly_docs.rb

and let it continue running in the background.

Create a webserver

Create a directory:

1
2
mkdir /tmp/seriesly-http/
cd /tmp/seriesly-http/

Create fileserver.go:

1
2
3
4
5
package main
import "net/http"
func main() {
        panic(http.ListenAndServe(":8080", http.FileServer(http.Dir("/tmp/seriesly-http/"))))
}

Run webserver:

1
go run fileserver.go

Download seriesly.html file

This is a file I wrote which uses seriesly as a metric data source for cubism.

It’s a quick hack, since I couldn’t manage to get seriesism.js working.

1
2
cd /tmp/seriesly-http/
wget https://gist.githubusercontent.com/tleyden/ec0c9be5786e0c0bd9ba/raw/1c08ea13b8ce46e08a49df19ad44c8e6a0ade896/seriesly.html

Open seriesly.html

In your browser, point to http://localhost:8080/seriesly.html

At this point, you should see the screenshot at the beginning of the blog post.

References

Comments