Skip to content

Commit

Permalink
Merge branch 'master' into feat/row-renderers-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 9, 2020
2 parents 728c43c + 8ef9833 commit e2b9e4d
Show file tree
Hide file tree
Showing 95 changed files with 2,195 additions and 2,206 deletions.
4 changes: 2 additions & 2 deletions docs/user/alerting/action-types/pagerduty.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ Then, select the *Integrations* tab and click the *New Integration* button.
* If you are creating a new service for your integration,
go to
https://support.pagerduty.com/docs/services-and-integrations#section-configuring-services-and-integrations[Configuring Services and Integrations]
and follow the steps outlined in the *Create a New Service* section, selecting *Elastic* as the *Integration Type* in step 4.
and follow the steps outlined in the *Create a New Service* section, selecting *Elastic Alerts* as the *Integration Type* in step 4.
Continue with the <<pagerduty-in-elastic, In Elastic>> section once you have finished these steps.

. Enter an *Integration Name* in the format Elastic-service-name (for example, Elastic-Alerting or Kibana-APM-Alerting)
and select Elastic from the *Integration Type* menu.
and select *Elastic Alerts* from the *Integration Type* menu.
. Click *Add Integration* to save your new integration.
+
You will be redirected to the *Integrations* tab for your service. An Integration Key is generated on this screen.
Expand Down
3 changes: 2 additions & 1 deletion test/functional/apps/discover/_doc_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const retry = getService('retry');

describe('doc link in discover', function contextSize() {
// Flaky: https://github.com/elastic/kibana/issues/71216
describe.skip('doc link in discover', function contextSize() {
beforeEach(async function () {
log.debug('load kibana index with default index pattern');
await esArchiver.loadIfNeeded('discover');
Expand Down
5 changes: 2 additions & 3 deletions test/functional/apps/visualize/_data_table_nontimeindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ export default function ({ getService, getPageObjects }) {
expect(data.trim().split('\n')).to.be.eql(['14,004 1,412.6']);
});

// bug https://github.com/elastic/kibana/issues/68977
describe.skip('data table with date histogram', async () => {
describe('data table with date histogram', async () => {
before(async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickDataTable();
Expand All @@ -123,7 +122,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visEditor.clickBucket('Split rows');
await PageObjects.visEditor.selectAggregation('Date Histogram');
await PageObjects.visEditor.selectField('@timestamp');
await PageObjects.visEditor.setInterval('Daily');
await PageObjects.visEditor.setInterval('Day');
await PageObjects.visEditor.clickGo();
});

Expand Down
10 changes: 6 additions & 4 deletions test/functional/page_objects/management/saved_objects_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ export function SavedObjectsPageProvider({ getService, getPageObjects }: FtrProv

async waitTableIsLoaded() {
return retry.try(async () => {
const exists = await find.existsByDisplayedByCssSelector(
'*[data-test-subj="savedObjectsTable"] .euiBasicTable-loading'
const isLoaded = await find.existsByDisplayedByCssSelector(
'*[data-test-subj="savedObjectsTable"] :not(.euiBasicTable-loading)'
);
if (exists) {

if (isLoaded) {
return true;
} else {
throw new Error('Waiting');
}
return true;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class PolicyTable extends Component {
icon: 'list',
onClick: () => {
this.props.navigateToApp('management', {
path: `/data/index_management${getIndexListUri(`ilm.policy:${policy.name}`)}`,
path: `/data/index_management${getIndexListUri(`ilm.policy:${policy.name}`, true)}`,
});
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export const services = {
services.uiMetricService.setup({ reportUiStats() {} } as any);
setExtensionsService(services.extensionsService);
setUiMetricService(services.uiMetricService);
const appDependencies = { services, core: { getUrlForApp: () => {} }, plugins: {} } as any;
const appDependencies = {
services,
core: { getUrlForApp: () => {} },
plugins: {},
} as any;

export const setupEnvironment = () => {
// Mock initialization of services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export const IndexManagementHome: React.FunctionComponent<RouteComponentProps<Ma
component={DataStreamList}
/>
<Route exact path={`/${Section.Indices}`} component={IndexList} />
<Route exact path={`/${Section.Indices}/filter/:filter?`} component={IndexList} />
<Route
exact
path={[`/${Section.IndexTemplates}`, `/${Section.IndexTemplates}/:templateName?`]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const HEADERS = {

export class IndexTable extends Component {
static getDerivedStateFromProps(props, state) {
// Deselct any indices which no longer exist, e.g. they've been deleted.
// Deselect any indices which no longer exist, e.g. they've been deleted.
const { selectedIndicesMap } = state;
const indexNames = props.indices.map((index) => index.name);
const selectedIndexNames = Object.keys(selectedIndicesMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import {
EuiFlexItem,
EuiCodeBlock,
} from '@elastic/eui';
import { useAppContext } from '../../../../../app_context';
import { TemplateDeserialized } from '../../../../../../../common';
import { getILMPolicyPath } from '../../../../../services/navigation';
import { getILMPolicyPath } from '../../../../../services/routing';

interface Props {
templateDetails: TemplateDeserialized;
Expand Down Expand Up @@ -51,6 +52,10 @@ export const TabSummary: React.FunctionComponent<Props> = ({ templateDetails })

const numIndexPatterns = indexPatterns.length;

const {
core: { getUrlForApp },
} = useAppContext();

return (
<EuiFlexGroup data-test-subj="summaryTab">
<EuiFlexItem>
Expand Down Expand Up @@ -153,7 +158,13 @@ export const TabSummary: React.FunctionComponent<Props> = ({ templateDetails })
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{ilmPolicy && ilmPolicy.name ? (
<EuiLink href={getILMPolicyPath(ilmPolicy.name)}>{ilmPolicy.name}</EuiLink>
<EuiLink
href={getUrlForApp('management', {
path: getILMPolicyPath(ilmPolicy.name),
})}
>
{ilmPolicy.name}
</EuiLink>
) : (
i18nTexts.none
)}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ export const getTemplateCloneLink = (name: string, isLegacy?: boolean) => {
return encodeURI(url);
};

export const getILMPolicyPath = (policyName: string) => {
return encodeURI(
`/data/index_lifecycle_management/policies/edit/${encodeURIComponent(policyName)}`
);
};

export const getIndexListUri = (filter?: string, includeHiddenIndices?: boolean) => {
const hiddenIndicesParam =
typeof includeHiddenIndices !== 'undefined' ? includeHiddenIndices : false;
if (filter) {
// React router tries to decode url params but it can't because the browser partially
// decodes them. So we have to encode both the URL and the filter to get it all to
// work correctly for filters with URL unsafe characters in them.
return encodeURI(
`/indices?includeHiddenIndices=${hiddenIndicesParam}&filter=${encodeURIComponent(filter)}`
);
}

// If no filter, URI is already safe so no need to encode.
return '/indices';
};

export const decodePathFromReactRouter = (pathname: string): string => {
let decodedPath;
try {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/index_management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export const plugin = () => {

export { IndexManagementPluginSetup };

export { getIndexListUri } from './application/services/navigation';
export { getIndexListUri } from './application/services/routing';
57 changes: 23 additions & 34 deletions x-pack/plugins/ingest_manager/common/services/agent_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,52 @@
*/

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

export function getAgentStatus(agent: Agent, now: number = Date.now()): AgentStatus {
const { type, last_checkin: lastCheckIn } = agent;
const msLastCheckIn = new Date(lastCheckIn || 0).getTime();
const msSinceLastCheckIn = new Date().getTime() - msLastCheckIn;
const intervalsSinceLastCheckIn = Math.floor(msSinceLastCheckIn / AGENT_POLLING_THRESHOLD_MS);
const { last_checkin: lastCheckIn } = agent;

if (!agent.active) {
return 'inactive';
}
if (!agent.last_checkin) {
return 'enrolling';
}
if (agent.unenrollment_started_at && !agent.unenrolled_at) {
return 'unenrolling';
}
if (agent.current_error_events.length > 0) {

const msLastCheckIn = new Date(lastCheckIn || 0).getTime();
const msSinceLastCheckIn = new Date().getTime() - msLastCheckIn;
const intervalsSinceLastCheckIn = Math.floor(msSinceLastCheckIn / AGENT_POLLING_THRESHOLD_MS);

if (agent.last_checkin_status === 'error') {
return 'error';
}
switch (type) {
case AGENT_TYPE_PERMANENT:
if (intervalsSinceLastCheckIn >= 4) {
return 'error';
}
case AGENT_TYPE_TEMPORARY:
if (intervalsSinceLastCheckIn >= 3) {
return 'offline';
}
case AGENT_TYPE_EPHEMERAL:
if (intervalsSinceLastCheckIn >= 3) {
return 'inactive';
}
if (agent.last_checkin_status === 'degraded') {
return 'degraded';
}
if (intervalsSinceLastCheckIn >= 4) {
return 'offline';
}

return 'online';
}

export function buildKueryForOnlineAgents() {
return `(${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_PERMANENT} and ${AGENT_SAVED_OBJECT_TYPE}.last_checkin >= now-${
(4 * AGENT_POLLING_THRESHOLD_MS) / 1000
}s) or (${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_TEMPORARY} and ${AGENT_SAVED_OBJECT_TYPE}.last_checkin >= now-${
(3 * AGENT_POLLING_THRESHOLD_MS) / 1000
}s) or (${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_EPHEMERAL} and ${AGENT_SAVED_OBJECT_TYPE}.last_checkin >= now-${
(3 * AGENT_POLLING_THRESHOLD_MS) / 1000
}s)`;
return `not (${buildKueryForOfflineAgents()}) AND not (${buildKueryForErrorAgents()})`;
}

export function buildKueryForOfflineAgents() {
return `${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_TEMPORARY} AND ${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${
(3 * AGENT_POLLING_THRESHOLD_MS) / 1000
}s`;
export function buildKueryForErrorAgents() {
return `( ${AGENT_SAVED_OBJECT_TYPE}.last_checkin_status:error or ${AGENT_SAVED_OBJECT_TYPE}.last_checkin_status:degraded )`;
}

export function buildKueryForErrorAgents() {
return `${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_PERMANENT} AND ${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${
export function buildKueryForOfflineAgents() {
return `((${AGENT_SAVED_OBJECT_TYPE}.type:${AGENT_TYPE_PERMANENT} AND ${AGENT_SAVED_OBJECT_TYPE}.last_checkin < now-${
(4 * AGENT_POLLING_THRESHOLD_MS) / 1000
}s`;
}s) AND not ( ${buildKueryForErrorAgents()} ))`;
}
12 changes: 11 additions & 1 deletion x-pack/plugins/ingest_manager/common/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ export type AgentType =
| typeof AGENT_TYPE_PERMANENT
| typeof AGENT_TYPE_TEMPORARY;

export type AgentStatus = 'offline' | 'error' | 'online' | 'inactive' | 'warning' | 'unenrolling';
export type AgentStatus =
| 'offline'
| 'error'
| 'online'
| 'inactive'
| 'warning'
| 'enrolling'
| 'unenrolling'
| 'degraded';

export type AgentActionType = 'CONFIG_CHANGE' | 'DATA_DUMP' | 'RESUME' | 'PAUSE' | 'UNENROLL';
export interface NewAgentAction {
type: AgentActionType;
Expand Down Expand Up @@ -82,6 +91,7 @@ interface AgentBase {
config_id?: string;
config_revision?: number | null;
last_checkin?: string;
last_checkin_status?: 'error' | 'online' | 'degraded';
user_provided_metadata: AgentMetadata;
local_metadata: AgentMetadata;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface PostAgentCheckinRequest {
agentId: string;
};
body: {
status?: 'online' | 'error' | 'degraded';
local_metadata?: Record<string, any>;
events?: NewAgentEvent[];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
}

if (selectedStatus.length) {
if (kuery) {
kuery = `(${kuery}) and`;
}

kuery = selectedStatus
const kueryStatus = selectedStatus
.map((status) => {
switch (status) {
case 'online':
Expand All @@ -196,6 +192,12 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
return '';
})
.join(' or ');

if (kuery) {
kuery = `(${kuery}) and ${kueryStatus}`;
} else {
kuery = kueryStatus;
}
}

const agentsRequest = useGetAgents(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ const Status = {
/>
</EuiHealth>
),
Degraded: (
<EuiHealth color="danger">
<FormattedMessage
id="xpack.ingestManager.agentHealth.degradedStatusText"
defaultMessage="Degraded"
/>
</EuiHealth>
),
Enrolling: (
<EuiHealth color="warning">
<FormattedMessage
id="xpack.ingestManager.agentHealth.enrollingStatusText"
defaultMessage="Enrolling"
/>
</EuiHealth>
),
Unenrolling: (
<EuiHealth color="warning">
<FormattedMessage
Expand All @@ -67,6 +83,8 @@ function getStatusComponent(agent: Agent): React.ReactElement {
switch (agent.status) {
case 'error':
return Status.Error;
case 'degraded':
return Status.Degraded;
case 'inactive':
return Status.Inactive;
case 'offline':
Expand All @@ -75,6 +93,8 @@ function getStatusComponent(agent: Agent): React.ReactElement {
return Status.Warning;
case 'unenrolling':
return Status.Unenrolling;
case 'enrolling':
return Status.Enrolling;
default:
return Status.Online;
}
Expand Down
7 changes: 5 additions & 2 deletions x-pack/plugins/ingest_manager/server/routes/agent/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@ export const postAgentCheckinHandler: RequestHandler<
const { actions } = await AgentService.agentCheckin(
soClient,
agent,
request.body.events || [],
request.body.local_metadata,
{
events: request.body.events || [],
localMetadata: request.body.local_metadata,
status: request.body.status,
},
{ signal }
);
const body: PostAgentCheckinResponse = {
Expand Down
Loading

0 comments on commit e2b9e4d

Please sign in to comment.