Skip to content

Commit

Permalink
[8.16] [Observability Onboarding] Show existing data callout in Fireh…
Browse files Browse the repository at this point in the history
…ose flow (#203072) (#203565)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Observability Onboarding] Show existing data callout in Firehose
flow (#203072)](#203072)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Mykola
Harmash","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-10T13:07:11Z","message":"[Observability
Onboarding] Show existing data callout in Firehose flow
(#203072)\n\nCloses
https://github.com/elastic/kibana/issues/190795\r\n\r\nAdds the logic to
display a message to the user in case there is already\r\nan existing
Firehose data in their cluster and to show the identified\r\nAWS
services in the \"Visualize Data\" step right away without waiting
for\r\nthe window to loose focus first.\r\n\r\n![CleanShot 2024-12-05 at
11
50\r\n59@2x](https://github.com/user-attachments/assets/00653bf0-f711-4029-9011-a34a160b4b9b)\r\n\r\n\r\n##
How to test\r\n\r\n1. Open the Firehose flow\r\n2. Make sure there is no
callout and the third step is not active\r\n3. Go to Kibana dev console
and ingest some dummy data (see examples\r\nbellow)\r\n4. Refresh the
page with the Firehose flow\r\n5. make sure there is a callout and the
third steps shows the identified\r\nAWS service\r\n\r\n```\r\nPOST
logs-aws.apigateway_logs-default/_doc\r\n{\r\n \"@timestamp\":
\"2024-11-25T13:32:01.000Z\",\r\n \"some\": 111,\r\n
\"aws.kinesis.name\": \"Elastic-CloudwatchLogs\"\r\n}\r\n\r\nPOST
metrics-aws.apigateway_metrics-default/_doc\r\n{\r\n \"@timestamp\":
\"2024-11-25T13:31:01.000Z\",\r\n \"agent\": {\r\n \"type\":
\"firehose\"\r\n },\r\n \"aws\": {\r\n \"cloudwatch\": {\r\n
\"namespace\": \"AWS/ApiGateway\"\r\n },\r\n \"exporter\": {\r\n
\"arn\":
\"arn:aws:cloudwatch:us-west-2:975050175126:metric-stream/Elastic-CloudwatchLogsAndMetricsToFirehose-CloudWatchMetricStream-Nhb4NhzPdL4J\"\r\n
}\r\n },\r\n \"cloud\": {\r\n \"account\": {\r\n \"id\":
\"975050175126\"\r\n },\r\n \"provider\": \"aws\",\r\n \"region\":
\"us-west-2\"\r\n
}\r\n}\r\n```","sha":"6cb14302a1a3fd157d1e1947493a0d0d5f4980f6","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","backport:prev-major","ci:project-deploy-observability","Team:obs-ux-logs","Feature:
Observability Onboarding"],"title":"[Observability Onboarding] Show
existing data callout in Firehose
flow","number":203072,"url":"https://github.com/elastic/kibana/pull/203072","mergeCommit":{"message":"[Observability
Onboarding] Show existing data callout in Firehose flow
(#203072)\n\nCloses
https://github.com/elastic/kibana/issues/190795\r\n\r\nAdds the logic to
display a message to the user in case there is already\r\nan existing
Firehose data in their cluster and to show the identified\r\nAWS
services in the \"Visualize Data\" step right away without waiting
for\r\nthe window to loose focus first.\r\n\r\n![CleanShot 2024-12-05 at
11
50\r\n59@2x](https://github.com/user-attachments/assets/00653bf0-f711-4029-9011-a34a160b4b9b)\r\n\r\n\r\n##
How to test\r\n\r\n1. Open the Firehose flow\r\n2. Make sure there is no
callout and the third step is not active\r\n3. Go to Kibana dev console
and ingest some dummy data (see examples\r\nbellow)\r\n4. Refresh the
page with the Firehose flow\r\n5. make sure there is a callout and the
third steps shows the identified\r\nAWS service\r\n\r\n```\r\nPOST
logs-aws.apigateway_logs-default/_doc\r\n{\r\n \"@timestamp\":
\"2024-11-25T13:32:01.000Z\",\r\n \"some\": 111,\r\n
\"aws.kinesis.name\": \"Elastic-CloudwatchLogs\"\r\n}\r\n\r\nPOST
metrics-aws.apigateway_metrics-default/_doc\r\n{\r\n \"@timestamp\":
\"2024-11-25T13:31:01.000Z\",\r\n \"agent\": {\r\n \"type\":
\"firehose\"\r\n },\r\n \"aws\": {\r\n \"cloudwatch\": {\r\n
\"namespace\": \"AWS/ApiGateway\"\r\n },\r\n \"exporter\": {\r\n
\"arn\":
\"arn:aws:cloudwatch:us-west-2:975050175126:metric-stream/Elastic-CloudwatchLogsAndMetricsToFirehose-CloudWatchMetricStream-Nhb4NhzPdL4J\"\r\n
}\r\n },\r\n \"cloud\": {\r\n \"account\": {\r\n \"id\":
\"975050175126\"\r\n },\r\n \"provider\": \"aws\",\r\n \"region\":
\"us-west-2\"\r\n
}\r\n}\r\n```","sha":"6cb14302a1a3fd157d1e1947493a0d0d5f4980f6"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203072","number":203072,"mergeCommit":{"message":"[Observability
Onboarding] Show existing data callout in Firehose flow
(#203072)\n\nCloses
https://github.com/elastic/kibana/issues/190795\r\n\r\nAdds the logic to
display a message to the user in case there is already\r\nan existing
Firehose data in their cluster and to show the identified\r\nAWS
services in the \"Visualize Data\" step right away without waiting
for\r\nthe window to loose focus first.\r\n\r\n![CleanShot 2024-12-05 at
11
50\r\n59@2x](https://github.com/user-attachments/assets/00653bf0-f711-4029-9011-a34a160b4b9b)\r\n\r\n\r\n##
How to test\r\n\r\n1. Open the Firehose flow\r\n2. Make sure there is no
callout and the third step is not active\r\n3. Go to Kibana dev console
and ingest some dummy data (see examples\r\nbellow)\r\n4. Refresh the
page with the Firehose flow\r\n5. make sure there is a callout and the
third steps shows the identified\r\nAWS service\r\n\r\n```\r\nPOST
logs-aws.apigateway_logs-default/_doc\r\n{\r\n \"@timestamp\":
\"2024-11-25T13:32:01.000Z\",\r\n \"some\": 111,\r\n
\"aws.kinesis.name\": \"Elastic-CloudwatchLogs\"\r\n}\r\n\r\nPOST
metrics-aws.apigateway_metrics-default/_doc\r\n{\r\n \"@timestamp\":
\"2024-11-25T13:31:01.000Z\",\r\n \"agent\": {\r\n \"type\":
\"firehose\"\r\n },\r\n \"aws\": {\r\n \"cloudwatch\": {\r\n
\"namespace\": \"AWS/ApiGateway\"\r\n },\r\n \"exporter\": {\r\n
\"arn\":
\"arn:aws:cloudwatch:us-west-2:975050175126:metric-stream/Elastic-CloudwatchLogsAndMetricsToFirehose-CloudWatchMetricStream-Nhb4NhzPdL4J\"\r\n
}\r\n },\r\n \"cloud\": {\r\n \"account\": {\r\n \"id\":
\"975050175126\"\r\n },\r\n \"provider\": \"aws\",\r\n \"region\":
\"us-west-2\"\r\n
}\r\n}\r\n```","sha":"6cb14302a1a3fd157d1e1947493a0d0d5f4980f6"}}]}]
BACKPORT-->

Co-authored-by: Mykola Harmash <[email protected]>
  • Loading branch information
kibanamachine and mykolaharmash authored Dec 10, 2024
1 parent ebe4505 commit 371ae4d
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';
import { EuiCallOut, useIsWithinMaxBreakpoint } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

export function ExistingDataCallout() {
const isMobile = useIsWithinMaxBreakpoint('s');

return (
<div css={{ maxWidth: isMobile ? '100%' : '80%' }}>
<EuiCallOut
title={i18n.translate('xpack.observability_onboarding.firehose.existingDataCallout.title', {
defaultMessage: 'This workflow has been used before.',
})}
iconType="iInCircle"
color="warning"
data-test-subj="observabilityOnboardingFirehosePanelExistingDataCallout"
>
<p>
{i18n.translate(
'xpack.observability_onboarding.firehose.existingDataCallout.description',
{
defaultMessage: `If the Amazon Firehose Data stream(s) associated with this workflow are still active, you will encounter errors during onboarding. Navigate to Step 3 below in order to explore your services.`,
}
)}
</p>
</EuiCallOut>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { useFirehoseFlow } from './use_firehose_flow';
import { VisualizeData } from './visualize_data';
import { ObservabilityOnboardingAppServices } from '../../..';
import { useWindowBlurDataMonitoringTrigger } from '../shared/use_window_blur_data_monitoring_trigger';
import { ExistingDataCallout } from './existing_data_callout';
import { usePopulatedAWSIndexList } from './use_populated_aws_index_list';

const OPTIONS = [
{
Expand Down Expand Up @@ -61,6 +63,9 @@ export function FirehosePanel() {
},
} = useKibana<ObservabilityOnboardingAppServices>();
const { data, status, error, refetch } = useFirehoseFlow();
const { data: populatedAWSIndexList } = usePopulatedAWSIndexList();

const hasExistingData = Array.isArray(populatedAWSIndexList) && populatedAWSIndexList.length > 0;

const telemetryEventContext: OnboardingFlowEventContext = useMemo(
() => ({
Expand All @@ -72,12 +77,13 @@ export function FirehosePanel() {
[cloudServiceProvider, selectedOptionId]
);

const isMonitoringData = useWindowBlurDataMonitoringTrigger({
isActive: status === FETCH_STATUS.SUCCESS,
onboardingFlowType: 'firehose',
onboardingId: data?.onboardingId,
telemetryEventContext,
});
const isMonitoringData =
useWindowBlurDataMonitoringTrigger({
isActive: status === FETCH_STATUS.SUCCESS,
onboardingFlowType: 'firehose',
onboardingId: data?.onboardingId,
telemetryEventContext,
}) || hasExistingData;

const onOptionChange = useCallback((id: string) => {
setSelectedOptionId(id as CreateStackOption);
Expand Down Expand Up @@ -193,13 +199,20 @@ export function FirehosePanel() {
<VisualizeData
selectedCreateStackOption={selectedOptionId}
onboardingId={data.onboardingId}
hasExistingData={hasExistingData}
/>
),
},
];

return (
<EuiPanel hasBorder paddingSize="xl">
{hasExistingData && (
<>
<ExistingDataCallout />
<EuiSpacer size="xl" />
</>
)}
<EuiSteps steps={steps} />
<FeedbackButtons flow="firehose" />
</EuiPanel>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { useFetcher } from '../../../hooks/use_fetcher';
import {
FIREHOSE_CLOUDFORMATION_STACK_NAME,
FIREHOSE_LOGS_STREAM_NAME,
} from '../../../../common/aws_firehose';

export function usePopulatedAWSIndexList() {
return useFetcher((callApi) => {
return callApi('GET /internal/observability_onboarding/firehose/has-data', {
params: {
query: {
logsStreamName: FIREHOSE_LOGS_STREAM_NAME,
stackName: FIREHOSE_CLOUDFORMATION_STACK_NAME,
},
},
});
}, []);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import { unionBy } from 'lodash';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { FormattedMessage } from '@kbn/i18n-react';
import { ObservabilityOnboardingAppServices } from '../../..';
import {
FIREHOSE_CLOUDFORMATION_STACK_NAME,
FIREHOSE_LOGS_STREAM_NAME,
} from '../../../../common/aws_firehose';
import { FETCH_STATUS, useFetcher } from '../../../hooks/use_fetcher';
import { FETCH_STATUS } from '../../../hooks/use_fetcher';
import { AccordionWithIcon } from '../shared/accordion_with_icon';
import { GetStartedPanel } from '../shared/get_started_panel';
import {
Expand All @@ -28,34 +24,25 @@ import { AutoRefreshCallout } from './auto_refresh_callout';
import { ProgressCallout } from './progress_callout';
import { HAS_DATA_FETCH_INTERVAL } from './utils';
import { CreateStackOption } from './types';
import { usePopulatedAWSIndexList } from './use_populated_aws_index_list';

const REQUEST_PENDING_STATUS_LIST = [FETCH_STATUS.LOADING, FETCH_STATUS.NOT_INITIATED];

interface Props {
onboardingId: string;
selectedCreateStackOption: CreateStackOption;
hasExistingData: boolean;
}

export function VisualizeData({ onboardingId, selectedCreateStackOption }: Props) {
export function VisualizeData({ onboardingId, selectedCreateStackOption, hasExistingData }: Props) {
const accordionId = useGeneratedHtmlId({ prefix: 'accordion' });
const [orderedVisibleAWSServiceList, setOrderedVisibleAWSServiceList] = useState<
AWSServiceGetStartedConfig[]
>([]);
const [shouldShowDataReceivedToast, setShouldShowDataReceivedToast] = useState<boolean>(true);
const {
data: populatedAWSIndexList,
status,
refetch,
} = useFetcher((callApi) => {
return callApi('GET /internal/observability_onboarding/firehose/has-data', {
params: {
query: {
logsStreamName: FIREHOSE_LOGS_STREAM_NAME,
stackName: FIREHOSE_CLOUDFORMATION_STACK_NAME,
},
},
});
}, []);
const [shouldShowDataReceivedToast, setShouldShowDataReceivedToast] = useState<boolean>(
!hasExistingData
);
const { data: populatedAWSIndexList, status, refetch } = usePopulatedAWSIndexList();
const {
services: {
notifications,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,39 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
// Checking that an AWS service item is visible after data is detected
await testSubjects.isDisplayed(`observabilityOnboardingAWSService-${AWS_SERVICE_ID}`);
});

it('shows the existing data callout and detected AWS services when data was ingested previously', async () => {
const DATASET = 'aws.vpcflow';
const AWS_SERVICE_ID = 'vpc-flow';
await testSubjects.clickWhenNotDisabled('observabilityOnboardingCopyToClipboardButton');
const copiedCommand = await browser.getClipboardValue();
const [, _stackName, logsStreamName] = copiedCommand.match(CF_COMMAND_REGEXP) ?? [];

await testSubjects.missingOrFail('observabilityOnboardingFirehosePanelExistingDataCallout');

expect(logsStreamName).toBeDefined();

// Simulate Firehose stream ingesting log files
const to = new Date().toISOString();
const count = 1;
await synthtrace.index(
timerange(moment(to).subtract(count, 'minute'), moment(to))
.interval('1m')
.rate(1)
.generator((timestamp) => {
return log.create().dataset(DATASET).timestamp(timestamp).defaults({
'aws.kinesis.name': logsStreamName,
});
})
);

await browser.refresh();

// Checking that the existing data callout is visible after data is detected
await testSubjects.isDisplayed('observabilityOnboardingFirehosePanelExistingDataCallout');

// Checking that an AWS service item is visible after data is detected
await testSubjects.isDisplayed(`observabilityOnboardingAWSService-${AWS_SERVICE_ID}`);
});
});
}

0 comments on commit 371ae4d

Please sign in to comment.