Skip to content

Commit

Permalink
last fixes + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dlpzx committed Aug 20, 2022
1 parent 39b515f commit 8591885
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 83 deletions.
4 changes: 2 additions & 2 deletions backend/dataall/api/Objects/Tenant/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def get_monitoring_vpc_connection_id(context, source):
def create_quicksight_data_source_set(context, source, vpcConnectionId: str = None):
current_account = SessionHelper.get_account()
region = os.getenv('AWS_REGION', 'eu-west-1')
user = Quicksight.register_user(AwsAccountId=current_account, UserName='dataallTenantUser', UserRole='AUTHOR')
user = Quicksight.register_user(AwsAccountId=current_account, UserName=context.username, UserRole='AUTHOR')

datasourceId = Quicksight.create_data_source_vpc(AwsAccountId=current_account, region=region, UserName='dataallTenantUser', vpcConnectionId=vpcConnectionId)
datasourceId = Quicksight.create_data_source_vpc(AwsAccountId=current_account, region=region, UserName=context.username, vpcConnectionId=vpcConnectionId)
# Data sets are not created programmatically. Too much overhead for the value added. However, an example API is provided:
# datasets = Quicksight.create_data_set_from_source(AwsAccountId=current_account, region=region, UserName='dataallTenantUser', dataSourceId=datasourceId, tablesToImport=['organization', 'environment', 'dataset', 'datapipeline', 'dashboard', 'share_object'])

