Skip to content

Commit

Permalink
Merge branch 'main' of github.com:elastic/kibana into assign-presenta…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
wayneseymour committed Nov 18, 2024
2 parents 707f87b + 1a1f29f commit 579a370
Show file tree
Hide file tree
Showing 17 changed files with 392 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type DateHistogramColumnParams = DateHistogramIndexPatternColumn['params'

export type TopValuesColumnParams = Pick<
TermsIndexPatternColumn['params'],
'size' | 'orderDirection' | 'orderBy' | 'secondaryFields' | 'accuracyMode'
'size' | 'orderDirection' | 'orderBy' | 'secondaryFields' | 'accuracyMode' | 'orderAgg'
>;

export const getHistogramColumn = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const mockKibanaValues = {
indexMappingComponent: null,
isCloud: false,
isSidebarEnabled: true,
kibanaVersion: null,
lens: {
EmbeddableComponent: jest.fn(),
stateHelperApi: jest.fn().mockResolvedValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ export interface DockerInstructionsStepProps {
hasApiKey: boolean;
isWaitingForConnector: boolean;
serviceType: string;
connectorVersion: string;
}
export const DockerInstructionsStep: React.FC<DockerInstructionsStepProps> = ({
connectorId,
isWaitingForConnector,
serviceType,
apiKeyData,
connectorVersion,
}) => {
const [isOpen, setIsOpen] = React.useState<EuiAccordionProps['forceState']>('open');
const { elasticsearchUrl } = useCloudDetails();
Expand Down Expand Up @@ -163,7 +165,7 @@ export const DockerInstructionsStep: React.FC<DockerInstructionsStepProps> = ({
showTopBar={false}
languageType="bash"
codeSnippet={getRunFromDockerSnippet({
version: '8.15.0',
version: connectorVersion,
})}
/>
</EuiAccordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { ConnectorStatus } from '@kbn/search-connectors';

import { Status } from '../../../../../common/types/api';

import { KibanaLogic } from '../../../shared/kibana';
import { GetApiKeyByIdLogic } from '../../api/api_key/get_api_key_by_id_api_logic';

import { GenerateConnectorApiKeyApiLogic } from '../../api/connector/generate_connector_api_key_api_logic';
Expand All @@ -48,6 +49,7 @@ export const ConnectorDeployment: React.FC = () => {
const [selectedDeploymentMethod, setSelectedDeploymentMethod] = useState<'docker' | 'source'>(
'docker'
);
const { kibanaVersion } = useValues(KibanaLogic);
const { generatedData, isGenerateLoading } = useValues(DeploymentLogic);
const { index, isLoading, connector, connectorId } = useValues(ConnectorViewLogic);
const { fetchConnector } = useActions(ConnectorViewLogic);
Expand Down Expand Up @@ -199,6 +201,7 @@ export const ConnectorDeployment: React.FC = () => {
serviceType={connector.service_type ?? ''}
isWaitingForConnector={isWaitingForConnector}
apiKeyData={apiKey}
connectorVersion={kibanaVersion ?? ''}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const renderApp = (
history,
indexMappingComponent,
isSidebarEnabled,
kibanaVersion,
lens,
ml,
navigateToUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface KibanaLogicProps {
history: ScopedHistory;
indexMappingComponent?: React.FC<IndexMappingProps>;
isSidebarEnabled: boolean;
kibanaVersion?: string;
lens?: LensPublicStart;
ml?: MlPluginStart;
navigateToUrl: RequiredFieldsOnly<ApplicationStart['navigateToUrl']>;
Expand Down Expand Up @@ -94,6 +95,7 @@ export interface KibanaValues {
indexMappingComponent: React.FC<IndexMappingProps> | null;
isCloud: boolean;
isSidebarEnabled: boolean;
kibanaVersion: string | null;
lens: LensPublicStart | null;
ml: MlPluginStart | null;
navigateToUrl(path: string, options?: CreateHrefOptions): Promise<void>;
Expand Down Expand Up @@ -133,6 +135,7 @@ export const KibanaLogic = kea<MakeLogicType<KibanaValues>>({
history: [props.history, {}],
indexMappingComponent: [props.indexMappingComponent || null, {}],
isSidebarEnabled: [props.isSidebarEnabled, {}],
kibanaVersion: [props.kibanaVersion || null, {}],
lens: [props.lens || null, {}],
ml: [props.ml || null, {}],
navigateToUrl: [
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export class EnterpriseSearchPlugin implements Plugin {
this.esConfig = { elasticsearch_host: ELASTICSEARCH_URL_PLACEHOLDER };
}

if (!this.config.host) return; // No API to call
if (this.hasInitialized) return; // We've already made an initial call

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const useCases = [
filter: '',
name: '',
},
'sum(system.cpu.user.pct)',
{
operation: 'sum',
operationWithField: 'sum(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
},
],
[
{
Expand All @@ -26,7 +30,11 @@ const useCases = [
filter: '',
name: '',
},
'max(system.cpu.user.pct)',
{
operation: 'max',
operationWithField: 'max(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
},
],
[
{
Expand All @@ -35,7 +43,11 @@ const useCases = [
filter: '',
name: '',
},
'min(system.cpu.user.pct)',
{
operation: 'min',
operationWithField: 'min(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
},
],
[
{
Expand All @@ -44,16 +56,24 @@ const useCases = [
filter: '',
name: '',
},
'average(system.cpu.user.pct)',
{
operation: 'average',
operationWithField: 'average(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
},
],
[
{
aggType: Aggregators.COUNT,
field: 'system.cpu.user.pct',
filter: '',
field: '',
filter: 'system.cpu.user.pct: *',
name: '',
},
'count(___records___)',
{
operation: 'count',
operationWithField: `count(kql='system.cpu.user.pct: *')`,
sourceField: '',
},
],
[
{
Expand All @@ -62,7 +82,11 @@ const useCases = [
filter: '',
name: '',
},
'unique_count(system.cpu.user.pct)',
{
operation: 'unique_count',
operationWithField: 'unique_count(system.cpu.user.pct)',
sourceField: 'system.cpu.user.pct',
},
],
[
{
Expand All @@ -71,7 +95,11 @@ const useCases = [
filter: '',
name: '',
},
'percentile(system.cpu.user.pct, percentile=95)',
{
operation: 'percentile',
operationWithField: 'percentile(system.cpu.user.pct, percentile=95)',
sourceField: 'system.cpu.user.pct',
},
],
[
{
Expand All @@ -80,7 +108,11 @@ const useCases = [
filter: '',
name: '',
},
'percentile(system.cpu.user.pct, percentile=99)',
{
operation: 'percentile',
operationWithField: 'percentile(system.cpu.user.pct, percentile=99)',
sourceField: 'system.cpu.user.pct',
},
],
[
{
Expand All @@ -89,7 +121,11 @@ const useCases = [
filter: '',
name: '',
},
`counter_rate(max(system.network.in.bytes), kql='')`,
{
operation: 'counter_rate',
operationWithField: `counter_rate(max(system.network.in.bytes), kql='')`,
sourceField: 'system.network.in.bytes',
},
],
[
{
Expand All @@ -98,7 +134,11 @@ const useCases = [
filter: 'host.name : "foo"',
name: '',
},
`counter_rate(max(system.network.in.bytes), kql='host.name : foo')`,
{
operation: 'counter_rate',
operationWithField: `counter_rate(max(system.network.in.bytes), kql='host.name : foo')`,
sourceField: 'system.network.in.bytes',
},
],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,35 @@
import { Aggregators } from '../../../common/custom_threshold_rule/types';
import { GenericMetric } from './rule_condition_chart';

export const getLensOperationFromRuleMetric = (metric: GenericMetric): string => {
export interface LensOperation {
operation: string;
operationWithField: string;
sourceField: string;
}

export const getLensOperationFromRuleMetric = (metric: GenericMetric): LensOperation => {
const { aggType, field, filter } = metric;
let operation: string = aggType;
const operationArgs: string[] = [];
const aggFilter = JSON.stringify(filter || '').replace(/"|\\/g, '');

if (aggType === Aggregators.RATE) {
return `counter_rate(max(${field}), kql='${aggFilter}')`;
return {
operation: 'counter_rate',
operationWithField: `counter_rate(max(${field}), kql='${aggFilter}')`,
sourceField: field || '',
};
}

if (aggType === Aggregators.AVERAGE) operation = 'average';
if (aggType === Aggregators.CARDINALITY) operation = 'unique_count';
if (aggType === Aggregators.P95 || aggType === Aggregators.P99) operation = 'percentile';
if (aggType === Aggregators.COUNT) operation = 'count';

let sourceField = field;

if (aggType === Aggregators.COUNT) {
sourceField = '___records___';
if (field) {
operationArgs.push(field);
}

operationArgs.push(sourceField || '');

if (aggType === Aggregators.P95) {
operationArgs.push('percentile=95');
}
Expand All @@ -41,7 +47,11 @@ export const getLensOperationFromRuleMetric = (metric: GenericMetric): string =>

if (aggFilter) operationArgs.push(`kql='${aggFilter}'`);

return operation + '(' + operationArgs.join(', ') + ')';
return {
operation,
operationWithField: `${operation}(${operationArgs.join(', ')})`,
sourceField: field || '',
};
};

export const getBufferThreshold = (threshold?: number): string =>
Expand Down
Loading

0 comments on commit 579a370

Please sign in to comment.