Skip to content

Commit

Permalink
Merge branch 'master' into jest-build
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 10, 2020
2 parents 0de33f3 + 0ed7176 commit 53aeb70
Show file tree
Hide file tree
Showing 55 changed files with 1,173 additions and 1,724 deletions.
14 changes: 7 additions & 7 deletions docs/apm/advanced-queries.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ TIP: Read the {kibana-ref}/kuery-query.html[Kibana Query Language Enhancements]

[float]
[[discover-advanced-queries]]
=== Querying in the Discover app
=== Querying in Discover

It may also be helpful to view your APM data in the {kibana-ref}/discover.html[Discover app].
Querying documents in Discover works the same way as querying in the APM app,
and all of the example APM app queries can also be used in the Discover app.
It may also be helpful to view your APM data in {kibana-ref}/discover.html[*Discover*].
Querying documents in *Discover* works the same way as querying in the APM app,
and all of the example APM app queries can also be used in *Discover*.

[float]
==== Example Discover app query
==== Example Discover query

One example where you may want to make use of the Discover app,
One example where you may want to make use of *Discover*,
is for viewing _all_ transactions for an endpoint, instead of just a sample.

TIP: Starting in v7.6, you can view 10 samples per bucket in the APM app, instead of just one.

Use the APM app to find a transaction name and time bucket that you're interested in learning more about.
Then, switch to the Discover app and make a search:
Then, switch to *Discover* and make a search:

["source","sh"]
-----
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/tutorial-discovering.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[tutorial-discovering]]
=== Discover your data

Using the Discover application, you can enter
Using *Discover*, you can enter
an {ref}/query-dsl-query-string-query.html#query-string-syntax[Elasticsearch
query] to search your data and filter the results.

Expand All @@ -12,7 +12,7 @@ You might need to click *New* in the menu bar to refresh the data.

. Click the caret to the right of the current index pattern, and select `ba*`.
+
By default, all fields are shown for each matching document.
By default, all fields are shown for each matching document.

