-
Notifications
You must be signed in to change notification settings - Fork 58
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
Conversation
Fix countDistribution access error when countDistribution not available. Signed-off-by: Peter Fitzgibbons <[email protected]>
Signed-off-by: Peter Fitzgibbons <[email protected]>
Signed-off-by: Peter Fitzgibbons <[email protected]>
a6f8435
to
37a963b
Compare
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. |
x: number; | ||
y: number; | ||
w: number; | ||
h: number; | ||
metricType: 'savedCustomMetric' | 'prometheusMetric'; | ||
catalog: string; |
There was a problem hiding this comment.
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 ({ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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.
}; | ||
}; | ||
|
||
const updateSavedVisualization = async (metricLayout: MetricType, name: string): string => { |
There was a problem hiding this comment.
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)`; |
There was a problem hiding this comment.
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?
There was a problem hiding this 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 ?
…) (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]>
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
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.