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

Fix integration labeling to identify S3 integrations #1157

Merged
merged 9 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
}
}
loading={false}
loadingProgress={0}
setLoading={[Function]}
setProgress={[Function]}
setSetupCallout={[Function]}
>
<EuiBottomBar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ export function AvailableIntegrationOverviewPage(props: AvailableIntegrationOver
http.get(`${INTEGRATIONS_BASE}/repository`).then((exists) => {
setData(exists.data);

let newItems = exists.data.hits.flatMap((hit: { labels?: string[] }) => hit.labels ?? []);
let newItems = exists.data.hits.flatMap(
(hit: { labels?: string[] }) => hit.labels?.sort() ?? []
);
newItems = [...new Set(newItems)].sort().map((newItem) => {
return {
name: newItem,
Expand Down Expand Up @@ -182,13 +184,7 @@ export function AvailableIntegrationOverviewPage(props: AvailableIntegrationOver
{isCardView
? AvailableIntegrationsCardView({
data: {
hits: data.hits.filter((hit) =>
helper.every((compon) =>
hit.components
.map((x) => x.name.split('_').findLast(() => true))
.includes(compon)
)
),
hits: data.hits.filter((hit) => helper.every((tag) => hit.labels?.includes(tag))),
},
isCardView,
setCardView,
Expand All @@ -200,13 +196,7 @@ export function AvailableIntegrationOverviewPage(props: AvailableIntegrationOver
: AvailableIntegrationsTable({
loading: false,
data: {
hits: data.hits.filter((hit) =>
helper.every((compon) =>
hit.components
.map((x) => x.name.split('_').findLast(() => true))
.includes(compon)
)
),
hits: data.hits.filter((hit) => helper.every((tag) => hit.labels?.includes(tag))),
},
isCardView,
setCardView,
Expand Down
47 changes: 10 additions & 37 deletions public/components/integrations/components/setup_integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import {
EuiButtonEmpty,
EuiCallOut,
EuiComboBox,
EuiEmptyPrompt,
EuiFieldText,
EuiFlexGroup,
EuiFlexItem,
EuiForm,
EuiFormRow,
EuiLoadingDashboards,
EuiLoadingLogo,
EuiPage,
EuiPageBody,
EuiPageContent,
EuiPageContentBody,
EuiProgress,
EuiSelect,
EuiSpacer,
EuiText,
Expand Down Expand Up @@ -274,16 +274,12 @@ export function SetupBottomBar({
integration,
loading,
setLoading,
loadingProgress,
setProgress,
setSetupCallout,
}: {
config: IntegrationSetupInputs;
integration: IntegrationTemplate;
loading: boolean;
setLoading: (loading: boolean) => void;
loadingProgress: number;
setProgress: (updater: number | ((progress: number) => number)) => void;
setSetupCallout: (setupCallout: SetupCallout) => void;
}) {
// Drop-in replacement for setToast
Expand Down Expand Up @@ -333,14 +329,12 @@ export function SetupBottomBar({
config.displayName,
config.connectionDataSource
);
setProgress((progress) => progress + 1);
} else if (config.connectionType === 's3') {
const http = coreRefs.http!;

const assets = await http.get(
`${INTEGRATIONS_BASE}/repository/${integration.name}/assets`
);
setProgress((progress) => progress + 1);

// Queries must exist because we disable s3 if they're not present
for (const query of assets.data.queries!) {
Expand All @@ -350,10 +344,7 @@ export function SetupBottomBar({
);
queryStr = queryStr.replaceAll('{s3_bucket_location}', config.connectionLocation);
queryStr = queryStr.replaceAll('{object_name}', integration.name);
const currProgress = loadingProgress; // Need a frozen copy for getting accurate query steps
const result = await runQuery(queryStr, (step) =>
setProgress(currProgress + step)
);
const result = await runQuery(queryStr, (_) => {});
if (!result.ok) {
setLoading(false);
setCalloutLikeToast(
Expand All @@ -375,7 +366,6 @@ export function SetupBottomBar({
config.displayName,
config.connectionDataSource
);
setProgress((progress) => progress + 1);
} else {
console.error('Invalid data source type');
}
Expand All @@ -390,27 +380,14 @@ export function SetupBottomBar({
);
}

export function LoadingPage({ value, max }: { value: number; max: number }) {
export function LoadingPage() {
return (
<>
<EuiSpacer size="xxl" />
<EuiFlexGroup direction="column" justifyContent="center" alignItems="center">
<EuiFlexItem grow={false}>
<EuiLoadingDashboards size="xxl" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiTitle>
<h3>Adding Integration</h3>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText>
This may take a few minutes. The integration and assets are being added.
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer />
<EuiProgress value={value} max={max} size="m" />
<EuiEmptyPrompt
icon={<EuiLoadingLogo logo="logoOpenSearch" size="xl" />}
title={<h2>Setting Up the Integration</h2>}
body={<p>This can take several minutes.</p>}
/>
</>
);
}
Expand All @@ -432,7 +409,6 @@ export function SetupIntegrationPage({ integration }: { integration: string }) {
const [setupCallout, setSetupCallout] = useState({ show: false } as SetupCallout);

const [showLoading, setShowLoading] = useState(false);
const [loadingProgress, setLoadingProgress] = useState(0);

useEffect(() => {
const getTemplate = async () => {
Expand All @@ -445,15 +421,14 @@ export function SetupIntegrationPage({ integration }: { integration: string }) {

const updateConfig = (updates: Partial<IntegrationSetupInputs>) =>
setConfig(Object.assign({}, integConfig, updates));
const maxProgress = 2 + 3 * (template.assets?.queries?.length ?? 0);

return (
<EuiPage>
<EuiPageBody>
<EuiPageContent>
<EuiPageContentBody>
{showLoading ? (
<LoadingPage value={loadingProgress} max={maxProgress} />
<LoadingPage />
) : (
<SetupIntegrationForm
config={integConfig}
Expand All @@ -469,8 +444,6 @@ export function SetupIntegrationPage({ integration }: { integration: string }) {
integration={template}
loading={showLoading}
setLoading={setShowLoading}
loadingProgress={loadingProgress}
setProgress={setLoadingProgress}
setSetupCallout={setSetupCallout}
/>
</EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Apache web logs collector",
"license": "Apache-2.0",
"type": "logs_apache",
"labels": ["log", "communication", "http"],
"labels": ["Observability", "Logs"],
"author": "OpenSearch",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/apache/info",
"statics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "AWS cloudfront Object Store",
"license": "Apache-2.0",
"type": "logs-aws_cloudfront",
"labels": ["log", "aws", "s3", "cloud", "cloudfront"],
"labels": ["Observability", "Logs", "AWS", "Cloud"],
"author": "OpenSearch",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/aws_cloudfront/info",
"statics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "AWS CloudTrail log collector",
"license": "Apache-2.0",
"type": "logs-aws_cloudtrail",
"labels": ["log", "aws", "s3", "cloud", "cloudtrail"],
"labels": ["Observability", "Logs", "AWS", "Flint S3", "Cloud"],
"author": "OpenSearch",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/aws_cloudtrail/info",
"statics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "AWS Elastic Load Balancer collector",
"license": "Apache-2.0",
"type": "logs_elb",
"labels": ["log", "aws", "communication", "http", "cloud", "elb", "url"],
"labels": ["Observability", "Logs", "AWS", "Flint S3", "Cloud"],
"author": "OpenSearch",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/aws_elb/info",
"statics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "AWS RDS",
"license": "Apache-2.0",
"type": "logs_rds",
"labels": ["log", "aws", "s3", "cloud", "rds"],
"labels": ["Observability", "Logs", "AWS", "Cloud"],
"author": "OpenSearch",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/aws_rds/info",
"statics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "AWS S3 Object Store",
"license": "Apache-2.0",
"type": "logs_s3",
"labels": ["log", "aws", "s3", "cloud"],
"labels": ["Observability", "Logs", "AWS", "Cloud"],
"author": "OpenSearch",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/aws_s3/info",
"statics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "AWS VPC Flow log collector",
"license": "Apache-2.0",
"type": "logs_vpc",
"labels": ["log", "aws", "s3", "cloud", "communication", "vpc"],
"labels": ["Observability", "Logs", "AWS", "Flint S3", "Cloud"],
"author": "Haidong Wang",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/aws_vpc_flow/info",
"statics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "AWS waf log collector",
"license": "Apache-2.0",
"type": "logs_waf",
"labels": ["log", "aws", "s3", "cloud", "waf"],
"labels": ["Observability", "Logs", "AWS", "Cloud"],
"author": "OpenSearch",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/aws_waf/info",
"statics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Kubernetes web logs collector",
"license": "Apache-2.0",
"type": "logs-k8s",
"labels": ["log", "k8s", "cloud", "container"],
"labels": ["Observability", "Logs", "Cloud"],
"author": "OpenSearch",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/k8s/info",
"statics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Nginx HTTP server collector",
"license": "Apache-2.0",
"type": "logs",
"labels": ["log", "http", "communication"],
"labels": ["Observability", "Logs", "Flint S3"],
"author": "OpenSearch",
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/nginx/info",
"statics": {
Expand Down
1 change: 1 addition & 0 deletions server/adaptors/integrations/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const templateSchema: JSONSchemaType<IntegrationConfig> = {
license: { type: 'string' },
type: { type: 'string' },
labels: { type: 'array', items: { type: 'string' }, nullable: true },
tags: { type: 'array', items: { type: 'string' }, nullable: true },
author: { type: 'string', nullable: true },
description: { type: 'string', nullable: true },
sourceUrl: { type: 'string', nullable: true },
Expand Down
Loading