-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds monitoring metrics component and legend
- Loading branch information
1 parent
789499a
commit 5b72d57
Showing
9 changed files
with
170 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...nd/packages/dev-console/src/components/monitoring/dashboard/MonitoringDashboardQueries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { template } from 'lodash'; | ||
import { | ||
humanizeBinaryBytes, | ||
humanizeCpuCores, | ||
humanizeDecimalBytesPerSec, | ||
} from '@console/internal/components/utils'; | ||
import { ByteDataTypes } from '@console/shared/src/graph-helper/data-utils'; | ||
import { GraphTypes } from './MonitoringDashboardGraph'; | ||
|
||
export const queries = [ | ||
{ | ||
query: template( | ||
`topk(25, sort_desc(sum(avg_over_time(pod:container_cpu_usage:sum{container="",pod!="",namespace='<%= namespace %>'}[5m])) BY (pod, namespace)))`, | ||
), | ||
chartType: GraphTypes.area, | ||
title: 'Stat 1', | ||
humanize: humanizeCpuCores, | ||
byteDataType: ByteDataTypes.BinaryBytes, | ||
}, | ||
{ | ||
query: template( | ||
`topk(25, sort_desc(sum(avg_over_time(container_memory_working_set_bytes{container="",pod!="",namespace='<%= namespace %>'}[5m])) BY (pod, namespace)))`, | ||
), | ||
chartType: GraphTypes.area, | ||
title: 'Stat 2', | ||
humanize: humanizeBinaryBytes, | ||
byteDataType: ByteDataTypes.BinaryBytes, | ||
}, | ||
{ | ||
query: template( | ||
`topk(25, sort_desc(sum(pod:container_fs_usage_bytes:sum{container="",pod!="",namespace='<%= namespace %>'}) BY (pod, namespace)))`, | ||
), | ||
chartType: GraphTypes.line, | ||
title: 'Stat 3', | ||
humanize: humanizeBinaryBytes, | ||
byteDataType: ByteDataTypes.BinaryBytes, | ||
}, | ||
{ | ||
query: template( | ||
`topk(25, sort_desc(sum(rate(container_network_receive_bytes_total{ container="POD", pod!= "", namespace = '<%= namespace %>'}[5m]) + rate(container_network_transmit_bytes_total{ container="POD", pod!= "", namespace = '<%= namespace %>'}[5m])) BY (namespace, pod)))`, | ||
), | ||
chartType: GraphTypes.line, | ||
title: 'Stat 4', | ||
humanize: humanizeDecimalBytesPerSec, | ||
byteDataType: ByteDataTypes.BinaryBytes, | ||
}, | ||
]; |
8 changes: 8 additions & 0 deletions
8
frontend/packages/dev-console/src/components/monitoring/metrics/MetricsDropdown.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.odc-metrics-dropdown { | ||
margin-bottom: 20px; | ||
&__menu { | ||
max-height: 50vh; | ||
overflow: auto; | ||
width: 100%; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
frontend/packages/dev-console/src/components/monitoring/metrics/MetricsDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import * as React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import * as fuzzy from 'fuzzysearch'; | ||
import { RootState } from '@console/internal/redux'; | ||
import { Dropdown } from '@console/internal/components/utils'; | ||
import { queryBrowserRunQueries, queryBrowserPatchQuery } from '@console/internal/actions/ui'; | ||
import { getActiveNamespace } from '@console/internal/reducers/ui'; | ||
import { QueryObj } from '@console/internal/components/monitoring/query-browser'; | ||
import { metricsQuery, getTopMetricsQueries } from '../queries'; | ||
import './MetricsDropdown.scss'; | ||
|
||
const ADD_NEW_QUERY = '#ADD_NEW_QUERY#'; | ||
|
||
type StateProps = { | ||
namespace: string; | ||
}; | ||
|
||
type MetricsDropdownProps = { | ||
patchQuery: (patch: QueryObj) => void; | ||
runQueries: () => never; | ||
namespace: string; | ||
}; | ||
|
||
export const MetricsDropdown: React.FC<MetricsDropdownProps> = ({ | ||
patchQuery, | ||
runQueries, | ||
namespace, | ||
}) => { | ||
const items = metricsQuery; | ||
const autocompleteFilter = (text, item) => fuzzy(text, item); | ||
const defaultActionItem = [ | ||
{ | ||
actionTitle: `Custom Query`, | ||
actionKey: ADD_NEW_QUERY, | ||
}, | ||
]; | ||
|
||
const [metric, setMetric] = React.useState(''); | ||
React.useEffect(() => { | ||
if (metric && metric !== ADD_NEW_QUERY) { | ||
const query = getTopMetricsQueries(namespace)[metric]; | ||
patchQuery({ text: query }); | ||
runQueries(); | ||
} | ||
}, [metric, namespace, patchQuery, runQueries]); | ||
const onChange = (selVal: string) => { | ||
setMetric(selVal); | ||
}; | ||
|
||
return ( | ||
<Dropdown | ||
autocompleteFilter={autocompleteFilter} | ||
items={items || {}} | ||
actionItems={defaultActionItem} | ||
dropDownClassName="odc-metrics-dropdown dropdown--full-width" | ||
menuClassName="odc-metrics-dropdown__menu dropdown-menu--text-wrap" | ||
onChange={onChange} | ||
title={'Select Query'} | ||
/> | ||
); | ||
}; | ||
|
||
const mapStateToProps = (state: RootState): StateProps => ({ | ||
namespace: getActiveNamespace(state), | ||
}); | ||
|
||
const mapDispatchToProps = (dispatch) => ({ | ||
runQueries: () => dispatch(queryBrowserRunQueries()), | ||
patchQuery: (v: QueryObj) => dispatch(queryBrowserPatchQuery(0, v)), | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(MetricsDropdown); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ckages/dev-console/src/components/monitoring/metrics/__tests__/MonitoringMetrics.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters