Skip to content

Commit

Permalink
Merge branch 'main' into query-permormance
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Sep 25, 2023
2 parents 657a23d + d8b8090 commit 56804ab
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 289 deletions.
2 changes: 1 addition & 1 deletion docs/api/osquery-manager/packs/create.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ experimental[] Create packs.

`policy_ids`:: (Optional, array) A list of agents policy IDs.

`shards`:: (Required, object) An object with shard configuration for policies included in the pack. For each policy, set the shard configuration to a percentage (1–100) of target hosts.
`shards`:: (Optional, object) An object with shard configuration for policies included in the pack. For each policy, set the shard configuration to a percentage (1–100) of target hosts.

`queries`:: (Required, object) An object of queries.

Expand Down
9 changes: 6 additions & 3 deletions x-pack/plugins/profiling_data_access/common/fleet_policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { SavedObjectsClientContract } from '@kbn/core/server';
import type { PackagePolicyClient } from '@kbn/fleet-plugin/server';
import { PACKAGE_POLICY_SAVED_OBJECT_TYPE, PackagePolicy } from '@kbn/fleet-plugin/common';
import { getApmPolicy } from './get_apm_policy';
import { PartialSetupState, ProfilingSetupOptions } from './setup';

Expand All @@ -21,9 +22,11 @@ async function getPackagePolicy({
packagePolicyClient: PackagePolicyClient;
soClient: SavedObjectsClientContract;
packageName: string;
}) {
const packagePolicies = await packagePolicyClient.list(soClient, {});
return packagePolicies.items.find((pkg) => pkg.name === packageName);
}): Promise<PackagePolicy | undefined> {
const packagePolicies = await packagePolicyClient.list(soClient, {
kuery: `${PACKAGE_POLICY_SAVED_OBJECT_TYPE}.name:${packageName}`,
});
return packagePolicies.items[0];
}

export async function getCollectorPolicy({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { render } from '../../lib/helper/rtl_helpers';
import * as reactRouterDom from 'react-router-dom';

import { Ping } from '../../../../common/runtime_types';
import { MonitorPageTitle, MonitorPageTitleContent } from './monitor_title';
import { MonitorPageTitle } from './monitor_title';

jest.mock('react-router-dom', () => {
const originalModule = jest.requireActual('react-router-dom');
Expand Down Expand Up @@ -51,23 +51,6 @@ describe('MonitorTitle component', () => {
},
};

const defaultBrowserMonitorStatus: Ping = {
docId: 'few213kl',
timestamp: moment(new Date()).subtract(15, 'm').toString(),
monitor: {
duration: {
us: 1234567,
},
id: 'browser',
status: 'up',
type: 'browser',
check_group: 'test-group',
},
url: {
full: 'https://www.elastic.co/',
},
};

const monitorStatusWithName: Ping = {
...defaultMonitorStatus,
monitor: {
Expand All @@ -84,14 +67,12 @@ describe('MonitorTitle component', () => {
render(
<>
<MonitorPageTitle />
<MonitorPageTitleContent />
</>,
{
state: { monitorStatus: { status: monitorStatusWithName, loading: false } },
}
);
expect(screen.getByText(monitorName));
expect(screen.getByRole('switch')).toBeInTheDocument();
});

it('renders the user provided monitorId when the name is not present', () => {
Expand All @@ -114,16 +95,4 @@ describe('MonitorTitle component', () => {
);
expect(screen.getByText(defaultMonitorStatus!.url!.full!));
});

it('renders beta disclaimer for synthetics monitors', () => {
render(<MonitorPageTitleContent />, {
state: { monitorStatus: { status: defaultBrowserMonitorStatus, loading: false } },
});
const betaLink = screen.getByRole('link', {
name: 'See more External link (opens in a new tab or window)',
}) as HTMLAnchorElement;
expect(betaLink).toBeInTheDocument();
expect(betaLink.href).toBe('https://www.elastic.co/what-is/synthetic-monitoring');
expect(screen.getByText('Browser (BETA)')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
* 2.0.
*/

import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiLink, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import React from 'react';
import { useSelector } from 'react-redux';
import { useMonitorId } from '../../hooks';
import { monitorStatusSelector } from '../../state/selectors';
import { EnableMonitorAlert } from '../overview/monitor_list/columns/enable_alert';
import { Ping } from '../../../../common/runtime_types/ping';
import { useBreadcrumbs } from '../../hooks/use_breadcrumbs';

Expand All @@ -32,86 +29,6 @@ const getPageTitle = (monitorId: string, selectedMonitor: Ping | null) => {
return monitorId;
};

export const MonitorPageTitleContent: React.FC = () => {
const monitorId = useMonitorId();
const selectedMonitor = useSelector(monitorStatusSelector);
const type = selectedMonitor?.monitor?.type;
const isBrowser = type === 'browser';
const renderMonitorType = (monitorType: string) => {
switch (monitorType) {
case 'http':
return (
<FormattedMessage
id="xpack.uptime.monitorDetails.title.pingType.http"
defaultMessage="HTTP ping"
/>
);
case 'tcp':
return (
<FormattedMessage
id="xpack.uptime.monitorDetails.title.pingType.tcp"
defaultMessage="TCP ping"
/>
);
case 'icmp':
return (
<FormattedMessage
id="xpack.uptime.monitorDetails.title.pingType.icmp"
defaultMessage="ICMP ping"
/>
);
case 'browser':
return (
<FormattedMessage
id="xpack.uptime.monitorDetails.title.pingType.browser"
defaultMessage="Browser"
/>
);
default:
return '';
}
};
return (
<>
<EuiFlexGroup wrap={false} data-test-subj="monitorTitle">
<EuiFlexItem grow={false} style={{ justifyContent: 'center' }}>
<EnableMonitorAlert monitorId={monitorId} selectedMonitor={selectedMonitor!} />
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="s" />
<EuiFlexGroup wrap={false} gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
{isBrowser && type && (
<EuiBadge color="hollow">
{renderMonitorType(type)}{' '}
<FormattedMessage
id="xpack.uptime.monitorDetails.title.disclaimer.description"
defaultMessage="(BETA)"
/>
</EuiBadge>
)}
</EuiFlexItem>
{isBrowser && (
<EuiFlexItem grow={false}>
<EuiText>
<EuiLink
data-test-subj="syntheticsMonitorPageTitleContentSeeMoreLink"
href="https://www.elastic.co/what-is/synthetic-monitoring"
target="_blank"
>
<FormattedMessage
id="xpack.uptime.monitorDetails.title.disclaimer.link"
defaultMessage="See more"
/>
</EuiLink>
</EuiText>
</EuiFlexItem>
)}
</EuiFlexGroup>
</>
);
};

export const MonitorPageTitle: React.FC = () => {
const monitorId = useMonitorId();

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 56804ab

Please sign in to comment.