Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target index settings to rollup #1280

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { long } from "@opensearch-project/opensearch/api/types";
import { ActionType } from "../public/pages/VisualCreatePolicy/utils/constants";
import { IndicesUpdateMode } from "../public/utils/constants";

export interface ManagedIndexMetaData {
index: string;
Expand Down Expand Up @@ -490,6 +489,7 @@ export interface Rollup {
schema_version: number;
source_index: string;
target_index: string;
target_index_settings: Map<string, any> | null;
roles: string[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ exports[`<IndexForm /> spec render page 1`] = `

<a
class="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest/api-reference/index-apis/create-index#index-settings"
href="https://opensearch.org/docs/latest/install-and-configure/configuring-opensearch/index-settings/#index-level-index-settings"
rel="noopener noreferrer"
target="_blank"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ exports[`<CreateIndexTemplate /> spec render template pages 1`] = `

<a
class="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest/api-reference/index-apis/create-index#index-settings"
href="https://opensearch.org/docs/latest/install-and-configure/configuring-opensearch/index-settings/#index-level-index-settings"
rel="noopener noreferrer"
target="_blank"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ exports[`<TemplateDetail /> spec render component in non-edit-mode 1`] = `

<a
class="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest/api-reference/index-apis/create-index#index-settings"
href="https://opensearch.org/docs/latest/install-and-configure/configuring-opensearch/index-settings/#index-level-index-settings"
rel="noopener noreferrer"
target="_blank"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@

import React, { Component } from "react";
import { EuiFlexGrid, EuiSpacer, EuiFlexItem, EuiText, EuiFlexGroup, EuiHorizontalRule, EuiPanel, EuiTitle } from "@elastic/eui";
import { ContentPanel, ContentPanelActions } from "../../../../components/ContentPanel";
import { ContentPanelActions } from "../../../../components/ContentPanel";
import { ModalConsumer } from "../../../../components/Modal";
import { IndexItem } from "../../../../../models/interfaces";
import { getOrderedJson } from "../../../../../utils/helper";

interface JobNameAndIndicesProps {
rollupId: string;
description: string;
sourceIndex: { label: string; value?: IndexItem }[];
targetIndex: { label: string; value?: IndexItem }[];
targetIndexSettings: Pick<IndexItem, "settings"> | null;
onChangeStep: (step: number) => void;
}

Expand All @@ -23,7 +25,7 @@ export default class JobNameAndIndices extends Component<JobNameAndIndicesProps>
}

render() {
const { rollupId, description, onChangeStep, sourceIndex, targetIndex } = this.props;
const { rollupId, description, onChangeStep, sourceIndex, targetIndex, targetIndexSettings } = this.props;

return (
<EuiPanel>
Expand Down Expand Up @@ -72,6 +74,14 @@ export default class JobNameAndIndices extends Component<JobNameAndIndicesProps>
<dd>{targetIndex[0].label}</dd>
</EuiText>
</EuiFlexItem>
{targetIndexSettings && (
<EuiFlexItem>
<EuiText size="s">
<dt>Target index Settings</dt>
<dd>{JSON.stringify(getOrderedJson(targetIndexSettings || {}), null, 2)}</dd>
</EuiText>
</EuiFlexItem>
)}
<EuiFlexItem>
<EuiText size="s">
<dt>Description</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ import { IndexItem } from "../../../../../models/interfaces";
import IndexService from "../../../../services/IndexService";
import { CoreServicesContext } from "../../../../components/core_services";
import { wildcardOption } from "../../../../utils/helpers";
import AdvancedSettings from "../../../../components/AdvancedSettings";
import flat from "flat";
import { INDEX_SETTINGS_URL } from "../../../../utils/constants";

interface RollupIndicesProps {
indexService: IndexService;
sourceIndex: { label: string; value?: IndexItem }[];
sourceIndexError: string;
targetIndex: { label: string; value?: IndexItem }[];
targetIndexError: string;
targetIndexSettings: Pick<IndexItem, "settings"> | null;
targetIndexSettingsError: string;
onChangeSourceIndex: (options: EuiComboBoxOptionOption<IndexItem>[]) => void;
onChangeTargetIndex: (options: EuiComboBoxOptionOption<IndexItem>[]) => void;
onChangeTargetIndexSettings: (settings: Pick<IndexItem, "settings"> | null) => void;
hasAggregation: boolean;
}

Expand Down Expand Up @@ -124,8 +130,11 @@ export default class RollupIndices extends Component<RollupIndicesProps, RollupI
sourceIndexError,
targetIndex,
targetIndexError,
targetIndexSettings,
targetIndexSettingsError,
onChangeSourceIndex,
onChangeTargetIndex,
onChangeTargetIndexSettings,
hasAggregation,
} = this.props;
const { isLoading, indexOptions, targetIndexOptions } = this.state;
Expand Down Expand Up @@ -209,6 +218,66 @@ export default class RollupIndices extends Component<RollupIndicesProps, RollupI
data-test-subj="targetIndexCombobox"
/>
</EuiCompressedFormRow>

<EuiCompressedFormRow
error={targetIndexSettingsError}
isInvalid={targetIndexSettingsError != ""}
helpText={
<EuiText size={"xs"}>
{"Optional. The target index settings will be apply only if target index will be created during the rollup."}
{
<EuiLink external href={ROLLUP_RESULTS_HELP_TEXT_LINK} target={"_blank"} rel="noopener noreferrer">
Learn more
</EuiLink>
}
</EuiText>
}
>
<AdvancedSettings
value={targetIndexSettings || {}}
onChange={(val) => {
if (Object.keys(val).length === 0) {
onChangeTargetIndexSettings(null);
} else {
onChangeTargetIndexSettings(val);
}
}}
accordionProps={{
initialIsOpen: false,
id: "accordionForCreateRollupTargetIndexSettings",
buttonContent: <h3>Target index settings</h3>,
}}
editorProps={{
disabled: false,
width: "100%",
formatValue: flat,
}}
rowProps={{
fullWidth: true,
label: "Specify advanced index settings",
helpText: (
<>
<p>
Specify a comma-delimited list of settings.{" "}
<EuiLink href={INDEX_SETTINGS_URL} target="_blank" external>
View index settings
</EuiLink>
</p>
<p>
All the settings will be handled in flat structure.{" "}
<EuiLink
href="https://opensearch.org/docs/latest/api-reference/index-apis/get-index/#query-parameters"
external
target="_blank"
>
Learn more
</EuiLink>
</p>
</>
),
}}
/>
</EuiCompressedFormRow>
</EuiPanel>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React, { ChangeEvent, Component, useContext } from "react";
import { EuiSpacer, EuiTitle, EuiFlexGroup, EuiFlexItem, EuiComboBoxOptionOption, EuiText } from "@elastic/eui";
import React, { ChangeEvent, Component } from "react";
import { EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiComboBoxOptionOption, EuiText } from "@elastic/eui";
import { RouteComponentProps } from "react-router-dom";
import { RollupService } from "../../../../services";
import ConfigureRollup from "../../components/ConfigureRollup";
import RollupIndices from "../../components/RollupIndices";
import CreateRollupSteps from "../../components/CreateRollupSteps";
import IndexService from "../../../../services/IndexService";
import { IndexItem } from "../../../../../models/interfaces";
import { DataSourceMenuContext, DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext";
import { DataSourceMenuProperties } from "../../../../services/DataSourceMenuContext";

interface CreateRollupProps extends RouteComponentProps, DataSourceMenuProperties {
rollupService: RollupService;
Expand All @@ -27,10 +27,13 @@ interface CreateRollupProps extends RouteComponentProps, DataSourceMenuPropertie
sourceIndexError: string;
targetIndex: { label: string; value?: IndexItem }[];
targetIndexError: string;
targetIndexSettings: Pick<IndexItem, "settings"> | null;
targetIndexSettingsError: string;
onChangeName: (e: ChangeEvent<HTMLInputElement>) => void;
onChangeDescription: (value: ChangeEvent<HTMLTextAreaElement>) => void;
onChangeSourceIndex: (options: EuiComboBoxOptionOption<IndexItem>[]) => void;
onChangeTargetIndex: (options: EuiComboBoxOptionOption<IndexItem>[]) => void;
onChangeTargetIndexSettings: (settings: Pick<IndexItem, "settings"> | null) => void;
currentStep: number;
hasAggregation: boolean;
useNewUX: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import React, { ChangeEvent, Component, useContext } from "react";
import { EuiSmallButton, EuiSmallButtonEmpty, EuiComboBoxOptionOption, EuiFlexGroup, EuiFlexItem } from "@elastic/eui";
import { RouteComponentProps, useHistory } from "react-router-dom";
import { RouteComponentProps } from "react-router-dom";
import moment from "moment";
import { RollupService } from "../../../../services";
import { BREADCRUMBS, ROUTES } from "../../../../utils/constants";
Expand All @@ -24,7 +24,6 @@ import { CoreServicesContext } from "../../../../components/core_services";
import {
DataSourceMenuContext,
DataSourceMenuProperties,
DataSourceMenuReadOnlyContext,
DataSourceMenuReadOnlyProperties,
} from "../../../../services/DataSourceMenuContext";
import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent";
Expand Down Expand Up @@ -53,6 +52,8 @@ interface CreateRollupFormState {
sourceIndexError: string;
targetIndex: { label: string; value?: IndexItem }[];
targetIndexError: string;
targetIndexSettings: Pick<IndexItem, "settings"> | null;
targetIndexSettingsError: string;

mappings: any;
allMappings: FieldItem[][];
Expand Down Expand Up @@ -115,6 +116,8 @@ export class CreateRollupForm extends Component<CreateRollupFormProps, CreateRol
sourceIndexError: "",
targetIndex: [],
targetIndexError: "",
targetIndexSettings: null,
targetIndexSettingsError: "",

timestamp: [],
timestampError: "",
Expand Down Expand Up @@ -333,6 +336,12 @@ export class CreateRollupForm extends Component<CreateRollupFormProps, CreateRol
this.setState({ targetIndex: options, rollupJSON: newJSON, targetIndexError: targetIndexError });
};

onChangeTargetIndexSettings = (settings: Pick<IndexItem, "settings"> | null): void => {
let newJSON = this.state.rollupJSON;
newJSON.rollup.target_index_settings = settings;
this.setState({ targetIndexSettings: settings, rollupJSON: newJSON });
};

onChangeIntervalType = (intervalType: string): void => {
this.setState({ intervalType, timeunit: "h" });
};
Expand Down Expand Up @@ -573,6 +582,8 @@ export class CreateRollupForm extends Component<CreateRollupFormProps, CreateRol
sourceIndexError,
targetIndex,
targetIndexError,
targetIndexSettings,
targetIndexSettingsError,
currentStep,

timestamp,
Expand Down Expand Up @@ -614,10 +625,13 @@ export class CreateRollupForm extends Component<CreateRollupFormProps, CreateRol
sourceIndexError={sourceIndexError}
targetIndex={targetIndex}
targetIndexError={targetIndexError}
targetIndexSettings={targetIndexSettings}
targetIndexSettingsError={targetIndexSettingsError}
onChangeName={this.onChangeName}
onChangeDescription={this.onChangeDescription}
onChangeSourceIndex={this.onChangeSourceIndex}
onChangeTargetIndex={this.onChangeTargetIndex}
onChangeTargetIndexSettings={this.onChangeTargetIndexSettings}
currentStep={this.state.currentStep}
hasAggregation={selectedDimensionField.length != 0 || selectedMetrics.length != 0}
useNewUX={useNewUX}
Expand Down Expand Up @@ -677,6 +691,7 @@ export class CreateRollupForm extends Component<CreateRollupFormProps, CreateRol
description={description}
sourceIndex={sourceIndex}
targetIndex={targetIndex}
targetIndexSettings={targetIndexSettings}
intervalType={intervalType}
intervalValue={intervalValue}
timestamp={timestamp}
Expand Down
Loading