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

Metrics api events #1214

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('Search bar', () => {
const popoverItems = jest.fn();
const isLiveTailOn = jest.fn();
const countDistribution = jest.fn();
const setMetricLabel = jest.fn();
const utils = render(
<Search
key="search-component"
Expand Down Expand Up @@ -61,6 +62,11 @@ describe('Search bar', () => {
popoverItems={popoverItems}
isLiveTailOn={isLiveTailOn}
countDistribution={countDistribution}
curVisId={'line'}
spanValue={false}
setSubType={'metric'}
setMetricMeasure={'hours (h)'}
setMetricLabel={setMetricLabel}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export const Search = (props: any) => {
searchError = null,
curVisId,
spanValue,
setSubType,
setMetricMeasure,
setMetricLabel,
} = props;

const appLogEvents = tabId.match(APP_ANALYTICS_TAB_ID_REGEX);
Expand Down Expand Up @@ -216,9 +219,13 @@ export const Search = (props: any) => {
showOptionList={
showSavePanelOptionsList &&
searchBarConfigs[selectedSubTabId]?.showSavePanelOptionsList

}
curVisId={curVisId}
spanValue={spanValue}
setSubType={setSubType}
setMetricMeasure={setMetricMeasure}
setMetricLabel={setMetricLabel}
/>
<EuiPopoverFooter>
<EuiFlexGroup justifyContent="flexEnd">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export const Explorer = ({
false
);
const [spanValue, setSpanValue] = useState(false);
const [subType, setSubType] = useState('visualization');
const [metricMeasure, setMetricMeasure] = useState('');
const [metricLabel, setMetricLabel] = useState([]);
const queryRef = useRef();
const appBasedRef = useRef('');
appBasedRef.current = appBaseQuery;
Expand Down Expand Up @@ -1107,6 +1110,9 @@ export const Explorer = ({
? JSON.stringify(userVizConfigs[curVisId])
: JSON.stringify({}),
description: vizDescription,
subType: subType,
unitsOfMeasure: metricMeasure,
// selectedLabels: metricLabel
})
.then((res: any) => {
setToast(
Expand Down Expand Up @@ -1141,6 +1147,9 @@ export const Explorer = ({
? JSON.stringify(userVizConfigs[curVisId])
: JSON.stringify({}),
description: vizDescription,
subType: subType,
unitsOfMeasure: metricMeasure,
// selectedLabels: metricLabel
})
.then((res: any) => {
batch(() => {
Expand Down Expand Up @@ -1342,6 +1351,9 @@ export const Explorer = ({
searchError={explorerVisualizations}
curVisId={curVisId}
spanValue={spanValue}
setSubType={setSubType}
setMetricMeasure={setMetricMeasure}
setMetricLabel={setMetricLabel}
/>
<EuiTabbedContent
className="mainContentTabs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('Saved query table component', () => {
it('Renders saved query table', async () => {
const handleNameChange = jest.fn();
const handleOptionChange = jest.fn();
const setMetricLabel = jest.fn();
const savedObjects = new SavedObjects(httpClientMock);

const wrapper = mount(
Expand All @@ -28,7 +29,12 @@ describe('Saved query table component', () => {
savedObjects={savedObjects}
savePanelName={'Count by depature'}
showOptionList={true}
/>
curVisId={'line'}
spanValue={false}
setSubType={'metric'}
setMetricMeasure={'hours (h)'}
setMetricLabel={setMetricLabel}
/>
);

wrapper.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ interface ISavedPanelProps {
showOptionList: boolean;
curVisId: string;
spanValue: boolean;
setSubType: any;
setMetricMeasure: any;
setMetricLabel: any;
}

interface CustomPanelOptions {
Expand All @@ -45,6 +48,9 @@ export const SavePanel = ({
showOptionList,
curVisId,
spanValue,
setSubType,
setMetricMeasure,
setMetricLabel,
}: ISavedPanelProps) => {
const [options, setOptions] = useState([]);
const [checked, setChecked] = useState(false);
Expand All @@ -67,14 +73,21 @@ export const SavePanel = ({

const onToggleChange = (e: { target: { checked: React.SetStateAction<boolean> } }) => {
setChecked(e.target.checked);
if (e.target.checked) {
setSubType("metric")
} else {
setSubType("visualization")
}
};

const onMeasureChange = (selectedMeasures: React.SetStateAction<never[]>) => {
setMeasure(selectedMeasures);
setMetricMeasure(selectedMeasures[0].label);
};

const onLabelChange = (selectedLabels: React.SetStateAction<never[]>) => {
setLabel(selectedLabels);
setMetricLabel(selectedLabels);
};

return (
Expand Down Expand Up @@ -149,11 +162,11 @@ export const SavePanel = ({
data-test-subj="eventExplorer__metricMeasureSaveComboBox"
/>
</EuiFormRow>
<EuiSpacer size="s" />
{/* <EuiSpacer size="s" />
<EuiTitle size="xxs">
<h3>{'Labels'}</h3>
</EuiTitle>
<EuiFormRow>
</EuiTitle> */}
{/* <EuiFormRow>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments if unnecessary? unless we are still deciding on using labels

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let this component be commented for now(can be used later), need to finish some more work in events home page

<EuiComboBox
placeholder="Select labels"
onChange={onLabelChange}
Expand All @@ -166,7 +179,7 @@ export const SavePanel = ({
isClearable={true}
data-test-subj="eventExplorer__metricLabelSaveComboBox"
/>
</EuiFormRow>
</EuiFormRow> */}
</>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export default class SavedObjects {
description = '',
applicationId = '',
userConfigs = '',
subType = '',
unitsOfMeasure = '',
selectedLabels,
}: any) {
const objRequest: any = {
object: {
Expand Down Expand Up @@ -91,6 +94,18 @@ export default class SavedObjects {
objRequest.object.user_configs = userConfigs;
}

if (!isEmpty(subType)) {
objRequest.object.sub_type = subType;
}

if (!isEmpty(unitsOfMeasure)) {
objRequest.object.units_of_measure = unitsOfMeasure;
}

if (!isEmpty(selectedLabels)) {
objRequest.object.selected_labels = selectedLabels;
}

return objRequest;
}

Expand Down Expand Up @@ -167,6 +182,9 @@ export default class SavedObjects {
timestamp: params.timestamp,
userConfigs: params.userConfigs,
description: params.description,
subType: params.subType,
unitsOfMeasure: params.unitsOfMeasure,
selectedLabels: params.selectedLabels
});

finalParams.object_id = params.objectId;
Expand Down Expand Up @@ -227,6 +245,9 @@ export default class SavedObjects {
applicationId: params.applicationId,
userConfigs: params.userConfigs,
description: params.description,
subType: params.subType,
unitsOfMeasure: params.unitsOfMeasure,
selectedLabels: params.selectedLabels
});

return await this.http.post(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ export const registerEventAnalyticsRouter = ({
description: schema.string(),
application_id: schema.maybe(schema.string()),
user_configs: schema.string(),
sub_type: schema.string(),
units_of_measure: schema.maybe(schema.string()),
selected_labels: schema.maybe(schema.object({
label: schema.arrayOf(schema.object({}, { unknowns: 'allow' })),
})),
}),
}),
},
Expand Down Expand Up @@ -226,6 +231,11 @@ export const registerEventAnalyticsRouter = ({
description: schema.string(),
application_id: schema.maybe(schema.string()),
user_configs: schema.string(),
sub_type: schema.string(),
units_of_measure: schema.maybe(schema.string()),
selected_labels: schema.maybe(schema.object({
labels: schema.arrayOf(schema.object({}, { unknowns: 'allow' })),
})),
}),
}),
},
Expand Down
2 changes: 1 addition & 1 deletion opensearch-observability/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask
buildscript {
ext {
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
opensearch_version = System.getProperty("opensearch.version", "2.2.0-SNAPSHOT")
opensearch_version = System.getProperty("opensearch.version", "2.4.0-SNAPSHOT")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
Expand Down
Loading