mirror of
https://github.com/prometheus/prometheus.git
synced 2025-11-02 09:21:01 +01:00
Merge pull request #17365 from akshatsinha0/fix/old-ui-createExpressionLink
fix(react-app): correct createExpressionLink query for /graph links
This commit is contained in:
commit
4c1355e14b
@ -270,7 +270,7 @@ export const getQueryParam = (key: string): string => {
|
||||
export const createExpressionLink = (expr: string): string => {
|
||||
return `../graph?g0.expr=${encodeURIComponent(expr)}&g0.tab=1&g0.display_mode=${
|
||||
GraphDisplayMode.Lines
|
||||
}&g0.show_exemplars=0.g0.range_input=1h.`;
|
||||
}&g0.show_exemplars=0&g0.range_input=1h`;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,
|
||||
|
||||
@ -15,6 +15,7 @@ import {
|
||||
parseOption,
|
||||
decodePanelOptionsFromQueryString,
|
||||
parsePrometheusFloat,
|
||||
createExpressionLink,
|
||||
} from '.';
|
||||
import { GraphDisplayMode, PanelType } from '../pages/graph/Panel';
|
||||
|
||||
@ -332,5 +333,17 @@ describe('Utils', () => {
|
||||
expect(parsePrometheusFloat('-1.7e+01')).toEqual(-17);
|
||||
});
|
||||
});
|
||||
describe('createExpressionLink',()=>{
|
||||
it('<....>builds link',()=>{
|
||||
expect(createExpressionLink('up')).toEqual(
|
||||
`../graph?g0.expr=up&g0.tab=1&g0.display_mode=${GraphDisplayMode.Lines}&g0.show_exemplars=0&g0.range_input=1h`
|
||||
);
|
||||
});
|
||||
it('url-encodes PromQL',() =>{
|
||||
expect(createExpressionLink('ALERTS{alertname="HighCPU"}')).toEqual(
|
||||
`../graph?g0.expr=ALERTS%7Balertname%3D%22High%20CPU%22%7D&g0.tab=1&g0.display_mode=${GraphDisplayMode.Lines}&g0.show_exemplars=0&g0.range_input=1h`
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user