get apps for all hosts
parent
e4f6c1d525
commit
80a29b0054
|
@ -63,7 +63,7 @@ export function getCpuAndLoadForHosts(proxyLink, telegrafDB) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getHosts(proxyLink, telegrafDB) {
|
export function getAllHosts(proxyLink, telegrafDB) {
|
||||||
return proxy({
|
return proxy({
|
||||||
source: proxyLink,
|
source: proxyLink,
|
||||||
query: 'show tag values from system with key = "host"',
|
query: 'show tag values from system with key = "host"',
|
||||||
|
@ -71,11 +71,16 @@ export function getHosts(proxyLink, telegrafDB) {
|
||||||
}).then((resp) => {
|
}).then((resp) => {
|
||||||
const allHostsSeries = _.get(resp, ['data', 'results', '0', 'series', '0'], []);
|
const allHostsSeries = _.get(resp, ['data', 'results', '0', 'series', '0'], []);
|
||||||
const hostnameIndex = allHostsSeries.columns.findIndex((col) => col === 'value');
|
const hostnameIndex = allHostsSeries.columns.findIndex((col) => col === 'value');
|
||||||
|
const hosts = {};
|
||||||
return allHostsSeries.values.map((v) => v[hostnameIndex]);
|
allHostsSeries.values.forEach((v) => {
|
||||||
|
const hostname = v[hostnameIndex];
|
||||||
|
hosts[hostname] = {
|
||||||
|
name: hostname,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return hosts;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMappings() {
|
export function getMappings() {
|
||||||
return AJAX({
|
return AJAX({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
|
|
@ -3,7 +3,7 @@ import LayoutRenderer from 'shared/components/LayoutRenderer';
|
||||||
import TimeRangeDropdown from '../../shared/components/TimeRangeDropdown';
|
import TimeRangeDropdown from '../../shared/components/TimeRangeDropdown';
|
||||||
import ReactTooltip from 'react-tooltip';
|
import ReactTooltip from 'react-tooltip';
|
||||||
import timeRanges from 'hson!../../shared/data/timeRanges.hson';
|
import timeRanges from 'hson!../../shared/data/timeRanges.hson';
|
||||||
import {getMappings, getAppsForHosts, getMeasurementsForHost, getHosts} from 'src/hosts/apis';
|
import {getMappings, getAppsForHosts, getMeasurementsForHost, getAllHosts} from 'src/hosts/apis';
|
||||||
import {fetchLayouts} from 'shared/apis';
|
import {fetchLayouts} from 'shared/apis';
|
||||||
|
|
||||||
export const HostPage = React.createClass({
|
export const HostPage = React.createClass({
|
||||||
|
@ -37,31 +37,28 @@ export const HostPage = React.createClass({
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const {source, params, location} = this.props;
|
const {source, params, location} = this.props;
|
||||||
const hostsToGet = {[params.hostID]: {name: params.hostID}};
|
|
||||||
|
|
||||||
// fetching layouts and mappings can be done at the same time
|
// fetching layouts and mappings can be done at the same time
|
||||||
fetchLayouts().then(({data: {layouts}}) => {
|
fetchLayouts().then(({data: {layouts}}) => {
|
||||||
getMappings().then(({data: {mappings}}) => {
|
getMappings().then(({data: {mappings}}) => {
|
||||||
getAppsForHosts(source.links.proxy, hostsToGet, mappings, source.telegraf).then((newHosts) => {
|
getAllHosts(source.links.proxy, source.telegraf).then((hosts) => {
|
||||||
getMeasurementsForHost(source, params.hostID).then((measurements) => {
|
getAppsForHosts(source.links.proxy, hosts, mappings, source.telegraf).then((newHosts) => {
|
||||||
const host = newHosts[this.props.params.hostID];
|
getMeasurementsForHost(source, params.hostID).then((measurements) => {
|
||||||
const filteredLayouts = layouts.filter((layout) => {
|
const host = newHosts[this.props.params.hostID];
|
||||||
const focusedApp = location.query.app;
|
const filteredLayouts = layouts.filter((layout) => {
|
||||||
if (focusedApp) {
|
const focusedApp = location.query.app;
|
||||||
return layout.app === focusedApp;
|
if (focusedApp) {
|
||||||
}
|
return layout.app === focusedApp;
|
||||||
|
}
|
||||||
|
|
||||||
return host.apps && host.apps.includes(layout.app) && measurements.includes(layout.measurement);
|
return host.apps && host.apps.includes(layout.app) && measurements.includes(layout.measurement);
|
||||||
|
});
|
||||||
|
this.setState({layouts: filteredLayouts, hosts});
|
||||||
});
|
});
|
||||||
this.setState({layouts: filteredLayouts});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
getHosts(source.links.proxy, source.telegraf).then((hosts) => {
|
|
||||||
this.setState({hosts});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleChooseTimeRange({lower}) {
|
handleChooseTimeRange({lower}) {
|
||||||
|
@ -138,7 +135,7 @@ export const HostPage = React.createClass({
|
||||||
<span className="caret"></span>
|
<span className="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<ul className="dropdown-menu" aria-labelledby="dropdownMenu1">
|
<ul className="dropdown-menu" aria-labelledby="dropdownMenu1">
|
||||||
{hosts.map((host, i) => {
|
{Object.keys(hosts).map((host, i) => {
|
||||||
return (
|
return (
|
||||||
<li key={i}>
|
<li key={i}>
|
||||||
<a href={`/sources/${this.props.source.id}/hosts/${host}`} className="role-option">
|
<a href={`/sources/${this.props.source.id}/hosts/${host}`} className="role-option">
|
||||||
|
|
Loading…
Reference in New Issue