Skip to content

Commit

Permalink
[Synthetics] Refactor cardinality test runs query (#166608)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Sep 26, 2023
1 parent fd1a1f9 commit 59c5eb0
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ export class LensAttributes {
dataType: 'number',
isBucketed: false,
label: label || 'Count of records',
customLabel: true,
operationType: 'count',
scale: 'ratio',
sourceField: RECORDS_FIELD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
PERCENTILE,
ReportTypes,
FORMULA_COLUMN,
RECORDS_FIELD,
} from '../constants';
import {
CLS_LABEL,
Expand Down Expand Up @@ -124,8 +125,8 @@ export function getSyntheticsKPIConfig({ dataView }: ConfigProps): SeriesConfig
},
{
label: 'Total runs',
id: 'monitor.check_group',
field: 'monitor.check_group',
id: 'total_test_runs',
field: RECORDS_FIELD,
columnType: OPERATION_COLUMN,
columnFilters: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ export function getSyntheticsSingleMetricConfig({ dataView }: ConfigProps): Seri
titlePosition: 'bottom',
},
columnType: FORMULA_COLUMN,
formula: "unique_count(monitor.check_group, kql='summary: *')",
format: 'number',
field: RECORDS_FIELD,
columnFilter: { language: 'kuery', query: 'summary: *' },
},
{
id: 'monitor_successful',
Expand All @@ -114,9 +115,9 @@ export function getSyntheticsSingleMetricConfig({ dataView }: ConfigProps): Seri
metricStateOptions: {
titlePosition: 'bottom',
},
columnType: FORMULA_COLUMN,
formula: 'unique_count(monitor.check_group, kql=\'monitor.status: "up"\')',
format: 'number',
field: RECORDS_FIELD,
columnFilter: { language: 'kuery', query: 'summary.down: 0' },
},
{
id: 'monitor_errors',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const sampleAttributeCoreWebVital = {
sourceField: 'user_agent.os.name',
},
'y-axis-column-1': {
customLabel: true,
dataType: 'number',
filter: {
language: 'kuery',
Expand All @@ -67,6 +68,7 @@ export const sampleAttributeCoreWebVital = {
sourceField: RECORDS_FIELD,
},
'y-axis-column-2': {
customLabel: true,
dataType: 'number',
filter: {
language: 'kuery',
Expand All @@ -79,6 +81,7 @@ export const sampleAttributeCoreWebVital = {
sourceField: RECORDS_FIELD,
},
'y-axis-column-layer0-0': {
customLabel: true,
dataType: 'number',
filter: {
language: 'kuery',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const sampleAttributeKpi = {
},
isBucketed: false,
label: 'test-series',
customLabel: true,
operationType: 'count',
scale: 'ratio',
sourceField: RECORDS_FIELD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const MonitorForm: React.FC<{
defaultValues?: SyntheticsMonitor;
space?: string;
readOnly?: boolean;
canUsePublicLocations: boolean;
canUsePublicLocations?: boolean;
}> = ({ children, defaultValues, space, readOnly = false, canUsePublicLocations }) => {
const methods = useFormWrapped({
mode: 'onSubmit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ActionBar = ({
canUsePublicLocations = true,
}: {
readOnly: boolean;
canUsePublicLocations: boolean;
canUsePublicLocations?: boolean;
}) => {
const { monitorId } = useParams<{ monitorId: string }>();
const history = useHistory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export const MonitorTestRunsSparkline = ({ monitorIds }: { monitorIds: string[]
'monitor.id': monitorIds.length > 0 ? monitorIds : ['false-monitor-id'], // Show no data when monitorIds is empty
},
dataType: 'synthetics' as const,
selectedMetricField: 'monitor.check_group',
selectedMetricField: 'total_test_runs',
filters: [],
name: labels.TEST_RUNS_LABEL,
color: theme.eui.euiColorVis1,
operationType: 'unique_count',
operationType: 'count',
},
];
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,46 @@

import React, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiPopover } from '@elastic/eui';
import styled from 'styled-components';
import {
EuiPopover,
EuiDescriptionListTitle,
EuiDescriptionListDescription,
EuiButtonEmpty,
} from '@elastic/eui';
import { Ping } from '../../../../../../common/runtime_types';
import { PingRedirects } from '../../ping_list/ping_redirects';
import { MonListDescription, MonListTitle } from './status_bar';

interface Props {
monitorStatus: Ping | null;
}

const RedirectBtn = styled.span`
cursor: pointer;
`;

export const MonitorRedirects: React.FC<Props> = ({ monitorStatus }) => {
const list = monitorStatus?.http?.response?.redirects;

const [isPopoverOpen, setIsPopoverOpen] = useState(false);

const button = (
<MonListDescription>
<RedirectBtn
<EuiDescriptionListDescription>
<EuiButtonEmpty
className="euiLink euiLink--primary"
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
data-test-subj="uptimeMonitorRedirectInfo"
iconType="arrowDown"
iconSide="right"
>
{i18n.translate('xpack.uptime.monitorList.redirects.title.number', {
defaultMessage: '{number}',
values: {
number: list?.length ?? 0,
},
})}
</RedirectBtn>
</MonListDescription>
</EuiButtonEmpty>
</EuiDescriptionListDescription>
);

return list ? (
<>
<MonListTitle>Redirects</MonListTitle>
<EuiDescriptionListTitle>Redirects</EuiDescriptionListTitle>
<EuiPopover
button={button}
isOpen={isPopoverOpen}
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/uptime/server/legacy_uptime/lib/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { DYNAMIC_SETTINGS_DEFAULT_ATTRIBUTES } from '../../constants/settings';
import { DynamicSettingsAttributes } from '../../runtime_types/settings';
import { settingsObjectId, umDynamicSettings } from './saved_objects/uptime_settings';
import { API_URLS } from '../../../common/constants';
import { UptimeServerSetup } from './adapters';

export type { UMServerLibs } from '../uptime_server';

Expand Down Expand Up @@ -287,7 +286,3 @@ export function debugESCall({
}
console.log(`\n`);
}

export const isTestUser = (server: UptimeServerSetup) => {
return server.config.service?.username === 'localKibanaIntegrationTestsUser';
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { KibanaResponse } from '@kbn/core-http-router-server-internal';
import { UMKibanaRouteWrapper } from './types';
import { isTestUser, UptimeEsClient } from '../lib/lib';
import { UptimeEsClient } from '../lib/lib';

export const uptimeRouteWrapper: UMKibanaRouteWrapper = (uptimeRoute, server) => ({
...uptimeRoute,
Expand All @@ -24,7 +24,7 @@ export const uptimeRouteWrapper: UMKibanaRouteWrapper = (uptimeRoute, server) =>
{
request,
uiSettings: coreContext.uiSettings,
isDev: Boolean(server.isDev && !isTestUser(server)),
isDev: Boolean(server.isDev),
}
);

Expand Down

0 comments on commit 59c5eb0

Please sign in to comment.