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

Refactor/metric save as ppl #1151

Closed
wants to merge 4 commits into from
Closed

Conversation

pjfitzgibbons
Copy link
Contributor

Description

Modify Metric Export to produce PPL based Metric query on Prometheus datasource.
Example query : source = prom_connector.prometheus_http_request_total | ...

Issues Resolved

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Fix countDistribution access error when countDistribution not available.

Signed-off-by: Peter Fitzgibbons <[email protected]>
Signed-off-by: Peter Fitzgibbons <[email protected]>
@pjfitzgibbons pjfitzgibbons force-pushed the refactor/metric-save-as-ppl branch from a6f8435 to 37a963b Compare October 23, 2023 17:48
@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Merging #1151 (f40d4f0) into main (ddb697a) will decrease coverage by 0.20%.
Report is 6 commits behind head on main.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1151      +/-   ##
==========================================
- Coverage   44.21%   44.02%   -0.20%     
==========================================
  Files         329      329              
  Lines       19542    19554      +12     
  Branches     4719     4719              
==========================================
- Hits         8640     8608      -32     
- Misses      10335    10378      +43     
- Partials      567      568       +1     
Flag Coverage Δ
dashboards-observability 44.02% <ø> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 10 files with indirect coverage changes

x: number;
y: number;
w: number;
h: number;
metricType: 'savedCustomMetric' | 'prometheusMetric';
catalog: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic around choosing if a record is "customMetric" or "prometheus" is simplified to just knowinng what catalog it is from.


// Creates a catalogVisualization for a runtime catalog based PPL query and runs getQueryResponse
export const renderCatalogVisualization = async ({
export const renderSavedVisualization = async ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Git diff split this one wierdly.
renderSavedVisualization is retained, diff is below.
renderCatalogVisualization, updateCatalogVisualizationQuery, createCatalogVisualizationMetaData are removed entirely, as they are specific to PromQL query processing, which is no longer needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

why is it no longer needed?

}: {
http: CoreStart['http'];
pplService: PPLService;
catalogSource: string;
savedVisualizationId: string;
inputMetaData: SavedVisualization;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a certain case (metric grid) the VisualizationConainer, will be passed the meta-data directly (inputMetaData), instead of having a saved record to render. It is passed here for processing.

setIsLoading,
setIsError
);
await renderSavedVisualization({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Argument list converted to object to avoid variable-placement errors in long argument list.

@@ -84,8 +84,6 @@ const normalizedPanel = (panel: CustomPanelType): CustomPanelType => ({

export const selectPanelList = (rootState): CustomPanelType[] => rootState.customPanel.panelList;

const {setToast} = useToast();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

linter says "useToast" can't be called at top-level.
Integrated into each method using it.

export const addMultipleVizToPanels = (panels, vizIds) => async (dispatch, getState) => {
forEach(panels, (oldPanel) => {
const panel = getState().customPanel.panelList.find((p) => p.id === oldPanel.panel.id);
export const addMultipleVizToPanels = async (panels, vizIds) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method re-written to capture the actual logic used in VisualizationFlyout

};

export const replaceVizInPanel = (oldPanel, oldVizId, vizId, newVisualizationTitle) => async (dispatch, getState) => {
export const replaceVizInPanel = (oldPanel, oldVizId, vizId, newVisualizationTitle) => async (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just some auto-formatting. Nothing to see here.

public/components/event_analytics/explorer/explorer.tsx Outdated Show resolved Hide resolved
};
};

const updateSavedVisualization = async (metricLayout: MetricType, name: string): string => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method written to overcome the incongruent API of OSDSavedVisualizationClient, which returns the raw saved-object on get() and expects a modified UI-ready object on update()

Signed-off-by: Peter Fitzgibbons <[email protected]>
const updateLayoutBySelection = (state: any, newMetric: any) => {
const newDimensions = getNewVizDimensions(state.metricsLayout);
const metricQueryFromId = (id: string) => {
return `source = ${id} | stats avg(@value) by span(@timestamp, 1d)`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of this function?

Copy link
Collaborator

@kavithacm kavithacm left a comment

Choose a reason for hiding this comment

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

can you resolve the merge conflicts ?

@pjfitzgibbons pjfitzgibbons deleted the refactor/metric-save-as-ppl branch November 9, 2023 23:33
RyanL1997 pushed a commit to RyanL1997/dashboards-observability that referenced this pull request Apr 18, 2024
…) (opensearch-project#1168)

Signed-off-by: Yan Zeng <[email protected]>

Co-authored-by: Chang Liu <[email protected]>
(cherry picked from commit 6236fe2a34f06fd2c104f4b7f86cfce4e55d761d)

Co-authored-by: Yan Zeng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants