Skip to content

Commit

Permalink
Merge branch 'master' into ingest/edit-ds
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Apr 29, 2020
2 parents 13d2482 + 1106482 commit f2ae8ed
Show file tree
Hide file tree
Showing 13 changed files with 432 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ const getCurrentValueFromAggregations = (

const getParsedFilterQuery: (
filterQuery: string | undefined
) => Record<string, any> = filterQuery => {
) => Record<string, any> | Array<Record<string, any>> = filterQuery => {
if (!filterQuery) return {};
try {
return JSON.parse(filterQuery).bool;
} catch (e) {
return {
query_string: {
query: filterQuery,
analyze_wildcard: true,
return [
{
query_string: {
query: filterQuery,
analyze_wildcard: true,
},
},
};
];
}
};

Expand Down Expand Up @@ -159,8 +161,12 @@ export const getElasticsearchMetricQuery = (
return {
query: {
bool: {
filter: [...rangeFilters, ...metricFieldFilters],
...parsedFilterQuery,
filter: [
...rangeFilters,
...metricFieldFilters,
...(Array.isArray(parsedFilterQuery) ? parsedFilterQuery : []),
],
...(!Array.isArray(parsedFilterQuery) ? parsedFilterQuery : {}),
},
},
size: 0,
Expand Down Expand Up @@ -233,6 +239,7 @@ const getMetric: (
body: searchBody,
index,
});

return { '*': getCurrentValueFromAggregations(result.aggregations, aggType) };
} catch (e) {
return { '*': undefined }; // Trigger an Error state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const DEFAULT_AGENT_CONFIG = {
status: AgentConfigStatus.Active,
datasources: [],
is_default: true,
monitoring_enabled: ['logs', 'metrics'] as Array<'logs' | 'metrics'>,
};

export const DEFAULT_AGENT_CONFIGS_PACKAGES = [DefaultPackages.system];
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface NewAgentConfig {
namespace?: string;
description?: string;
is_default?: boolean;
monitoring_enabled?: Array<'logs' | 'metrics'>;
}

export interface AgentConfig extends NewAgentConfig {
Expand Down Expand Up @@ -58,4 +59,12 @@ export interface FullAgentConfig {
};
datasources: FullAgentConfigDatasource[];
revision?: number;
settings?: {
monitoring: {
use_output?: string;
enabled: boolean;
metrics: boolean;
logs: boolean;
};
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import {
EuiButtonEmpty,
EuiFlyout,
EuiFlyoutBody,
EuiFlyoutHeader,
EuiFlyoutFooter,
EuiLink,
EuiText,
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';

interface Props {
onClose: () => void;
}

export const AlphaFlyout: React.FunctionComponent<Props> = ({ onClose }) => {
return (
<EuiFlyout onClose={onClose} size="m" maxWidth={640}>
<EuiFlyoutHeader hasBorder aria-labelledby="AlphaMessagingFlyoutTitle">
<EuiTitle size="m">
<h2 id="AlphaMessagingFlyoutTitle">
<FormattedMessage
id="xpack.ingestManager.alphaMessaging.flyoutTitle"
defaultMessage="About this release"
/>
</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiText size="m">
<p>
<FormattedMessage
id="xpack.ingestManager.alphaMessaging.introText"
defaultMessage="This release is experimental and is not subject to the support SLA. It is designed for users to test and offer feedback about Ingest
Manager and the new Elastic Agent. It is not intended for use in production environments since certain features may change or go away in a future release."
/>
</p>
<FormattedMessage
id="xpack.ingestManager.alphaMessaging.feedbackText"
defaultMessage="We encourage you to read our {docsLink} or to ask questions and send feedback in our {forumLink}."
values={{
docsLink: (
<EuiLink href="https://ela.st/ingest-manager-docs" external target="_blank">
<FormattedMessage
id="xpack.ingestManager.alphaMessaging.docsLink"
defaultMessage="documentation"
/>
</EuiLink>
),
forumLink: (
<EuiLink href="https://ela.st/ingest-manager-forum" external target="_blank">
<FormattedMessage
id="xpack.ingestManager.alphaMessaging.forumLink"
defaultMessage="Discuss forum"
/>
</EuiLink>
),
}}
/>
<p />

<p>
<FormattedMessage
id="xpack.ingestManager.alphaMessaging.warningText"
defaultMessage="{note}: you should not store important data with Ingest Manager
since you will have limited visibility to it in a future release. This version uses an
indexing strategy that will be deprecated in a future release and there is no migration
path. Also, licensing for certain features is under consideration and may change in the future. As a result, you may lose access to certain features based on your license
tier."
values={{
note: (
<strong>
<FormattedMessage
id="xpack.ingestManager.alphaMessaging.warningNote"
defaultMessage="Note"
/>
</strong>
),
}}
/>
</p>
</EuiText>
</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiButtonEmpty iconType="cross" onClick={onClose} flush="left">
<FormattedMessage
id="xpack.ingestManager.alphaMessging.closeFlyoutLabel"
defaultMessage="Close"
/>
</EuiButtonEmpty>
</EuiFlyoutFooter>
</EuiFlyout>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,45 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import React, { useState } from 'react';
import styled from 'styled-components';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiText } from '@elastic/eui';
import { EuiText, EuiLink } from '@elastic/eui';
import { AlphaFlyout } from './alpha_flyout';

const Message = styled(EuiText).attrs(props => ({
color: 'subdued',
textAlign: 'center',
size: 's',
}))`
padding: ${props => props.theme.eui.paddingSizes.m};
`;

export const AlphaMessaging: React.FC<{}> = () => (
<Message>
<p>
<small>
<strong>
export const AlphaMessaging: React.FC<{}> = () => {
const [isAlphaFlyoutOpen, setIsAlphaFlyoutOpen] = useState<boolean>(false);

return (
<>
<Message>
<p>
<strong>
<FormattedMessage
id="xpack.ingestManager.alphaMessageTitle"
defaultMessage="Experimental"
/>
</strong>
{' – '}
<FormattedMessage
id="xpack.ingestManager.alphaMessageTitle"
defaultMessage="Alpha release"
/>
</strong>
{' – '}
<FormattedMessage
id="xpack.ingestManager.alphaMessageDescription"
defaultMessage="Ingest Manager is under active development and is not
id="xpack.ingestManager.alphaMessageDescription"
defaultMessage="Ingest Manager is under active development and is not
intended for production purposes."
/>
</small>
</p>
</Message>
);
/>{' '}
<EuiLink color="subdued" onClick={() => setIsAlphaFlyoutOpen(true)}>
View more details.
</EuiLink>
</p>
</Message>
{isAlphaFlyoutOpen && <AlphaFlyout onClose={() => setIsAlphaFlyoutOpen(false)} />}
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
EuiText,
EuiComboBox,
EuiIconTip,
EuiCheckboxGroup,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
Expand All @@ -30,7 +31,7 @@ interface ValidationResults {

const StyledEuiAccordion = styled(EuiAccordion)`
.ingest-active-button {
color: ${props => props.theme.eui.euiColorPrimary}};
color: ${props => props.theme.eui.euiColorPrimary};
}
`;

Expand Down Expand Up @@ -244,6 +245,68 @@ export const AgentConfigForm: React.FunctionComponent<Props> = ({
)}
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />
<EuiFlexGroup>
<EuiFlexItem>
<EuiText>
<h4>
<FormattedMessage
id="xpack.ingestManager.agentConfigForm.monitoringLabel"
defaultMessage="Agent monitoring"
/>
</h4>
</EuiText>
<EuiSpacer size="m" />
<EuiText size="s">
<FormattedMessage
id="xpack.ingestManager.agentConfigForm.monitoringDescription"
defaultMessage="Collect data about your agents for debugging and tracking performance."
/>
</EuiText>
</EuiFlexItem>
<EuiFlexItem>
<EuiCheckboxGroup
options={[
{
id: 'logs',
label: i18n.translate(
'xpack.ingestManager.agentConfigForm.monitoringLogsFieldLabel',
{ defaultMessage: 'Collect agent logs' }
),
},
{
id: 'metrics',
label: i18n.translate(
'xpack.ingestManager.agentConfigForm.monitoringMetricsFieldLabel',
{ defaultMessage: 'Collect agent metrics' }
),
},
]}
idToSelectedMap={(agentConfig.monitoring_enabled || []).reduce(
(acc: { logs: boolean; metrics: boolean }, key) => {
acc[key] = true;
return acc;
},
{ logs: false, metrics: false }
)}
onChange={id => {
if (id !== 'logs' && id !== 'metrics') {
return;
}

const hasLogs =
agentConfig.monitoring_enabled && agentConfig.monitoring_enabled.indexOf(id) >= 0;

const previousValues = agentConfig.monitoring_enabled || [];
updateAgentConfig({
monitoring_enabled: hasLogs
? previousValues.filter(type => type !== id)
: [...previousValues, id],
});
}}
/>
</EuiFlexItem>
</EuiFlexGroup>
</StyledEuiAccordion>
</EuiForm>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const CreateAgentConfigFlyout: React.FunctionComponent<Props> = ({ onClos
description: '',
namespace: '',
is_default: undefined,
monitoring_enabled: ['logs', 'metrics'],
});
const [isLoading, setIsLoading] = useState<boolean>(false);
const [withSysMonitoring, setWithSysMonitoring] = useState<boolean>(true);
Expand Down
Loading

0 comments on commit f2ae8ed

Please sign in to comment.