Skip to content

Commit

Permalink
[Chore] Update other timeline es() examples and test usage
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Romero <[email protected]>
  • Loading branch information
joshuarrrr committed Nov 18, 2022
1 parent 327212c commit 47303cf
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/plugins/timeline/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function initTimelineApp(app, deps) {
const savedVisualizations = deps.plugins.visualizations.savedVisualizationsLoader;
const timezone = getTimezone(deps.core.uiSettings);

const defaultExpression = '.es(*)';
const defaultExpression = '.opensearch(*)';

$scope.topNavMenu = getTopNavMenu();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
For some reasons it doesn't work without it (even though the default role of
the element is textbox anyway). -->
<textarea data-expression-input role="textbox" rows="{{ rows }}" class="timExpressionInput kuiTextArea fullWidth"
placeholder="{{ ::'timeline.expressionInputPlaceholder' | i18n: { defaultMessage: 'Try a query with {opensearchQuery}', values: { opensearchQuery: '.es(*)' } } }}"
placeholder="{{ ::'timeline.expressionInputPlaceholder' | i18n: { defaultMessage: 'Try a query with {opensearchQuery}', values: { opensearchQuery: '.opensearch(*)' } } }}"
ng-model="sheet" ng-focus="onFocusInput()" ng-keydown="onKeyDownInput($event)" ng-keyup="onKeyUpInput($event)"
ng-blur="onBlurInput()" ng-mousedown="onMouseDownInput()" ng-mouseup="onMouseUpInput()"
ng-click="onClickExpression()"
Expand All @@ -16,4 +16,4 @@
suggestions-type="suggestions.type" selected-index="suggestions.index"
on-click-suggestion="onClickSuggestion(suggestionIndex)" should-popover="shouldPopoverSuggestions">
</timeline-expression-suggestions>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ <h2 i18n-id="timeline.help.queryingTitle" i18n-default-message="Querying the Ope
datasource, you can start submitting queries. For starters,
enter {opensearchPattern} in the input bar and hit enter."
i18n-values="{
html_opensearchPattern: '<code>.es(*)</code>',
html_opensearchPattern: '<code>.opensearch(*)</code>',
}"
></p>
<p>
Expand All @@ -176,8 +176,8 @@ <h2 i18n-id="timeline.help.queryingTitle" i18n-default-message="Querying the Ope
i18n-values="{
html_opensearchAsteriskQueryDescription: '<em>' + translations.opensearchAsteriskQueryDescription + '</em>',
html_html: '<em>html</em>',
html_htmlQuery: '<code>.es(html)</code>',
html_bobQuery: '<code>.es(\'user:bob AND bytes:>100\')</code>',
html_htmlQuery: '<code>.opensearch(html)</code>',
html_bobQuery: '<code>.opensearch(\'user:bob AND bytes:>100\')</code>',
html_bob: '<em>bob</em>',
html_user: '<code>user</code>',
html_bytes: '<code>bytes</code>',
Expand All @@ -193,7 +193,7 @@ <h2 i18n-id="timeline.help.queryingTitle" i18n-default-message="Querying the Ope
timeline.help.querying.paragraph2Part2"></a>
<span i18n-id="timeline.help.querying.paragraph2Part2"
i18n-default-message="as the first argument to the {opensearchQuery} function." i18n-values="{
html_opensearchQuery: '<code>.es()</code>',
html_opensearchQuery: '<code>.opensearch()</code>',
}" i18n-description="Part of composite text
timeline.help.querying.paragraph2Part1 +
timeline.help.querying.luceneQueryLinkText +
Expand All @@ -208,9 +208,9 @@ <h4 i18n-id="timeline.help.querying.passingArgumentsTitle" i18n-default-message=
For example, you can enter {opensearchLogstashQuery} to tell the OpenSearch datasource
{opensearchIndexQueryDescription}."
i18n-values="{
html_opensearchEmptyQuery: '<code>.es()</code>',
html_opensearchStarQuery: '<code>.es(*)</code>',
html_opensearchLogstashQuery: '<code>.es(index=\'logstash-*\', q=\'*\')</code>',
html_opensearchEmptyQuery: '<code>.opensearch()</code>',
html_opensearchStarQuery: '<code>.opensearch(*)</code>',
html_opensearchLogstashQuery: '<code>.opensearch(index=\'logstash-*\', q=\'*\')</code>',
html_opensearchIndexQueryDescription: '<em>' + translations.opensearchIndexQueryDescription + '</em>',
}"></p>
<h4 i18n-id="timeline.help.querying.countTitle" i18n-default-message="Beyond count"></h4>
Expand Down Expand Up @@ -240,8 +240,8 @@ <h4 i18n-id="timeline.help.querying.countTitle" i18n-default-message="Beyond cou
html_cardinality: '<code>cardinality</code>',
html_bytes: '<code>bytes</code>',
html_srcIp: '<code>src_ip</code>',
html_opensearchCardinalityQuery: '<code>.es(*, metric=\'cardinality:src_ip\')</code>',
html_opensearchAvgQuery: '<code>.es(metric=\'avg:bytes\')</code>',
html_opensearchCardinalityQuery: '<code>.opensearch(*, metric=\'cardinality:src_ip\')</code>',
html_opensearchAvgQuery: '<code>.opensearch(metric=\'avg:bytes\')</code>',
}" i18n-description="Part of composite text
timeline.help.querying.countTextPart1 +
timeline.help.querying.countMetricAggregationLinkText +
Expand Down Expand Up @@ -275,7 +275,7 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
></p>
<table class="table table-condensed table-striped">
<tr>
<td><code>.es(*), .es(US)</code></td>
<td><code>.opensearch(*), .opensearch(US)</code></td>
<td i18n-id="timeline.help.expressions.examples.twoExpressionsDescription"
i18n-default-message="{descriptionTitle} Two expressions on the same chart."
i18n-values="{
Expand All @@ -284,7 +284,7 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
></td>
</tr>
<tr>
<td><code>.es(*).color(#f66), .es(US).bars(1)</code></td>
<td><code>.opensearch(*).color(#f66), .opensearch(US).bars(1)</code></td>
<td
i18n-id="timeline.help.expressions.examples.customStylingDescription"
i18n-default-message="{descriptionTitle} Colorizes the first series red and
Expand All @@ -297,7 +297,7 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
<tr>
<td>
<code
>.es(*).color(#f66).lines(fill=3), .es(US).bars(1).points(radius=3,
>.opensearch(*).color(#f66).lines(fill=3), .opensearch(US).bars(1).points(radius=3,
weight=1)</code
>
</td>
Expand All @@ -310,7 +310,7 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
></td>
</tr>
<tr>
<td><code>(.es(*), .es(GB)).points()</code></td>
<td><code>(.opensearch(*), .opensearch(GB)).points()</code></td>
<td i18n-id="timeline.help.expressions.examples.groupedExpressionsDescription" i18n-default-message="{descriptionTitle} You can also chain groups of expressions to
functions. Here, both series are shown as points instead of lines." i18n-values="{
html_descriptionTitle: '<strong>' + translations.groupedExpressionsDescriptionTitle + '</strong>',
Expand Down Expand Up @@ -350,18 +350,18 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
our web traffic comes from the US?"></p>
<p i18n-id="timeline.help.dataTransforming.paragraph2"
i18n-default-message="First, we need to find all events that contain US: {opensearchUsQuery}."
i18n-values="{ html_opensearchUsQuery: '<code>.es(\'US\')</code>' }"></p>
i18n-values="{ html_opensearchUsQuery: '<code>.opensearch(\'US\')</code>' }"></p>
<p i18n-id="timeline.help.dataTransforming.paragraph3" i18n-default-message="Next, we want to calculate the ratio of US events to the whole.
To divide {us} by everything, we can use the {divide} function:
{divideDataQuery}."
i18n-values="{
html_us: '<code>\'US\'</code>',
html_divide: '<code>divide</code>',
html_divideDataQuery: '<code>.es(\'US\').divide(.es())</code>',
html_divideDataQuery: '<code>.opensearch(\'US\').divide(.opensearch())</code>',
}"></p>
<p i18n-id="timeline.help.dataTransforming.paragraph4" i18n-default-message="Not bad, but this gives us a number between 0 and 1. To convert it
to a percentage, simply multiply by 100: {multiplyDataQuery}."
i18n-values="{ html_multiplyDataQuery: '<code>.es(\'US\').divide(.es()).multiply(100)</code>' }">
i18n-values="{ html_multiplyDataQuery: '<code>.opensearch(\'US\').divide(.opensearch()).multiply(100)</code>' }">
</p>
<p i18n-id="timeline.help.dataTransforming.paragraph5" i18n-default-message="Now we know what percentage of our traffic comes from the US, and
can see how it has changed over time! Timeline has a number of
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/timeline/public/services/_saved_sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function createSavedSheetClass(
title: 'New Timeline Sheet',
hits: 0,
description: '',
timelion_sheet: ['.es(*)'],
timelion_sheet: ['.opensearch(*)'],
timelion_interval: 'auto',
timelion_chart_height: 275,
timelion_columns: config.get('timeline:default_columns') || 2,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/plugins/vis_type_timeline/public/to_ast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('timeline vis toExpressionAst function', () => {
});

it('should not escape single quotes', () => {
vis.params.expression = `.es(index=my*,timefield="date",split='test field:3',metric='avg:value')`;
vis.params.expression = `.opensearch(index=my*,timefield="date",split='test field:3',metric='avg:value')`;
const actual = toExpressionAst(vis);
expect(actual).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const expect = require('chai').expect;

describe('timeline parse_sheet function', function () {
it(`doesn't split expressions on whitespace`, async function () {
const data = ['.es() .es(404)'];
const data = ['.opensearch() .opensearch(404)'];
const ast = parseSheet(data);

const expressions = ast[0];
Expand All @@ -43,7 +43,7 @@ describe('timeline parse_sheet function', function () {
});

it('splits expressions on commas', function () {
const data = ['.es(), .es(404)'];
const data = ['.opensearch(), .opensearch(404)'];
const ast = parseSheet(data);

const expressions = ast[0];
Expand All @@ -53,7 +53,7 @@ describe('timeline parse_sheet function', function () {
});

it('splits expressions on newlines', function () {
const data = [`.es()\n\r ,\n\r .es(404)`];
const data = [`.opensearch()\n\r ,\n\r .opensearch(404)`];
const ast = parseSheet(data);

const expressions = ast[0];
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/vis_type_timeline/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class Plugin {
value: '@timestamp',
description: i18n.translate('timeline.uiSettings.timeFieldDescription', {
defaultMessage: 'Default field containing a timestamp when using {opensearchParam}',
values: { opensearchParam: '.es()' },
values: { opensearchParam: '.opensearch()' },
}),
category: ['timeline'],
schema: schema.string(),
Expand All @@ -123,7 +123,7 @@ export class Plugin {
value: '_all',
description: i18n.translate('timeline.uiSettings.defaultIndexDescription', {
defaultMessage: 'Default opensearch index to search with {opensearchParam}',
values: { opensearchParam: '.es()' },
values: { opensearchParam: '.opensearch()' },
}),
category: ['timeline'],
schema: schema.string(),
Expand Down
Loading

0 comments on commit 47303cf

Please sign in to comment.