Skip to content

Commit

Permalink
fix: optimize host's monitor (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: yaojiping <[email protected]>
  • Loading branch information
yaojp123 and yaojiping authored Dec 7, 2024
1 parent 8524202 commit 9812249
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 42 deletions.
6 changes: 0 additions & 6 deletions web/src/components/Overview/Monitor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ const Monitor = (props) => {
return monitor_configs?.node_stats?.enabled === false && monitor_configs?.index_stats?.enabled === false
}, [JSON.stringify(selectedCluster?.monitor_configs)])

console.log("spinning")
console.log(spinning)
console.log("state.refresh")
console.log(state.refresh)


return (
<div>
<BreadcrumbList data={breadcrumbList} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ export function getCurrentMethodAndTokenPaths(
// mark the url as completed.
ret.urlTokenPath.push(URL_PATH_END_MARKER);
}
debugger

if (t && t.type === "method") {
ret.method = t.value;
Expand Down Expand Up @@ -593,7 +592,6 @@ export default function({ coreEditor: editor }: { coreEditor: CoreEditor }) {
switch ((t || ({} as Token)).type) {
case "method":
// we moved one back
debugger
return "path";
default:
if (isUrlPathToken(t)) {
Expand Down Expand Up @@ -1110,7 +1108,6 @@ export default function({ coreEditor: editor }: { coreEditor: CoreEditor }) {
} else {
components = getUnmatchedEndpointComponents();
}
debugger
populateContext(ret.bodyTokenPath, context, editor, true, components);

return context;
Expand Down
41 changes: 29 additions & 12 deletions web/src/pages/Platform/Overview/Cluster/Monitor/advanced.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ import QueueMetric from "../../components/queue_metric";
import { ESPrefix } from "@/services/common";
import { SearchEngines } from "@/lib/search_engines";

export const shouldHaveModelInferenceBreaker = (cluster) => {
if ([SearchEngines.Easysearch, SearchEngines.Opensearch].includes(cluster?.distribution)) return false;
const versions = cluster?.version?.split('.') || []
if (parseInt(versions[0]) > 8 || (parseInt(versions[0]) === 8 && parseInt(versions[1]) >= 6 )) {
return true
}
return false
}

export const isVersionGTE6 = (cluster) => {
if ([SearchEngines.Easysearch, SearchEngines.Opensearch].includes(cluster?.distribution)) return true;
const main = cluster?.version?.split('.')[0]
if (main && parseInt(main) >= 6) {
return true
}
return false
}

export default ({
selectedCluster,
clusterID,
Expand All @@ -29,14 +47,13 @@ export default ({
refresh
}

const isVersionGTE6 = useMemo(() => {
if ([SearchEngines.Easysearch, SearchEngines.Opensearch].includes(selectedCluster?.distribution)) return true;
const main = selectedCluster?.version?.split('.')[0]
if (main && parseInt(main) >= 6) {
return true
}
return false
}, [selectedCluster?.version])
const isVersionGTE8_6 = useMemo(() => {
return shouldHaveModelInferenceBreaker(selectedCluster)
}, [selectedCluster])

const versionGTE6 = useMemo(() => {
return isVersionGTE6(selectedCluster)
}, [selectedCluster])

const [param, setParam] = useState({
tab: "cluster",
Expand Down Expand Up @@ -141,8 +158,8 @@ export default ({
"fielddata_breaker",
"request_breaker",
"in_flight_requests_breaker",
"model_inference_breaker"
]
isVersionGTE8_6 ? "model_inference_breaker" : undefined
].filter((item) => !!item)
],
[
"io",
Expand Down Expand Up @@ -314,7 +331,7 @@ export default ({
param={param}
setParam={setParam}
metrics={[
isVersionGTE6 ? [
versionGTE6 ? [
"thread_pool_write",
[
"write_active",
Expand All @@ -340,7 +357,7 @@ export default ({
"search_threads"
]
],
!isVersionGTE6 ? [
!versionGTE6 ? [
"thread_pool_bulk",
[
"bulk_active",
Expand Down
14 changes: 11 additions & 3 deletions web/src/pages/Platform/Overview/Host/Detail/Metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ export default (props) => {
return null;
}

const hasAgent = !!props.data?._source?.agent_id;
const isAgent = !!props.data?._source?.agent_id;

return (
<>
<Metrics
metricAction={`/host/${id}/metrics`}
metrics={[
'cpu_used_percent',
'memory_used_percent',
'disk_used_percent',
isAgent ? 'network_summary' : undefined,
isAgent ? 'disk_read_rate' : undefined,
isAgent ? 'disk_write_rate' : undefined
].filter((item) => !!item)}
renderExtraMetric={() =>
!hasAgent && (
!isAgent && (
<div
style={{
height: 150,
Expand Down Expand Up @@ -56,7 +64,7 @@ export default (props) => {
)
}
extra={
hasAgent && (
isAgent && (
<>
<Agent id={id} />
<Process id={id} />
Expand Down
30 changes: 26 additions & 4 deletions web/src/pages/Platform/Overview/Host/Monitor/advanced.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,46 @@ import { Button } from 'antd';
import InstallAgent from '@/components/Overview/Monitor/InstallAgent';
import { formatMessage } from "umi/locale";

const timezone = "local";

export default ({
hostID,
timeRange,
handleTimeChange,
info
info,
bucketSize,
timezone,
timeout,
refresh,
}) => {

const isAgent = info?.agent_id

return (
<ClusterMetric
timezone={timezone}
timeRange={timeRange}
timeout={timeout}
bucketSize={bucketSize}
refresh={refresh}
handleTimeChange={handleTimeChange}
fetchUrl={`/host/${hostID}/metrics`}
renderExtra={() => {
if (info?.agent_id) return;
if (isAgent) return;
return <InstallAgent height={226} desc={formatMessage({ id: "cluster.metrics.host.uninstall_agent" })}/>
}}
metrics={[
'cpu_used_percent',
'memory_used_percent',
'disk_used_percent',
isAgent ? 'network_summary' : undefined,
isAgent ? 'disk_read_rate' : undefined,
isAgent ? 'disk_write_rate' : undefined,
isAgent ? 'system_load' : undefined,
isAgent ? 'cpu_iowait' : undefined,
isAgent ? 'swap_memory_used_percent' : undefined,
isAgent ? 'network_packets_summary' : undefined,
isAgent ? 'disk_partition_usage' : undefined,
isAgent ? 'network_interface_output_rate' : undefined,
].filter((item) => !!item)}
/>
);
}
1 change: 1 addition & 0 deletions web/src/pages/Platform/Overview/Host/Monitor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const panes = [
export default (props) => {
return (
<Monitor
selectedCluster={{}}
formatState={(state) => {
return {
...state,
Expand Down
21 changes: 19 additions & 2 deletions web/src/pages/Platform/Overview/Host/Monitor/overview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,36 @@ export default ({
hostID,
timeRange,
handleTimeChange,
info
info,
bucketSize,
timezone,
timeout,
refresh,
}) => {
const isAgent = info?.agent_id

return (
<ClusterMetric
timezone={timezone}
timeRange={timeRange}
timeout={timeout}
bucketSize={bucketSize}
refresh={refresh}
handleTimeChange={handleTimeChange}
overview={1}
fetchUrl={`/host/${hostID}/metrics`}
renderExtra={() => {
if (info?.agent_id) return;
if (isAgent) return;
return <InstallAgent height={226} desc={formatMessage({ id: "cluster.metrics.host.uninstall_agent" })}/>
}}
metrics={[
'cpu_used_percent',
'memory_used_percent',
'disk_used_percent',
isAgent ? 'network_summary' : undefined,
isAgent ? 'disk_read_rate' : undefined,
isAgent ? 'disk_write_rate' : undefined
].filter((item) => !!item)}
/>
);
}
24 changes: 12 additions & 12 deletions web/src/pages/Platform/Overview/Node/Monitor/advanced.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import NodeMetric from "../../components/node_metric";
import QueueMetric from "../../components/queue_metric";
import { formatMessage } from "umi/locale";
import { SearchEngines } from "@/lib/search_engines";
import { isVersionGTE6, shouldHaveModelInferenceBreaker } from "../../Cluster/Monitor/advanced";

export default ({
selectedCluster,
Expand All @@ -27,13 +28,12 @@ export default ({
refresh
}

const isVersionGTE6 = useMemo(() => {
if ([SearchEngines.Easysearch, SearchEngines.Opensearch].includes(selectedCluster?.distribution)) return true;
const main = selectedCluster?.version?.split('.')[0]
if (main && parseInt(main) >= 6) {
return true
}
return false
const isVersionGTE8_6 = useMemo(() => {
return shouldHaveModelInferenceBreaker(selectedCluster)
}, [selectedCluster])

const versionGTE6 = useMemo(() => {
return isVersionGTE6(selectedCluster)
}, [selectedCluster])

const [param, setParam] = useState({
Expand Down Expand Up @@ -120,8 +120,8 @@ export default ({
"fielddata_breaker",
"request_breaker",
"in_flight_requests_breaker",
"model_inference_breaker"
]
isVersionGTE8_6 ? "model_inference_breaker" : undefined
].filter((item) => !!item)
],
[
"io",
Expand Down Expand Up @@ -215,7 +215,7 @@ export default ({
param={param}
setParam={setParam}
metrics={[
isVersionGTE6 ? [
versionGTE6 ? [
"thread_pool_write",
[
"write_active",
Expand All @@ -241,7 +241,7 @@ export default ({
"search_threads"
]
],
!isVersionGTE6 ? [
!versionGTE6 ? [
"thread_pool_bulk",
[
"bulk_active",
Expand Down Expand Up @@ -286,7 +286,7 @@ export default ({
"force_merge_threads"
]
]
].filter((item) => !!item)}
]}
/>
</Tabs.TabPane>
</Tabs>
Expand Down

0 comments on commit 9812249

Please sign in to comment.