PlotMachine is a tool for plotting key-value data.
The advatnage of PlotMachine is that it is simple to install
and simple to use.
Take a look:
plot
, dashboard.
PlotMachine is under active development.
Embedded:
So, please, forgive the temporarily ugly look.
Features
Free
Open source
Simple to install:
Install MySQL or PostgreSQL.
Does not require MySQL or PostgreSQL become comes with built-in Derby
but preferable to use MySQL or PostgreSQL.
Configure connection string
Drop in Tomcat, Jetty etc.
Start using
Simple to use
In order to add data, just pass key value on the URL
In order to view plots, define plots in JavaScript in a few seconds
How to
Prerequisites
Java 7
MySQL or PostgreSQL
Servlet container such as Tomcat or Jetty
How to install
Create DB in MySQL
Unzip
Configure conf.properties.
This is how it looks if you use MySQL:
#possible values: mysql, pg for postgres, comment out to use derby
store.db.type=mysql
#store.pg.url=jdbc:postgresql:monitor?user=USR&password=PWD
store.mysql.url=jdbc:mysql://localhost/monitor?user=USR&password=PWD
Configure log4j.properties to tell it where to write the log
Drop into Tomcat's webapps directory.
How to add data from an HTML page
Include the following before </body>:
<script language="javascript" type="text/javascript" src="http://WHERE_YOU_INSTALLED_PLOTMACHINE/js/plotmachine.api.js"></script>
Decide how you would like to call whatever you measure.
For example, let's call your measurement my_test
Add this to the page:
<script>PlotMachine.add('http://WHERE_YOU_INSTALLED_PLOTMACHINE', 'my_test', 1);</script>
How to add data directly to PlotMachine
Make an HTTP GET request to
http://WHERE_YOU_INSTALLED_PLOTMACHINE/api/plotmachine/data/add?name=KEY&value=VALUE
where name is the name of what you're measuring
and value is the current value of your measurement
First you must startup the Driver by passing the base URL where you installed PlotMachine
Example: com.scriptedstuff.plotmachine.PlotMachine.startup("http://SERVER:PORT/PATH"); Then you use the driver by feeding name of measurement + value:
com.scriptedstuff.plotmachine.PlotMachine.add("page_views", 1); In the end you must shut the driver:
com.scriptedstuff.plotmachine.PlotMachine.shutdown();
How to install
Prerequisites: Apache HTTPClient, HTTPCore and Codec.
Download HTTPClient and the 3 JARs are there.
Plus use the driver class: plotmachine.jar
How to plot data
Browse to http://WHERE_YOU_INSTALLED_PLOTMACHINE/plot.jsp
Define your plot in JavaScript
Example:
var name = 'my_plot';
var from = '-1 week';
var to = 'now';
var names = ['my_test'];
var refresh = 60000;
var x = 'time';
var y = 'my_test';
var points = 50;
Explanation:
name of the plot
from and to define the time period
You can use 'now', 'minute', 'hour', 'day', 'week', 'month', 'year'
examples: '-5 minutes', '-12 hours', '-10 days', '-2 weeks', '-3 months'
from and to can be in the format '10 Jan 2011 00:00:00'
names is an array of measurements you want to plot.
For example, if you want to plot registered users and guest visitors,
you will write: names = ['users', 'guests'];
refresh is the plot refresh rate in milliseconds
x and y and the names of the axes
points is the number of data points you want to see
every variable must be preceded by var
every statement must end in ;
name of plot and names of measurements must consist of english letters.
Instead of space use _
How to plot increasing data
In some cases the measured value keeps increasing.
For example I measure the number of JMS messages that have been sent since the server was started.
My server always returns the total since it was started and this total always grows.
In this case use:
var diff = true;
How to plot aggregated data
If you want to aggregate data by time period, use soemthing like:
var aggregate='1 hour';
IMPORTANT: when you use aggregate, do not use points
How to embed a plot in a web page
Define a plot as described above
Add this to your HTML:
Create a div for your plot. I noticed that jQuery sometimes needs defined size in pixels or percents
Call the plot:
<script>PlotMachine.embed('DOMAIN WHERE YOU RUN PLOTMACHINE', 'NAME OF YOUR PLOT', 'ID OF THE DIV');</script>
This page embeds a plot. Look at the source.
You can embed multiple plots on the same web page.
How to create a dashboard
Go to http://WHERE_YOU_INSTALLED_PLOTMACHINE/dashboard.jsp
Define a dashboard by setting name and plot names:
var name = 'views';
var plots = ['my_plot_a','my_plot_b'];