Pass defaultRP from client to server for Host Page queries

Co-authored-by Iris Scholten <ischolten.is@gmail.com>
pull/10616/head
Jared Scheib 2018-04-13 17:47:33 -07:00
parent ac3a19f6c0
commit fd2af90e53
2 changed files with 10 additions and 8 deletions

View File

@ -5,16 +5,17 @@ import _ from 'lodash'
export const getCpuAndLoadForHosts = (
proxyLink,
telegrafDB,
telegrafSystemInterval
telegrafSystemInterval,
rp
) => {
return proxy({
source: proxyLink,
query: `SELECT mean("usage_user") FROM cpu WHERE "cpu" = 'cpu-total' AND time > now() - 10m GROUP BY host;
SELECT mean("load1") FROM "system" WHERE time > now() - 10m GROUP BY host;
SELECT non_negative_derivative(mean(uptime)) AS deltaUptime FROM "system" WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0);
SELECT mean("Percent_Processor_Time") FROM win_cpu WHERE time > now() - 10m GROUP BY host;
SELECT mean("Processor_Queue_Length") FROM win_system WHERE time > now() - 10s GROUP BY host;
SELECT non_negative_derivative(mean("System_Up_Time")) AS winDeltaUptime FROM win_system WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0);
query: `SELECT mean("usage_user") FROM cpu WHERE "${telegrafDB}"."${rp}"."cpu" = 'cpu-total' AND time > now() - 10m GROUP BY host;
SELECT mean("load1") FROM "${telegrafDB}"."${rp}"."system" WHERE time > now() - 10m GROUP BY host;
SELECT non_negative_derivative(mean(uptime)) AS deltaUptime FROM "${telegrafDB}"."${rp}"."system" WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0);
SELECT mean("Percent_Processor_Time") FROM "${telegrafDB}"."${rp}".win_cpu WHERE time > now() - 10m GROUP BY host;
SELECT mean("Processor_Queue_Length") FROM "${telegrafDB}"."${rp}".win_system WHERE time > now() - 10s GROUP BY host;
SELECT non_negative_derivative(mean("System_Up_Time")) AS winDeltaUptime FROM "${telegrafDB}"."${rp}".win_system WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0);
SHOW TAG VALUES WITH KEY = "host";`,
db: telegrafDB,
}).then(resp => {

View File

@ -38,7 +38,8 @@ class HostsPage extends Component {
const hosts = await getCpuAndLoadForHosts(
source.links.proxy,
source.telegraf,
telegrafSystemInterval
telegrafSystemInterval,
source.defaultRP
)
if (!hosts) {
throw new Error(hostsError)