. In the search field, enter the following string:
+
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export {
isStringType,
isType,
isValidInterval,
isValidJson,
METRIC_TYPES,
OptionedParamType,
parentPipelineType,
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/data/public/search/aggs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export { toAbsoluteDates } from './buckets/lib/date_utils';
export { convertIPRangeToString } from './buckets/ip_range';
export { aggTypeFilters, propFilter } from './filter';
export { OptionedParamType } from './param_types/optioned';
export { isValidJson, isValidInterval } from './utils';
export { isValidInterval } from './utils';
export { BUCKET_TYPES } from './buckets/bucket_agg_types';
export { METRIC_TYPES } from './metrics/metric_agg_types';

Expand Down
49 changes: 0 additions & 49 deletions src/legacy/core_plugins/data/public/search/aggs/utils.test.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions src/legacy/core_plugins/data/public/search/aggs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,6 @@
import { leastCommonInterval } from 'ui/vis/lib/least_common_interval';
import { isValidEsInterval } from '../../../common';

/**
* Check a string if it's a valid JSON.
*
* @param {string} value a string that should be validated
* @returns {boolean} true if value is a valid JSON or if value is an empty string, or a string with whitespaces, otherwise false
*/
export function isValidJson(value: string): boolean {
if (!value || value.length === 0) {
return true;
}

const trimmedValue = value.trim();

if (trimmedValue.length === 0) {
return true;
}

if (trimmedValue[0] === '{' || trimmedValue[0] === '[') {
try {
JSON.parse(trimmedValue);
return true;
} catch (e) {
return false;
}
} else {
return false;
}
}

export function isValidInterval(value: string, baseInterval?: string) {
if (baseInterval) {
return _parseWithBase(value, baseInterval);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,65 +17,91 @@
* under the License.
*/

import React, { useEffect } from 'react';
import React, { useState, useMemo, useCallback } from 'react';

import { EuiFormRow, EuiIconTip, EuiTextArea } from '@elastic/eui';
import { EuiFormRow, EuiIconTip, EuiCodeEditor, EuiScreenReaderOnly } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

import { isValidJson } from '../../legacy_imports';
import { AggParamEditorProps } from '../agg_param_props';

function RawJsonParamEditor({
agg,
showValidation,
value = '',
setValidity,
setValue,
setTouched,
}: AggParamEditorProps<string>) {
const label = (
<>
<FormattedMessage id="visDefaultEditor.controls.jsonInputLabel" defaultMessage="JSON input" />{' '}
<EuiIconTip
position="right"
content={i18n.translate('visDefaultEditor.controls.jsonInputTooltip', {
defaultMessage:
"Any JSON formatted properties you add here will be merged with the elasticsearch aggregation definition for this section. For example 'shard_size' on a terms aggregation.",
})}
type="questionInCircle"
/>
</>
const [isFieldValid, setFieldValidity] = useState(true);
const [editorReady, setEditorReady] = useState(false);

const editorTooltipText = useMemo(
() =>
i18n.translate('visDefaultEditor.controls.jsonInputTooltip', {
defaultMessage:
"Any JSON formatted properties you add here will be merged with the elasticsearch aggregation definition for this section. For example 'shard_size' on a terms aggregation.",
}),
[]
);
const isValid = isValidJson(value);

const onChange = (ev: React.ChangeEvent<HTMLTextAreaElement>) => {
const textValue = ev.target.value;
setValue(textValue);
setValidity(isValidJson(textValue));
};
const jsonEditorLabelText = useMemo(
() =>
i18n.translate('visDefaultEditor.controls.jsonInputLabel', {
defaultMessage: 'JSON input',
}),
[]
);

useEffect(() => {
setValidity(isValid);
}, [isValid]);
const label = useMemo(
() => (
<>
{jsonEditorLabelText}{' '}
<EuiIconTip position="right" content={editorTooltipText} type="questionInCircle" />
</>
),
[jsonEditorLabelText, editorTooltipText]
);

const onEditorValidate = useCallback(
(annotations: unknown[]) => {
// The first onValidate returned from EuiCodeEditor is a false negative
if (editorReady) {
const validity = annotations.length === 0;
setFieldValidity(validity);
setValidity(validity);
} else {
setEditorReady(true);
}
},
[setValidity, editorReady]
);

return (
<EuiFormRow
label={label}
isInvalid={showValidation ? !isValid : false}
isInvalid={showValidation ? !isFieldValid : false}
fullWidth={true}
compressed
>
<EuiTextArea
id={`visEditorRawJson${agg.id}`}
isInvalid={showValidation ? !isValid : false}
value={value}
onChange={onChange}
rows={2}
fullWidth={true}
onBlur={setTouched}
compressed
/>
<>
<EuiCodeEditor
mode="json"
theme="github"
width="100%"
height="250px"
value={value}
onValidate={onEditorValidate}
setOptions={{
fontSize: '14px',
}}
onChange={setValue}
onBlur={setTouched}
aria-label={jsonEditorLabelText}
aria-describedby="jsonEditorDescription"
/>
<EuiScreenReaderOnly>
<p id="jsonEditorDescription">{editorTooltipText}</p>
</EuiScreenReaderOnly>
</>
</EuiFormRow>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export { parentPipelineType } from 'ui/agg_types';
export { siblingPipelineType } from 'ui/agg_types';
export { isType, isStringType } from 'ui/agg_types';
export { OptionedValueProp, OptionedParamEditorProps, OptionedParamType } from 'ui/agg_types';
export { isValidJson, isValidInterval } from 'ui/agg_types';
export { isValidInterval } from 'ui/agg_types';
export { AggParamOption } from 'ui/agg_types';
export { CidrMask } from 'ui/agg_types';

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 53aeb70

Please sign in to comment.