chore: adjust the description when no data in monitor logs (#153)

* chore: adjust the description when no data in monitor logs

* chore: adjust discover's histogram

---------

Co-authored-by: yaojiping <yaojiping@infini.ltd>
This commit is contained in:
yaojp123 2025-02-20 16:03:30 +08:00 committed by GitHub
parent 78cdd44e9c
commit 1ecdbb3e59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 92 additions and 64 deletions

View File

@ -158,7 +158,7 @@ const Monitor = (props) => {
return monitor_configs?.node_stats?.enabled === false && monitor_configs?.index_stats?.enabled === false return monitor_configs?.node_stats?.enabled === false && monitor_configs?.index_stats?.enabled === false
} }
return metric_collection_mode === 'agent' return metric_collection_mode === 'agent'
}, [JSON.stringify(selectedCluster?.monitor_configs)]) }, [JSON.stringify(selectedCluster)])
return ( return (
<div> <div>
@ -170,6 +170,7 @@ const Monitor = (props) => {
<> <>
<div style={{ marginBottom: 5 }}> <div style={{ marginBottom: 5 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}> <div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div style={{ maxWidth: 600 }}>
<DatePicker <DatePicker
locale={getLocale()} locale={getLocale()}
start={state.timeRange.min} start={state.timeRange.min}
@ -210,6 +211,7 @@ const Monitor = (props) => {
}} }}
recentlyUsedRangesKey={'monitor'} recentlyUsedRangesKey={'monitor'}
/> />
</div>
<CollectStatus fetchUrl={`${ESPrefix}/${selectedCluster?.id}/_collection_stats`}/> <CollectStatus fetchUrl={`${ESPrefix}/${selectedCluster?.id}/_collection_stats`}/>
</div> </div>
</div> </div>

View File

@ -88,7 +88,7 @@ export class DiscoverHistogram extends Component {
render() { render() {
const timeZone = getTimezone(); const timeZone = getTimezone();
const { chartData } = this.props; const { chartData, height = 100 } = this.props;
const { chartsTheme, chartsBaseTheme } = this.state; const { chartsTheme, chartsBaseTheme } = this.state;
@ -149,7 +149,7 @@ export class DiscoverHistogram extends Component {
//console.log(data) //console.log(data)
return ( return (
<Chart size={{ height: 40 }}> <Chart size={{ height }}>
<Settings <Settings
xDomain={xDomain} xDomain={xDomain}
onBrushEnd={this.onBrushEnd} onBrushEnd={this.onBrushEnd}

View File

@ -130,6 +130,8 @@ export default {
"cluster.monitor.logs.node": "Node", "cluster.monitor.logs.node": "Node",
"cluster.monitor.logs.message": "Message", "cluster.monitor.logs.message": "Message",
"cluster.monitor.logs.search.placeholder": "Search message", "cluster.monitor.logs.search.placeholder": "Search message",
"cluster.monitor.logs.empty.agent": "No data, please change the time range or check if the Agent is working properly.",
"cluster.monitor.logs.empty.agentless": "No data, please install the Agent and change the cluster collection mode to Agent.",
"cluster.monitor.tabs.overview": "Overview", "cluster.monitor.tabs.overview": "Overview",
"cluster.monitor.tabs.advanced": "Advanced", "cluster.monitor.tabs.advanced": "Advanced",

View File

@ -121,6 +121,8 @@ export default {
"cluster.monitor.logs.node": "节点", "cluster.monitor.logs.node": "节点",
"cluster.monitor.logs.message": "日志", "cluster.monitor.logs.message": "日志",
"cluster.monitor.logs.search.placeholder": "搜索日志", "cluster.monitor.logs.search.placeholder": "搜索日志",
"cluster.monitor.logs.empty.agent": "没有数据,请更改时间范围或检查 Agent 是否正常工作。",
"cluster.monitor.logs.empty.agentless": "没有数据,请安装 Agent 并更改集群采集模式为 Agent 。",
"cluster.monitor.tabs.overview": "概览", "cluster.monitor.tabs.overview": "概览",
"cluster.monitor.tabs.advanced": "高级", "cluster.monitor.tabs.advanced": "高级",

View File

@ -355,7 +355,10 @@ export default {
let idx = state.clusterList.findIndex((item) => item.id === payload.id); let idx = state.clusterList.findIndex((item) => item.id === payload.id);
idx > -1 && (state.clusterList[idx].name = payload.name); idx > -1 && (state.clusterList[idx].name = payload.name);
if (state.selectedCluster?.id === payload.id) { if (state.selectedCluster?.id === payload.id) {
state.selectedCluster.monitor_configs = payload.monitor_configs state.selectedCluster = {
...(state.selectedCluster || {}),
...(payload || {})
}
} }
state.clusterStatus[payload.id].config.monitored = payload.monitored; state.clusterStatus[payload.id].config.monitored = payload.monitored;
return state; return state;

View File

@ -178,6 +178,9 @@ const Discover = (props) => {
field: "", field: "",
enabled: false, enabled: false,
}; };
const [histogramVisible, setHistogramVisible] = useState(false)
const [distinctParams, setDistinctParams] = React.useState( const [distinctParams, setDistinctParams] = React.useState(
distinctParamsDefault distinctParamsDefault
); );
@ -1162,7 +1165,9 @@ const Discover = (props) => {
showLayoutListIcon={false} showLayoutListIcon={false}
histogramProps={{ histogramProps={{
histogramData, histogramData,
timefilterUpdateHandler onHistogramToggle: () => {
setHistogramVisible(!histogramVisible)
},
}} }}
// viewLayout={viewLayout} // viewLayout={viewLayout}
// onViewLayoutChange={(layout) => { // onViewLayoutChange={(layout) => {
@ -1310,6 +1315,31 @@ const Discover = (props) => {
responsive={false} responsive={false}
style={{ position: "relative" }} style={{ position: "relative" }}
> >
{histogramVisible && opts.timefield && (
<EuiFlexItem>
<section
aria-label={"Histogram of found documents"}
className="dscTimechart"
>
{opts.chartAggConfigs &&
histogramData &&
records.length !== 0 && (
<div
className="dscHistogramGrid"
data-test-subj="discoverChart"
>
<DiscoverHistogram
chartData={histogramData}
timefilterUpdateHandler={
timefilterUpdateHandler
}
/>
</div>
)}
</section>
<EuiSpacer size="s" />
</EuiFlexItem>
)}
<EuiFlexItem className="eui-yScroll"> <EuiFlexItem className="eui-yScroll">
<section <section
className="dscTable eui-yScroll" className="dscTable eui-yScroll"

View File

@ -5,25 +5,11 @@ import styles from "./index.less";
export default (props) => { export default (props) => {
const { histogramData, timefilterUpdateHandler } = props const { onHistogramToggle } = props
const [visible, setVisible] = useState(false)
return ( return (
<Popover <Icon type="bar-chart" title="show histogram" style={{color: '#006BB4', cursor: 'pointer'}} onClick={() => {
visible={visible} onHistogramToggle()
placement="left"
title={null}
overlayClassName={styles.histogram}
content={(
<DiscoverHistogram
chartData={histogramData}
timefilterUpdateHandler={timefilterUpdateHandler}
/>
)}>
<Icon type="bar-chart" style={{color: '#006BB4', cursor: 'pointer'}} onClick={() => {
setVisible(!visible)
}}/> }}/>
</Popover>
) )
} }

View File

@ -314,7 +314,10 @@ export default (props) => {
</div> </div>
</> </>
) : ( ) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE}/> <Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={formatMessage({ id: `cluster.monitor.logs.empty.${isAgent ? 'agent' : 'agentless'}` })}
/>
) )
} }
</div> </div>