forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from anyscale/hdash-grafana
Grafana Integration
- Loading branch information
Showing
7 changed files
with
172 additions
and
30 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
64 changes: 64 additions & 0 deletions
64
python/ray/dashboard/client/src/pages/dashboard/node-info/dialogs/grafana/IFrame.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,64 @@ | ||
import { fade } from "@material-ui/core/styles/colorManipulator"; | ||
import { Theme } from "@material-ui/core/styles/createMuiTheme"; | ||
import createStyles from "@material-ui/core/styles/createStyles"; | ||
import withStyles, { WithStyles } from "@material-ui/core/styles/withStyles"; | ||
import Typography from "@material-ui/core/Typography"; | ||
import React from "react"; | ||
import { getGrafanaIframe, GetGrafanaIframeResponse } from "../../../../../api"; | ||
import DialogWithTitle from "../../../../../common/DialogWithTitle"; | ||
|
||
const styles = (theme: Theme) => | ||
createStyles({ | ||
header: { | ||
lineHeight: 1, | ||
marginBottom: theme.spacing(3), | ||
marginTop: theme.spacing(3) | ||
} | ||
}); | ||
|
||
interface Props { | ||
clearDialog: () => void; | ||
pid: number | "All"; | ||
metric: "cpu" | "memory"; | ||
} | ||
|
||
interface State { | ||
result: GetGrafanaIframeResponse | null; | ||
error: string | null; | ||
} | ||
|
||
class IFrame extends React.Component<Props & WithStyles<typeof styles>, State> { | ||
state: State = { | ||
result: null, | ||
error: null | ||
}; | ||
|
||
async componentDidMount() { | ||
try { | ||
const { metric, pid } = this.props; | ||
const result = await getGrafanaIframe(pid, metric); | ||
this.setState({ result, error: null }); | ||
} catch (error) { | ||
this.setState({ result: null, error: error.toString() }); | ||
} | ||
} | ||
|
||
render() { | ||
const { classes, clearDialog } = this.props; | ||
const { result, error } = this.state; | ||
|
||
return ( | ||
<DialogWithTitle handleClose={clearDialog} title="Historical Metrics"> | ||
{error !== null ? ( | ||
<Typography color="error">{error}</Typography> | ||
) : result === null ? ( | ||
<Typography color="textSecondary">Loading...</Typography> | ||
) : ( | ||
<div dangerouslySetInnerHTML={{ __html: result.frame_html }} /> | ||
)} | ||
</DialogWithTitle> | ||
); | ||
} | ||
} | ||
|
||
export default withStyles(styles)(IFrame); |
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