Skip to content

Commit

Permalink
Merge branch 'master' into ingest/fix/asset-links
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 17, 2020
2 parents e76a20a + 5cd1f6e commit 21c5326
Show file tree
Hide file tree
Showing 47 changed files with 349 additions and 204 deletions.
4 changes: 2 additions & 2 deletions .ci/Jenkinsfile_baseline_capture
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ kibanaPipeline(timeoutMinutes: 120) {
catchError {
parallel([
'oss-visualRegression': {
workers.ci(name: 'oss-visualRegression', size: 's', ramDisk: false) {
workers.ci(name: 'oss-visualRegression', size: 's-highmem', ramDisk: true) {
kibanaPipeline.functionalTestProcess('oss-visualRegression', './test/scripts/jenkins_visual_regression.sh')(1)
}
},
'xpack-visualRegression': {
workers.ci(name: 'xpack-visualRegression', size: 's', ramDisk: false) {
workers.ci(name: 'xpack-visualRegression', size: 's-highmem', ramDisk: true) {
kibanaPipeline.functionalTestProcess('xpack-visualRegression', './test/scripts/jenkins_xpack_visual_regression.sh')(1)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { get } from 'lodash';
import { i18n } from '@kbn/i18n';
import { VisResponseValue, PersistedState } from '../../../../plugins/visualizations/public';
import { ExpressionFunctionDefinition, Render } from '../../../../plugins/expressions/public';
import { getTypes, getIndexPatterns, getFilterManager } from '../services';
import { getTypes, getIndexPatterns, getFilterManager, getSearch } from '../services';

interface Arguments {
index?: string | null;
Expand All @@ -31,6 +31,7 @@ interface Arguments {
schemas?: string;
visConfig?: string;
uiState?: string;
aggConfigs?: string;
}

export type ExpressionFunctionVisualization = ExpressionFunctionDefinition<
Expand Down Expand Up @@ -84,6 +85,11 @@ export const visualization = (): ExpressionFunctionVisualization => ({
default: '"{}"',
help: 'User interface state',
},
aggConfigs: {
types: ['string'],
default: '"{}"',
help: 'Aggregation configurations',
},
},
async fn(input, args, { inspectorAdapters }) {
const visConfigParams = args.visConfig ? JSON.parse(args.visConfig) : {};
Expand All @@ -94,6 +100,11 @@ export const visualization = (): ExpressionFunctionVisualization => ({
const uiStateParams = args.uiState ? JSON.parse(args.uiState) : {};
const uiState = new PersistedState(uiStateParams);

const aggConfigsState = args.aggConfigs ? JSON.parse(args.aggConfigs) : [];
const aggs = indexPattern
? getSearch().aggs.createAggConfigs(indexPattern, aggConfigsState)
: undefined;

if (typeof visType.requestHandler === 'function') {
input = await visType.requestHandler({
partialRows: args.partialRows,
Expand All @@ -107,6 +118,7 @@ export const visualization = (): ExpressionFunctionVisualization => ({
inspectorAdapters,
queryFilter: getFilterManager(),
forceFetch: true,
aggs,
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/plugins/visualizations/public/legacy/build_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,10 @@ export const buildPipeline = async (
metricsAtAllLevels=${vis.isHierarchical()}
partialRows=${vis.type.requiresPartialRows || vis.params.showPartialRows || false} `;
if (indexPattern) {
pipeline += `${prepareString('index', indexPattern.id)}`;
pipeline += `${prepareString('index', indexPattern.id)} `;
if (vis.data.aggs) {
pipeline += `${prepareJson('aggConfigs', vis.data.aggs!.aggs)}`;
}
}
}

Expand Down
20 changes: 12 additions & 8 deletions x-pack/plugins/ingest_manager/common/services/agent_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import {
AGENT_POLLING_THRESHOLD_MS,
AGENT_TYPE_PERMANENT,
AGENT_SAVED_OBJECT_TYPE,
} from '../constants';
import { AGENT_POLLING_THRESHOLD_MS, AGENT_SAVED_OBJECT_TYPE } from '../constants';
import { Agent, AgentStatus } from '../types';

export function getAgentStatus(agent: Agent, now: number = Date.now()): AgentStatus {
Expand Down Expand Up @@ -41,16 +37,24 @@ export function getAgentStatus(agent: Agent, now: number = Date.now()): AgentSta
return 'online';
}

export function buildKueryForEnrollingAgents() {
return `not ${AGENT_SAVED_OBJECT_TYPE}.last_checkin:*`;
}

export function buildKueryForUnenrollingAgents() {
return `${AGENT_SAVED_OBJECT_TYPE}.unenrollment_started_at:*`;
}

export function buildKueryForOnlineAgents() {
return `not (${buildKueryForOfflineAgents()}) AND not (${buildKueryForErrorAgents()})`;
return `not (${buildKueryForOfflineAgents()}) AND not (${buildKueryForErrorAgents()}) AND not (${buildKueryForEnrollingAgents()}) AND not (${buildKueryForUnenrollingAgents()})`;
}

export function buildKueryForErrorAgents() {
return `( ${AGENT_SAVED_OBJECT_TYPE}.last_checkin_status:error or ${AGENT_SAVED_OBJECT_TYPE}.last_checkin_status:degraded )`;
}

export function buildKueryForOfflineAgents() {
return `((${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_PERMANENT} AND ${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${
return `${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${
(4 * AGENT_POLLING_THRESHOLD_MS) / 1000
}s) AND not ( ${buildKueryForErrorAgents()} ))`;
}s AND not (${buildKueryForErrorAgents()})`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,6 @@ export interface GetAgentStatusResponse {
online: number;
error: number;
offline: number;
other: number;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const DonutChart = ({ height, width, data }: DonutChartProps) => {
.ordinal()
// @ts-ignore
.domain(data)
.range(['#017D73', '#98A2B3', '#BD271E']);
.range(['#017D73', '#98A2B3', '#BD271E', '#F5A700']);
const pieGenerator = d3.layout
.pie()
.value(({ value }: any) => value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const ListLayout: React.FunctionComponent<{}> = ({ children }) => {
online: agentStatus?.online || 0,
offline: agentStatus?.offline || 0,
error: agentStatus?.error || 0,
other: agentStatus?.other || 0,
}}
/>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ export async function getAgentStatusForConfig(
soClient: SavedObjectsClientContract,
configId?: string
) {
const [all, error, offline] = await Promise.all(
const [all, online, error, offline] = await Promise.all(
[
undefined,
AgentStatusKueryHelper.buildKueryForOnlineAgents(),
AgentStatusKueryHelper.buildKueryForErrorAgents(),
AgentStatusKueryHelper.buildKueryForOfflineAgents(),
].map((kuery) =>
Expand All @@ -47,9 +48,10 @@ export async function getAgentStatusForConfig(
return {
events: await getEventsCount(soClient, configId),
total: all.total,
online: all.total - error.total - offline.total,
online: online.total,
error: error.total,
offline: offline.total,
other: all.total - online.total - error.total - offline.total,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getExceptionListItemSchemaMock = (): ExceptionListItemSchema => ({
entries: ENTRIES,
id: '1',
item_id: 'endpoint_list_item',
list_id: 'endpoint_list',
list_id: 'endpoint_list_id',
meta: {},
name: 'Sample Endpoint Exception List',
namespace_type: 'single',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { ENDPOINT_LIST_ID } from '../..';

import { ExceptionListSchema } from './exception_list_schema';

export const getExceptionListSchemaMock = (): ExceptionListSchema => ({
Expand All @@ -12,10 +14,10 @@ export const getExceptionListSchemaMock = (): ExceptionListSchema => ({
created_by: 'user_name',
description: 'This is a sample endpoint type exception',
id: '1',
list_id: 'endpoint_list',
list_id: ENDPOINT_LIST_ID,
meta: {},
name: 'Sample Endpoint Exception List',
namespace_type: 'single',
namespace_type: 'agnostic',
tags: ['user added string for a tag', 'malware'],
tie_breaker_id: '77fd1909-6786-428a-a671-30229a719c1f',
type: 'endpoint',
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lists/public/exceptions/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ describe('Exceptions Lists API', () => {
test('it returns expected format when call succeeds', async () => {
const exceptionResponse = await fetchExceptionListItemsByListId({
http: mockKibanaHttpService(),
listId: 'endpoint_list',
listId: 'endpoint_list_id',
namespaceType: 'single',
pagination: {
page: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { EuiFieldText, EuiFormRow, EuiPanel } from '@elastic/eui';

Expand All @@ -13,10 +13,12 @@ import { i18n } from '@kbn/i18n';

export function CreateSourceEditor({ onSourceConfigChange }) {
const tilemap = getKibanaTileMap();

if (tilemap.url) {
onSourceConfigChange();
}
useEffect(() => {
if (tilemap.url) {
onSourceConfigChange();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<EuiPanel>
Expand All @@ -33,7 +35,7 @@ export function CreateSourceEditor({ onSourceConfigChange }) {
})
}
>
<EuiFieldText readOnly value={tilemap.url} />
<EuiFieldText readOnly value={tilemap.url ? tilemap.url : ''} />
</EuiFormRow>
</EuiPanel>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from 'react';
import { MapsAppView } from '.';
import { getMapsSavedObjectLoader } from '../../bootstrap/services/gis_map_saved_object_loader';
import { getToasts } from '../../../kibana_services';
import { getCoreChrome, getToasts } from '../../../kibana_services';
import { i18n } from '@kbn/i18n';
import { Redirect } from 'react-router-dom';

Expand All @@ -30,6 +30,10 @@ export const LoadMapAndRender = class extends React.Component {
try {
const savedMap = await getMapsSavedObjectLoader().get(this.props.savedMapId);
if (this._isMounted) {
getCoreChrome().docTitle.change(savedMap.title);
if (this.props.savedMapId) {
getCoreChrome().recentlyAccessed.add(savedMap.getFullPath(), savedMap.title, savedMap.id);
}
this.setState({ savedMap });
}
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ export class MapsAppView extends React.Component {
}

componentDidMount() {
const { savedMap } = this.props;

getCoreChrome().docTitle.change(savedMap.title);
getCoreChrome().recentlyAccessed.add(savedMap.getFullPath(), savedMap.title, savedMap.id);

// Init sync utils
// eslint-disable-next-line react-hooks/rules-of-hooks
this._globalSyncUnsubscribe = useGlobalStateSyncing();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { EntriesArray } from '../shared_imports';
import { RuleType } from './types';

export const hasLargeValueList = (entries: EntriesArray): boolean => {
const found = entries.filter(({ type }) => type === 'list');
Expand All @@ -15,3 +16,5 @@ export const hasNestedEntry = (entries: EntriesArray): boolean => {
const found = entries.filter(({ type }) => type === 'nested');
return found.length > 0;
};

export const isThresholdRule = (ruleType: RuleType) => ruleType === 'threshold';
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {
} from '../../../../../public/lists_plugin_deps';
import * as i18n from './translations';
import { TimelineNonEcsData, Ecs } from '../../../../graphql/types';
import { useAppToasts } from '../../../hooks/use_app_toasts';
import { useKibana } from '../../../lib/kibana';
import { errorToToaster, displaySuccessToast, useStateToaster } from '../../toasters';
import { ExceptionBuilder } from '../builder';
import { Loader } from '../../loader';
import { useAddOrUpdateException } from '../use_add_exception';
Expand Down Expand Up @@ -115,7 +115,7 @@ export const AddExceptionModal = memo(function AddExceptionModal({
Array<ExceptionListItemSchema | CreateExceptionListItemSchema>
>([]);
const [fetchOrCreateListError, setFetchOrCreateListError] = useState(false);
const [, dispatchToaster] = useStateToaster();
const { addError, addSuccess } = useAppToasts();
const { loading: isSignalIndexLoading, signalIndexName } = useSignalIndex();

const [{ isLoading: indexPatternLoading, indexPatterns }] = useFetchIndexPatterns(
Expand All @@ -124,15 +124,15 @@ export const AddExceptionModal = memo(function AddExceptionModal({

const onError = useCallback(
(error: Error) => {
errorToToaster({ title: i18n.ADD_EXCEPTION_ERROR, error, dispatchToaster });
addError(error, { title: i18n.ADD_EXCEPTION_ERROR });
onCancel();
},
[dispatchToaster, onCancel]
[addError, onCancel]
);
const onSuccess = useCallback(() => {
displaySuccessToast(i18n.ADD_EXCEPTION_SUCCESS, dispatchToaster);
addSuccess(i18n.ADD_EXCEPTION_SUCCESS);
onConfirm(shouldCloseAlert);
}, [dispatchToaster, onConfirm, shouldCloseAlert]);
}, [addSuccess, onConfirm, shouldCloseAlert]);

const [{ isLoading: addExceptionIsLoading }, addOrUpdateExceptionItems] = useAddOrUpdateException(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from '../../../../../public/lists_plugin_deps';
import * as i18n from './translations';
import { useKibana } from '../../../lib/kibana';
import { errorToToaster, displaySuccessToast, useStateToaster } from '../../toasters';
import { useAppToasts } from '../../../hooks/use_app_toasts';
import { ExceptionBuilder } from '../builder';
import { useAddOrUpdateException } from '../use_add_exception';
import { AddExceptionComments } from '../add_exception_comments';
Expand Down Expand Up @@ -93,7 +93,7 @@ export const EditExceptionModal = memo(function EditExceptionModal({
const [exceptionItemsToAdd, setExceptionItemsToAdd] = useState<
Array<ExceptionListItemSchema | CreateExceptionListItemSchema>
>([]);
const [, dispatchToaster] = useStateToaster();
const { addError, addSuccess } = useAppToasts();
const { loading: isSignalIndexLoading, signalIndexName } = useSignalIndex();

const [{ isLoading: indexPatternLoading, indexPatterns }] = useFetchIndexPatterns(
Expand All @@ -102,15 +102,15 @@ export const EditExceptionModal = memo(function EditExceptionModal({

const onError = useCallback(
(error) => {
errorToToaster({ title: i18n.EDIT_EXCEPTION_ERROR, error, dispatchToaster });
addError(error, { title: i18n.EDIT_EXCEPTION_ERROR });
onCancel();
},
[dispatchToaster, onCancel]
[addError, onCancel]
);
const onSuccess = useCallback(() => {
displaySuccessToast(i18n.EDIT_EXCEPTION_SUCCESS, dispatchToaster);
addSuccess(i18n.EDIT_EXCEPTION_SUCCESS);
onConfirm();
}, [dispatchToaster, onConfirm]);
}, [addSuccess, onConfirm]);

const [{ isLoading: addExceptionIsLoading }, addOrUpdateExceptionItems] = useAddOrUpdateException(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { ExceptionItem } from './';
import { getExceptionListItemSchemaMock } from '../../../../../../../lists/common/schemas/response/exception_list_item_schema.mock';
import { getCommentsArrayMock } from '../../../../../../../lists/common/schemas/types/comments.mock';

jest.mock('../../../../lib/kibana');

describe('ExceptionItem', () => {
it('it renders ExceptionDetails and ExceptionEntries', () => {
const exceptionItem = getExceptionListItemSchemaMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { isError } from 'lodash/fp';

import { AppToast, ActionToaster } from './';
import { isToasterError } from './errors';
import { isApiError } from '../../utils/api';
import { isAppError } from '../../utils/api';

/**
* Displays an error toast for the provided title and message
Expand Down Expand Up @@ -114,7 +114,7 @@ export const errorToToaster = ({
iconType,
errors: error.messages,
};
} else if (isApiError(error)) {
} else if (isAppError(error)) {
toast = {
id,
title,
Expand Down
Loading

0 comments on commit 21c5326

Please sign in to comment.