Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create prometheus datasource flow #1054

Merged
merged 36 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
73becc4
Manage datasources (#967)
derek-ho Sep 7, 2023
6e42a2b
Add acceleration management UI (#989)
ps48 Sep 11, 2023
24cdd19
Rename data sources to data connections (#1004)
derek-ho Sep 15, 2023
dfd5bd8
Add fallback to show if user does not have datasource API permissions…
derek-ho Sep 15, 2023
28201e9
Add access control tab content (#992)
derek-ho Sep 18, 2023
89eafa2
Delete datasource and Connection Configuration Tab (#1024)
derek-ho Sep 20, 2023
1efd191
Get most of the workflow working for configure datasource
derek-ho Sep 22, 2023
ad153ed
remove acceleration components
ps48 Sep 22, 2023
93ad0dd
Update data connection to datasources in a few more places and update…
derek-ho Sep 22, 2023
d98cd8d
Merge branch 'feature/flint-UI' of github.com:opensearch-project/dash…
derek-ho Sep 22, 2023
2bd8c27
Rename and re-organize in folders
derek-ho Sep 22, 2023
cc7b1a2
Fix import path in testing file
derek-ho Sep 22, 2023
ed8cfc1
Get Initial S3 configuration working
derek-ho Sep 25, 2023
0b84fab
Configure S3 Data Source Working
derek-ho Sep 25, 2023
6d8a98f
Fix query permissions display
derek-ho Sep 25, 2023
e8b831f
Merge branch 'main' of github.com:opensearch-project/dashboards-obser…
derek-ho Sep 25, 2023
7a3f085
Fix merge conflict
derek-ho Sep 25, 2023
1ffdfb0
Clean up PR
derek-ho Sep 25, 2023
7a333bf
Add s3 logo in manage table
derek-ho Sep 25, 2023
c5f1eae
Fix up PR according to UX feedback
derek-ho Sep 25, 2023
23699bc
Remove successfully
derek-ho Sep 25, 2023
51bb5d4
Update test
derek-ho Sep 25, 2023
6726750
Initial commit adding prometheus logo and icon
derek-ho Sep 27, 2023
b47c1e9
Merge branch 'main' of github.com:opensearch-project/dashboards-obser…
derek-ho Sep 27, 2023
a9a9dda
Get the major flow working
derek-ho Sep 27, 2023
bc5cadc
Fix app navigation
derek-ho Sep 27, 2023
cf9c45b
Fix up PR
derek-ho Sep 28, 2023
8fb8220
Remove management redirection for now and fix test and add cards
derek-ho Sep 28, 2023
655fa07
Remove type filter and update test according to UX feedback
derek-ho Sep 28, 2023
cca73f8
Add link and update test
derek-ho Sep 28, 2023
6d3894b
Address PR comments
derek-ho Sep 28, 2023
09b3db4
Include useful info in the error toast
derek-ho Sep 28, 2023
2a329e2
Update actions in manage table according to UX feedback
derek-ho Sep 29, 2023
8cbe04d
Add update button and update tests
derek-ho Sep 29, 2023
3ddb81d
Remove unused code until further implementation
derek-ho Sep 29, 2023
d8283b1
Fix router files
derek-ho Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/types/data_connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export interface PermissionsConfigurationProps {

export type Role = EuiComboBoxOptionOption;

export type DatasourceType = 'SPARK' | 'S3GLUE' | 'OPENSEARCH';
export type DatasourceType = 'SPARK' | 'S3GLUE' | 'OPENSEARCH' | 'PROMETHEUS';
3 changes: 2 additions & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"savedObjects",
"uiActions",
"urlForwarding",
"visualizations"
"visualizations",
"management"
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
],
"optionalPlugins": [
"managementOverview"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const ConnectionConfiguration = (props: ConnectionConfigurationProps) =>
const [details, setDetails] = useState(connectionDetails);

const [password, setPassword] = useState('');
const [dual, setDual] = useState(true);

const NameRow = () => {
return (
Expand Down Expand Up @@ -127,7 +126,7 @@ export const ConnectionConfiguration = (props: ConnectionConfigurationProps) =>
</EuiFormRow>
<EuiFormRow label="Password">
<EuiFieldPassword
type={dual ? 'dual' : undefined}
type={'dual'}
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
Expand Down
69 changes: 49 additions & 20 deletions public/components/datasources/components/manage/data_connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import {
import React, { useEffect, useState } from 'react';
import { AccessControlTab } from './access_control_tab';
import { NoAccess } from '../no_access';
import { DATACONNECTIONS_BASE } from '../../../../../common/constants/shared';
import {
DATACONNECTIONS_BASE,
observabilityLogsID,
observabilityMetricsID,
} from '../../../../../common/constants/shared';
import { coreRefs } from '../../../../framework/core_refs';
import { ConnectionDetails } from './connection_details';

Expand All @@ -44,7 +48,7 @@ export const DataConnection = (props: any) => {
properties: {},
});
const [hasAccess, setHasAccess] = useState(true);
const { http, chrome } = coreRefs;
const { http, chrome, application } = coreRefs;

useEffect(() => {
chrome!.setBreadcrumbs([
Expand Down Expand Up @@ -103,6 +107,48 @@ export const DataConnection = (props: any) => {
},
];

const QueryOrAccelerateData = () => {
console.log(chrome);
switch (datasourceDetails.connector) {
case 'S3GLUE':
return (
<EuiFlexGroup>
<EuiFlexItem>
<EuiCard
icon={<EuiIcon size="xxl" type="discoverApp" />}
title={'Query data'}
description="Query your data in Data Explorer or Observability Logs."
onClick={() => application!.navigateToApp(observabilityLogsID)}
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiCard
icon={<EuiIcon size="xxl" type="bolt" />}
title={'Accelerate performance'}
description="Accelerate performance through OpenSearch indexing."
onClick={() => {}}
derek-ho marked this conversation as resolved.
Show resolved Hide resolved
/>
</EuiFlexItem>
</EuiFlexGroup>
);
case 'PROMETHEUS':
return (
<EuiFlexGroup>
<EuiFlexItem>
<EuiCard
icon={<EuiIcon size="xxl" type="discoverApp" />}
title={'Query data'}
description="Query your data in Metrics Analytics."
onClick={() => application!.navigateToApp(observabilityMetricsID)}
/>
</EuiFlexItem>
</EuiFlexGroup>
);
default:
return null;
}
};

const DatasourceOverview = () => {
return (
<EuiPanel>
Expand Down Expand Up @@ -183,24 +229,7 @@ export const DataConnection = (props: any) => {
buttonContent="Ways to use in Dashboards"
initialIsOpen={true}
>
<EuiFlexGroup>
<EuiFlexItem>
<EuiCard
icon={<EuiIcon size="xxl" type="discoverApp" />}
title={'Query data'}
description="Query your data in Data Explorer or Observability Logs."
onClick={() => {}}
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiCard
icon={<EuiIcon size="xxl" type="bolt" />}
title={'Accelerate performance'}
description="Accelerate performance through OpenSearch indexing."
onClick={() => {}}
/>
</EuiFlexItem>
</EuiFlexGroup>
<QueryOrAccelerateData />
</EuiAccordion>
<EuiTabbedContent tabs={tabs} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { DATACONNECTIONS_BASE } from '../../../../../common/constants/shared';
import { useToast } from '../../../common/toast';
import { DeleteModal } from '../../../common/helpers/delete_modal';
import S3Logo from '../../icons/s3-logo.svg';
import PrometheusLogo from '../../icons/prometheus-logo.svg';
import { DatasourceType } from '../../../../../common/types/data_connections';

interface DataConnection {
Expand Down Expand Up @@ -97,6 +98,8 @@ export const ManageDataConnectionsTable = (props: HomeProps) => {
switch (record.connectionType) {
case 'S3GLUE':
return <EuiIcon type={S3Logo} />;
case 'PROMETHEUS':
return <EuiIcon type={PrometheusLogo} />;
default:
return <></>;
}
Expand Down
138 changes: 115 additions & 23 deletions public/components/datasources/components/new/configure_datasource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,27 @@ import { DATACONNECTIONS_BASE } from '../../../../../common/constants/shared';
import { ReviewS3Datasource } from './review_s3_datasource_configuration';
import { useToast } from '../../../../../public/components/common/toast';
import { DatasourceType, Role } from '../../../../../common/types/data_connections';
import { ConfigurePrometheusDatasource } from './configure_prometheus_datasource';
import { ReviewPrometheusDatasource } from './review_prometheus_datasource_configuration';

interface ConfigureDatasourceProps {
type: string;
}

export function Configure(props: ConfigureDatasourceProps) {
const { type } = props;
const { http } = coreRefs;
const { http, chrome } = coreRefs;
const { setToast } = useToast();

const [name, setName] = useState('');
const [details, setDetails] = useState('');
const [arn, setArn] = useState('');
const [store, setStore] = useState('');
const [storeURI, setStoreURI] = useState('');
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [accessKey, setAccessKey] = useState('');
const [secretKey, setSecretKey] = useState('');
const [region, setRegion] = useState('');
const [roles, setRoles] = useState<Role[]>([]);
const [selectedQueryPermissionRoles, setSelectedQueryPermissionRoles] = useState<Role[]>([]);
const [page, setPage] = useState<'configure' | 'review'>('configure');
Expand All @@ -59,6 +66,20 @@ export function Configure(props: ConfigureDatasourceProps) {
})
)
);
chrome!.setBreadcrumbs([
{
text: 'Data sources',
href: '#/',
},
{
text: 'New',
href: '#/new',
},
{
text: `${type}`,
href: `#/configure/${type}`,
},
]);
}, []);

const ConfigureDatasource = (configurationProps: { datasourceType: DatasourceType }) => {
Expand All @@ -73,13 +94,37 @@ export function Configure(props: ConfigureDatasourceProps) {
setDetailsForRequest={setDetails}
currentArn={arn}
setArnForRequest={setArn}
currentStore={store}
setStoreForRequest={setStore}
currentStore={storeURI}
setStoreForRequest={setStoreURI}
roles={roles}
selectedQueryPermissionRoles={selectedQueryPermissionRoles}
setSelectedQueryPermissionRoles={setSelectedQueryPermissionRoles}
/>
);
case 'PROMETHEUS':
return (
<ConfigurePrometheusDatasource
currentName={name}
currentDetails={details}
setNameForRequest={setName}
setDetailsForRequest={setDetails}
currentStore={storeURI}
setStoreForRequest={setStoreURI}
roles={roles}
currentUsername={username}
setUsernameForRequest={setUsername}
currentPassword={password}
setPasswordForRequest={setPassword}
selectedQueryPermissionRoles={selectedQueryPermissionRoles}
setSelectedQueryPermissionRoles={setSelectedQueryPermissionRoles}
currentAccessKey={accessKey}
currentSecretKey={secretKey}
setAccessKeyForRequest={setAccessKey}
setSecretKeyForRequest={setSecretKey}
currentRegion={region}
setRegionForRequest={setRegion}
Comment on lines +107 to +125
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Is there a way to reduce the number of props here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is side effect of this issue: #1054 (comment), if there is a cleaner way to do it I am all for it, but I couldn't find one with quick search

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't be an issue if we render the form inline, but rendering the form as a child is causing issues

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mis-understood your question here - I don't think there is a way to do so, since I need to know the values in the parent in order to send the request and have a way of updating them in the child. Thus I need to pass in value and setter for each of the possible configuration properties. Consolidating it into an object might be cleaner, but I think this way makes it clear what is going in and as what. Leaning towards keeping it like this for now

/>
);
default:
return <></>;
}
Expand All @@ -88,13 +133,25 @@ export function Configure(props: ConfigureDatasourceProps) {
const ReviewDatasourceConfiguration = (configurationProps: { datasourceType: string }) => {
const { datasourceType } = configurationProps;
switch (datasourceType) {
case 'S3':
case 'S3GLUE':
return (
<ReviewS3Datasource
currentName={name}
currentDetails={details}
currentArn={arn}
currentStore={store}
currentStore={storeURI}
selectedQueryPermissionRoles={selectedQueryPermissionRoles}
goBack={() => setPage('configure')}
/>
);
case 'PROMETHEUS':
return (
<ReviewPrometheusDatasource
currentName={name}
currentDetails={details}
currentArn={arn}
currentStore={storeURI}
currentUsername={username}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mentioned in other comment, but this would benefit from being consolidated in a currentContext object or something of the sort

selectedQueryPermissionRoles={selectedQueryPermissionRoles}
goBack={() => setPage('configure')}
/>
Expand Down Expand Up @@ -146,28 +203,63 @@ export function Configure(props: ConfigureDatasourceProps) {
}, [page]);

const createDatasource = () => {
http!
.post(`${DATACONNECTIONS_BASE}`, {
body: JSON.stringify({
name,
allowedRoles: selectedQueryPermissionRoles.map((role) => role.label),
connector: 's3glue',
properties: {
'glue.auth.type': 'iam_role',
'glue.auth.role_arn': arn,
'glue.indexstore.opensearch.uri': store,
'glue.indexstore.opensearch.auth': false,
'glue.indexstore.opensearch.region': 'us-west-2',
},
}),
})
let response;
switch (type) {
case 'S3GLUE':
response = http!.post(`${DATACONNECTIONS_BASE}`, {
body: JSON.stringify({
name,
allowedRoles: selectedQueryPermissionRoles.map((role) => role.label),
connector: 's3glue',
properties: {
'glue.auth.type': 'iam_role',
'glue.auth.role_arn': arn,
'glue.indexstore.opensearch.uri': storeURI,
'glue.indexstore.opensearch.auth': false,
'glue.indexstore.opensearch.region': 'us-west-2',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hardcoded?

},
}),
});
break;
case 'PROMETHEUS':
const properties = username
? {
'prometheus.uri': storeURI,
'prometheus.auth.type': 'basicauth',
'prometheus.auth.username': username,
'prometheus.auth.password': password,
}
: {
'prometheus.uri': storeURI,
'prometheus.auth.type': 'awssigv4',
'prometheus.auth.region': region,
'prometheus.auth.access_key': accessKey,
'prometheus.auth.secret_key': secretKey,
};
response = http!.post(`${DATACONNECTIONS_BASE}`, {
body: JSON.stringify({
name,
allowedRoles: selectedQueryPermissionRoles.map((role) => role.label),
connector: 'prometheus',
properties,
}),
});
break;
default:
response = Promise.reject('Invalid data source type');
}
response
.then(() => {
setToast(`Data source ${name} created`, 'success');
window.location.hash = '#/manage';
})
.catch((err) => {
setToast(`Data source ${name} created`, 'success');
window.location.hash = '#/manage';
setToast(
`Could not create data source`,
'danger',
`An error occured while trying to create the ${type} data source ${name}: ${err}`
);
setPage('configure');
});
};

Expand Down
Loading
Loading