WIP handle telegrafSystemInterval env
parent
711cb48d14
commit
8ea050e0bf
|
@ -2,15 +2,19 @@ import {proxy} from 'utils/queryUrlGenerator'
|
|||
import AJAX from 'utils/ajax'
|
||||
import _ from 'lodash'
|
||||
|
||||
export function getCpuAndLoadForHosts(proxyLink, telegrafDB) {
|
||||
export function getCpuAndLoadForHosts(
|
||||
proxyLink,
|
||||
telegrafDB,
|
||||
uptimeInverval = '1m'
|
||||
) {
|
||||
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() - 10m GROUP BY host, time(1m) fill(0);
|
||||
SELECT non_negative_derivative(mean(uptime)) AS deltaUptime FROM "system" WHERE time > now() - 10m GROUP BY host, time(${uptimeInverval}) 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() - 10m GROUP BY host, time(1m) fill(0);
|
||||
SELECT non_negative_derivative(mean("System_Up_Time")) AS winDeltaUptime FROM win_system WHERE time > now() - 10m GROUP BY host, time(${uptimeInverval}) fill(0);
|
||||
SHOW TAG VALUES WITH KEY = "host";`,
|
||||
db: telegrafDB,
|
||||
}).then(resp => {
|
||||
|
|
|
@ -5,6 +5,7 @@ import HostsTable from 'src/hosts/components/HostsTable'
|
|||
import SourceIndicator from 'shared/components/SourceIndicator'
|
||||
|
||||
import {getCpuAndLoadForHosts, getLayouts, getAppsForHosts} from '../apis'
|
||||
import {getEnv} from 'src/shared/apis/env'
|
||||
|
||||
class HostsPage extends Component {
|
||||
constructor(props) {
|
||||
|
@ -17,10 +18,13 @@ class HostsPage extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const {source, addFlashMessage} = this.props
|
||||
async componentDidMount() {
|
||||
const {source: {links, telegraf}, addFlashMessage} = this.props
|
||||
|
||||
const {data: {telegrafSystemInterval}} = await getEnv(links.env)
|
||||
|
||||
Promise.all([
|
||||
getCpuAndLoadForHosts(source.links.proxy, source.telegraf),
|
||||
getCpuAndLoadForHosts(links.proxy, telegraf, telegrafSystemInterval),
|
||||
getLayouts(),
|
||||
new Promise(resolve => {
|
||||
this.setState({hostsLoading: true})
|
||||
|
@ -32,7 +36,7 @@ class HostsPage extends Component {
|
|||
hosts,
|
||||
hostsLoading: false,
|
||||
})
|
||||
getAppsForHosts(source.links.proxy, hosts, layouts, source.telegraf)
|
||||
getAppsForHosts(links.proxy, hosts, layouts, telegraf)
|
||||
.then(newHosts => {
|
||||
this.setState({
|
||||
hosts: newHosts,
|
||||
|
@ -57,7 +61,7 @@ class HostsPage extends Component {
|
|||
})
|
||||
// TODO: this isn't reachable at the moment, because getCpuAndLoadForHosts doesn't fail when it should.
|
||||
// (like with a bogus proxy link). We should provide better messaging to the user in this catch after that's fixed.
|
||||
console.error(reason) // eslint-disable-line no-console
|
||||
console.error(reason)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import AJAX from 'src/utils/ajax'
|
||||
|
||||
export const getEnv = async url => {
|
||||
try {
|
||||
return await AJAX({
|
||||
method: 'GET',
|
||||
url,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
throw error
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue