The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/features/admin/ServerStats.tsx

74 lines
1.7 KiB

import React, { PureComponent } from 'react';
import { hot } from 'react-hot-loader';
import { connect } from 'react-redux';
import { NavModel, StoreState } from 'app/types';
import { getNavModel } from 'app/core/selectors/navModel';
import { getServerStats, ServerStat } from './state/apis';
import PageHeader from 'app/core/components/PageHeader/PageHeader';
interface Props {
navModel: NavModel;
getServerStats: () => Promise<ServerStat[]>;
}
interface State {
stats: ServerStat[];
}
export class ServerStats extends PureComponent<Props, State> {
constructor(props) {
super(props);
this.state = {
stats: [],
};
}
async componentDidMount() {
try {
const stats = await this.props.getServerStats();
this.setState({ stats });
} catch (error) {
console.error(error);
}
}
render() {
const { navModel } = this.props;
const { stats } = this.state;
return (
<div>
<PageHeader model={navModel} />
<div className="page-container page-body">
<table className="filter-table form-inline">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>{stats.map(StatItem)}</tbody>
</table>
</div>
</div>
);
}
}
function StatItem(stat: ServerStat) {
return (
<tr key={stat.name}>
<td>{stat.name}</td>
<td>{stat.value}</td>
</tr>
);
}
const mapStateToProps = (state: StoreState) => ({
navModel: getNavModel(state.navIndex, 'server-stats'),
getServerStats: getServerStats,
});
export default hot(module)(connect(mapStateToProps)(ServerStats));