Expand Down
2 changes: 1 addition & 1 deletion backend/dataall/aws/handlers/quicksight.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def create_data_source_vpc(AwsAccountId, region, UserName, vpcConnectionId):
},
Permissions=[
{
"Principal": f"arn:aws:quicksight:{identity_region}:{AwsAccountId}:group/default/dataall",
"Principal": f"arn:aws:quicksight:{region}:{AwsAccountId}:group/default/dataall",
"Actions": [
"quicksight:UpdateDataSourcePermissions",
"quicksight:DescribeDataSource",
Expand Down
29 changes: 22 additions & 7 deletions documentation/userguide/docs/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,43 @@ Follow the steps in the

To complete the set-up you will need the following information:

- VPC_ID of the RDS Aurora database, which you can find in the RDS Console
- VPC_ID of the RDS Aurora database, which is the same as the data.all created one. If you have more than one VPC in the account, you can always check this value in
AWS SSM Parameters or in the Aurora database as appears in the picture:

![quicksight](pictures/monitoring/vpc1.png#zoom#shadow)

![quicksight](pictures/monitoring/vpc2.png#zoom#shadow)

- Security group created for Quicksight: In the VPC console, under security groups, look for a group called `<resource-prefix>-<envname>-quicksight-monitoring-sg`
For example using the default resource prefix, in an environment called prod, look for `dataall-prod-quicksight-monitoring-sg`.

**3) [WIP] Create Aurora data source and Quicksight data sets**
**3) Create Aurora data source**
We have automated this step for you! As a tenant user, a user that belongs to `DAADministrators` group, sign in to data.all.
In the UI navigate to the **Admin Settings** window by clicking in the top-right corner. You will appear in a window with 2 tabs: Teams and Monitoring.
In the Monitoring tab, introduce the VPC connection ... and click on .....
In the Monitoring tab, introduce the VPC connection name that you created in step 2 and click on the *Save* button. Then, click on the
*Create Quicksight data source* button. Right now, a connection between the RDS database and Quicksight has been established.

![quicksight](pictures/monitoring/qs1.png#zoom#shadow)

**4) Customize your analyses and share your dashboards**
Explore Quicksight documentation for next steps, such as <a href="https://docs.aws.amazon.com/quicksight/latest/user/working-with-visuals.html">customization of analyses</a>,
<a href="https://docs.aws.amazon.com/quicksight/latest/user/share-dashboard-view.html">sharing dashboards</a>
or <a href="https://docs.aws.amazon.com/quicksight/latest/user/sending-reports.html">sending reports via email</a>.
Go to Quicksight to start building your analysis by clicking on the *Start Quicksight session* button.
First, you need to create a dataset. Use the **dataall-metadata-db** data source, this is our connection with RDS.

![quicksight](pictures/monitoring/qs2.png#zoom#shadow)

Use this dataset in an analysis (check the docs <a href="https://docs.aws.amazon.com/quicksight/latest/user/working-with-visuals.html">customization of analyses</a>)
and publish it as a dashboard (docs in <a href="https://docs.aws.amazon.com/quicksight/latest/user/creating-a-dashboard.html">publish dashboards</a>)

!!! abstract "Not only RDS"
With Quicksight you can go one step further and communicate with other AWS services and data sources. Explore the documentation
for cost analyses in AWS with Quicksight or AWS CloudWatch Logs collection and visualization with Quicksight.


**5) Bring your dashboard back to data.all**
Once your dashboard is ready, copy its ID (you can find it in the URL as appears in the below picture)


![quicksight](pictures/monitoring/qs3.png#zoom#shadow)

Back in the data.all Monitoring tab, introduce this dashbaord ID. Now, other tenants can see your dashboard directly from data.all UI!

![quicksight](pictures/monitoring/qs4.png#zoom#shadow)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 5 additions & 73 deletions frontend/src/views/Administration/AdministratorDashboardViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { Formik, useFormik } from 'formik';
import * as ReactIf from 'react-if';
import {
Box,
Button,
Collapse,
Grid,
Card,
CardActions,
Expand All @@ -14,11 +12,12 @@ import {
Container,
Divider,
TextField,
Typography
Typography,
Button,
CircularProgress
} from '@mui/material';
import { FaCheckCircle } from 'react-icons/fa';
import { AddOutlined, CopyAllOutlined, ArrowLeft, ArrowRightAlt, ChevronRight } from '@mui/icons-material';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import { CopyToClipboard } from 'react-copy-to-clipboard/lib/Component';
import { LoadingButton } from '@mui/lab';
import getMonitoringDashboardId from '../../api/Tenant/getMonitoringDashboardId';
Expand All @@ -33,7 +32,6 @@ import useClient from '../../hooks/useClient';
import { SET_ERROR } from '../../store/errorReducer';
import useSettings from '../../hooks/useSettings';


const QuickSightEmbedding = require('amazon-quicksight-embedding-sdk');

const DashboardViewer = () => {
Expand Down Expand Up @@ -61,9 +59,6 @@ const DashboardViewer = () => {
const response = await client.query(getMonitoringVPCConnectionId());
if (!response.errors) {
setVpcConnectionId(response.data.getMonitoringVPCConnectionId);
console.log("fetch vpc")
console.log(response.data.getMonitoringVPCConnectionId)
console.log(vpcConnectionId)
} else {
dispatch({ type: SET_ERROR, error: response.errors[0].message });
}
Expand All @@ -73,15 +68,9 @@ const DashboardViewer = () => {
const response = await client.query(getMonitoringDashboardId());
if (!response.errors) {
setDashboardId(response.data.getMonitoringDashboardId);
console.log("fetch dashboard")
console.log(response.data.getMonitoringDashboardId)
console.log(dashboardId)
if (response.data.getMonitoringDashboardId != "updateme"){
console.log("getting url")
const resp = await client.query(getPlatformReaderSession(response.data.getMonitoringDashboardId));
if (!resp.errors){
console.log("inside resp")
console.log(resp.data.getPlatformReaderSession)
setSessionUrl(resp.data.getPlatformReaderSession)
const options = {
url: resp.data.getPlatformReaderSession,
Expand Down Expand Up @@ -121,9 +110,6 @@ const DashboardViewer = () => {

async function submitVpc(values, setStatus, setSubmitting, setErrors){
try {
console.log("values")
console.log(values);
console.log(values.vpc)
setVpcConnectionId(values.vpc)
const response = await client.mutate(updateSSMParameter({name:"VPCConnectionId", value:values.vpc}));
if (!response.errors) {
Expand All @@ -143,18 +129,13 @@ const DashboardViewer = () => {

async function submitDash(values, setStatus, setSubmitting, setErrors){
try {
console.log("values")
console.log(values);
console.log(values.dash)
setDashboardId(values.dash)
const response = await client.mutate(updateSSMParameter({name:"DashboardId", value:values.dash}));
if (!response.errors) {
setStatus({success: true});
setSubmitting(false);
const resp = await client.query(getPlatformReaderSession(values.dash));
if (!resp.errors){
console.log("inside resp")
console.log(resp.data.getPlatformReaderSession)
setSessionUrl(resp.data.getPlatformReaderSession)
const options = {
url: resp.data.getPlatformReaderSession,
Expand Down Expand Up @@ -185,9 +166,6 @@ const DashboardViewer = () => {
};

async function createQuicksightdata () {
console.log("inside enableQuicksight")
console.log(dashboardId)
console.log(vpcConnectionId)
setIsCreatingDataSource(true)
const response = await client.mutate(createQuicksightDataSourceSet({vpcConnectionId}));
if (response.errors) {
Expand All @@ -207,27 +185,7 @@ const DashboardViewer = () => {
setIsOpeningSession(false);
};

interface ExpandMoreProps extends IconButtonProps {
expand: boolean;
}

const ExpandMore = styled((props: ExpandMoreProps) => {
const { expand, ...other } = props;
return <IconButton {...other} />;
})(({ theme, expand }) => ({
transform: !expand ? 'rotate(0deg)' : 'rotate(180deg)',
marginLeft: 'auto',
transition: theme.transitions.create('transform', {
duration: theme.transitions.duration.shortest,
}),
}));

export default function RecipeReviewCard() {
const [expanded, setExpanded] = React.useState(false);

const handleExpandClick = () => {
setExpanded(!expanded);
};
return (
<Container maxWidth={settings.compact ? 'xl' : false}>
<Grid container justifyContent="space-between" spacing={3}>
Expand All @@ -253,18 +211,7 @@ const DashboardViewer = () => {
<Card sx={{ mt: 3 }}>
<CardHeader title="Create the RDS data source in Quicksight" />
<Divider />
<CardActions disableSpacing>
<ExpandMore
expand={expanded}
onClick={handleExpandClick}
aria-expanded={expanded}
aria-label="show more"
>
<ExpandMoreIcon />
</ExpandMore>
</CardActions>
<Collapse in={expanded} timeout="auto" unmountOnExit>
<CardContent>
<CardContent>
<Box mb={1}>
<Box mb={1}>
<Typography color="textSecondary" variant="subtitle2">
Expand Down Expand Up @@ -338,7 +285,7 @@ const DashboardViewer = () => {
</Typography>
</Box>
<Grid container justifyContent="space-between" spacing={3}>
<Grid item lg={12} xl={12} xs={12}>
<Grid item lg={6} xl={6} xs={6}>
<LoadingButton
loading={isCreatingDataSource}
color="primary"
Expand All @@ -357,7 +304,6 @@ const DashboardViewer = () => {
</Grid>
</Box>
</CardContent>
</Collapse>
</Card>
</Grid>
<Grid item lg={6} md={6} sm={12} xs={12}>
Expand Down Expand Up @@ -458,18 +404,6 @@ const DashboardViewer = () => {
<Grid item lg={12} md={12} sm={12} xs={12}>
<ReactIf.If condition={sessionUrl}>
<ReactIf.Then>
<Box sx={{ mb: 3 }}>
<Button
color="primary"
component="a"
target="_blank"
rel="noreferrer"
startIcon={<FaCheckCircle size={15} />}
variant="outlined"
>
Import Dashboard
</Button>
</Box>
<div ref={dashboardRef} />
</ReactIf.Then>
</ReactIf.If>
Expand All @@ -480,5 +414,3 @@ const DashboardViewer = () => {
};

export default DashboardViewer;


16 changes: 16 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is a sample Python script.

# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.


def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/

0 comments on commit 8591885

Please sign in to comment.