Skip to content

Instantly share code, notes, and snippets.

@stanaka
Last active December 7, 2016 13:15
Show Gist options
  • Save stanaka/eae027169de6a35dd76a to your computer and use it in GitHub Desktop.
Save stanaka/eae027169de6a35dd76a to your computer and use it in GitHub Desktop.
save this html as a local file, then open the file.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Mackerel Graph Builder</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
function update() {
var d = $("#def")[0].value;
var o = $("#org")[0].value;
localStorage.setItem("orgName", o);
var p = $("#period")[0].value;
var u = $("#unit")[0].value;
var title = $("#title")[0].value;
var target = "https://mackerel.io/embed/orgs/" + o +
"/advanced-graph?query=" + d.replace(/[\n ]/g, '') +
"&unit=" + u +
"&period=" + p +
"&title=" + title;
var t = $("#target");
t.prepend('<div><iframe src="' + target +'" height="400" width="600" frameborder="0"></iframe><pre>' + d + '</pre></div>');
return true;
};
</script>
<script type="text/javascript">
window.onload = function(){
var o = localStorage.getItem("orgName");
if(o){
$("#org").val(o);
}
};
</script>
</head>
<body>
<h1>Mackerel Graph Builder</h1>
https://mackerel.io/embed/orgs/&lt;organization&gt;/advanced-graph?query=
<form>
organization: <input type="text" value="" id=org> (saved to LocalStorage)<br />
<textarea cols=100 rows=20 id="def">group(
alias(
avg(
timeShift(
role('foo:app','loadavg5'),
'1w'
)
),
'avg-lastweek'
),
alias(
avg(
role('foo:app','loadavg5')
),
'avg'
)
)</textarea><br />
period: <input type="text" value="1d" id=period><br />
unit: <input type="text" value="" id=unit><br />
title: <input type="text" value="formula graph" id=title><br />
<input type="button" value="submit" onclick="update()">
</form>
<div id="target"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment