RESTful API for creating a chart

By using RESTful API, it can extract data, and then connect the data with external applications. The user can also visualize the data by using the JavaScript chart library.

RESTFul API Server
You can use RESTful API while the mach webadmin runs.

Data Entry
Create the entry program by using CLI, JDBC, and Python.You can also enter the data by using Collector Guide.

Write a JS Chart
You can describe how to generate the chart by using chart.js (open-source). It can work with other chart libraries as well.

When getting the result values by executing an SQL statement using the GET method and RESTful API, generate the chart after adjusting data to the chart library. Refer to the sample code below. To create a query based on each time period, refer to format string from Built-In Functions.

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="-1"/>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
var data = {
labels : [],
datasets : [
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
data : []
<h2> apache access log per 30 min</h2>
<div class="chartWrap" style="position:relative;margin:10px auto;width:96%;height:500px;">
<canvas id="ifChart"></canvas>

var sql = "select TO_CHAR(time, 'YYYY-MM-DD HH24:MI30') as x, count(host) as y from apache_access_log group by x order by 1 asc duration 1 day";

url: '',
data: 'q='+encodeURIComponent(sql),
beforeSend: function() {
success: function(resp) {
$.each($.parseJSON('['+resp+']'), function(n,v) {
data.labels[n] = v.x;
data.datasets[0].data[n] = v.y;

var canvas = document.getElementById("ifChart");
canvas.width = $('.chartWrap').width();
canvas.height = $('.chartWrap').height();
var ctx = canvas.getContext("2d");

new Chart(ctx).Bar(data);
error: function(request,status,err) {
alert(request.status+':'+request.responseText+'\n'+status + '\n' + err);
complete: function() {

It needs the results from GROUP BY clause with a specified time range due to the characteristics of time series data. Machbase provides the query syntax to get fast query results as follows.

It provides date formats such as "MI30" to easily get the results on a half hourly basis.
select to_char(time, 'YYYY-MM-DD HH24:MI30') as x, count(*) as y from apache_access_log group by x order by 1 asc duration 1 day.
However, when there are more data, the performance time for the query execution will be increased. Therefore, it requires much faster query syntax. To get the results every 30 minute, write queries as follows.

select to_char(date_trunc('minute', time, 30),'YYYY-MM-DD HH24:MI') as x, count(*) as y from apache_access_log group by x order by 1 asc duration 1 day;

results matching ""

    No results matching ""