provide a default group by time for host page

pull/10616/head
Jade McGough 2016-11-11 02:49:14 -08:00
parent ec2af515bb
commit 3de787d457
7 changed files with 14 additions and 10 deletions

View File

@ -12,7 +12,7 @@
"name": "CPU Usage",
"queries": [
{
"query": "SELECT \"usage_user\" FROM \"telegraf\"..\"cpu\"",
"query": "SELECT mean(\"usage_user\") FROM \"telegraf\"..\"cpu\"",
"db": "telegraf",
"rp": "autogen",
"groupbys": [],

View File

@ -12,7 +12,7 @@
"name": "Disk used %",
"queries": [
{
"query": "select used_percent from disk",
"query": "select mean(used_percent) from disk",
"db": "telegraf",
"rp": "autogen",
"groupbys": [

View File

@ -10,7 +10,7 @@
"i": "4c79cefb-5152-410c-9b88-74f9bff7ef22",
"name": "Docker - Container CPU",
"queries": [{
"query": "SELECT \"usage_percent\" FROM \"docker_container_cpu\"",
"query": "SELECT mean(\"usage_percent\") FROM \"docker_container_cpu\"",
"db": "telegraf",
"rp": "autogen",
"groupbys": ["\"container_name\""],
@ -25,7 +25,7 @@
"i": "4c79cefb-5152-410c-9b88-74f9bff7ef00",
"name": "Docker - Container Memory",
"queries": [{
"query": "SELECT \"usage\" FROM \"docker_container_mem\"",
"query": "SELECT mean(\"usage\") FROM \"docker_container_mem\"",
"db": "telegraf",
"rp": "autogen",
"groupbys": ["\"container_name\""],

View File

@ -12,7 +12,7 @@
"name": "System Load",
"queries": [
{
"query": "SELECT \"load1\" FROM \"telegraf\"..\"system\"",
"query": "SELECT mean(\"load1\") FROM \"telegraf\"..\"system\"",
"db": "telegraf",
"rp": "autogen",
"groupbys": [],

View File

@ -12,7 +12,7 @@
"name": "Memory bytes used",
"queries": [
{
"query": "SELECT \"used\", \"available\" FROM \"telegraf\"..\"mem\"",
"query": "SELECT mean(\"used\"), mean(\"available\") FROM \"telegraf\"..\"mem\"",
"db": "telegraf",
"rp": "autogen",
"groupbys": [],

View File

@ -8,7 +8,10 @@ const RefreshingLineGraph = AutoRefresh(LineGraph);
export const LayoutRenderer = React.createClass({
propTypes: {
timeRange: PropTypes.string.isRequired,
timeRange: PropTypes.shape({
defaultGroupBy: PropTypes.string.isRequired,
queryValue: PropTypes.string.isRequired,
}).isRequired,
cells: PropTypes.arrayOf(
PropTypes.shape({
queries: PropTypes.arrayOf(
@ -45,12 +48,13 @@ export const LayoutRenderer = React.createClass({
return this.props.cells.map((cell) => {
const qs = cell.queries.map((q) => {
let text = q.text;
text += ` where \"host\" = '${host}' and time > ${timeRange}`;
text += ` where \"host\" = '${host}' and time > ${timeRange.queryValue}`;
if (q.wheres && q.wheres.length > 0) {
text += ` and ${q.wheres.join(' and ')}`;
}
text += ` group by time(${timeRange.defaultGroupBy})`;
if (q.groupbys && q.groupbys.length > 0) {
text += ` group by ${q.groupbys.join(',')}`;
text += `,${q.groupbys.join(',')}`;
}
return Object.assign({}, q, {

View File

@ -77,7 +77,7 @@ export const HostPage = React.createClass({
return (
<LayoutRenderer
timeRange={timeRange.queryValue}
timeRange={timeRange}
cells={layoutCells}
autoRefreshMs={autoRefreshMs}
source={source}