Skip to content

Commit

Permalink
Catch up to all latest PromQL features, enable experimental functions
Browse files Browse the repository at this point in the history
This updates UI and backend dependencies such that PromLens supports the latest
PromQL features, such as:

* limitk() / limit_ratio() operators
* all current experimental functions, such as mad_over_time() and native histogram ones
* updated function documentation

Signed-off-by: Julius Volz <[email protected]>
  • Loading branch information
juliusv committed Aug 31, 2024
1 parent cf4dfe1 commit 23b6826
Show file tree
Hide file tree
Showing 13 changed files with 1,082 additions and 2,024 deletions.
215 changes: 121 additions & 94 deletions app/package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@codemirror/autocomplete": "^6.3.0",
"@codemirror/commands": "^6.2.4",
"@codemirror/language": "^6.2.1",
"@codemirror/lint": "^6.0.0",
"@codemirror/search": "^6.2.1",
"@codemirror/state": "^6.1.4",
"@codemirror/view": "^6.3.1",
"@codemirror/autocomplete": "^6.18.0",
"@codemirror/commands": "^6.6.1",
"@codemirror/language": "^6.10.2",
"@codemirror/lint": "^6.8.1",
"@codemirror/search": "^6.5.6",
"@codemirror/state": "^6.4.1",
"@codemirror/view": "^6.33.0",
"@fortawesome/fontawesome-svg-core": "^1.2.34",
"@fortawesome/free-solid-svg-icons": "^5.15.2",
"@lezer/highlight": "^1.1.4",
"@prometheus-io/codemirror-promql": "^0.42.0",
"@prometheus-io/codemirror-promql": "^0.54.1",
"bootstrap": "^4.5.3",
"flot": "^4.2.1",
"fuzzy": "^0.1.3",
Expand Down
5 changes: 5 additions & 0 deletions app/src/PromLens/NodeVisualizer/ExplainViews/Aggregation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ const describeAggregationType = (aggrType: aggregationType, param: ASTNode | nul
}th percentile) over the sample values of the input series`;
}
return 'calculates a quantile over the sample values of the input series';

case 'limitk':
return 'limits the output to K series';
case 'limit_ratio':
return 'limits the output to a ratio of the input series';
default:
throw new Error(`invalid aggregation type ${aggrType}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ const AggregationEditor: FC<AggregationEditorProps> = ({ node, onUpdate }) => {

const changeOp = (newOp: aggregationType) => {
let param: ASTNode | null = null;
// Keeping the param argument only makes sense when switching between bottomk/topk.
if (['topk', 'bottomk'].includes(node.op) && ['topk', 'bottomk'].includes(newOp)) {

// Keeping the param argument only makes sense when switching between bottomk/topk/limitk.
const kOps = ['topk', 'bottomk', 'limitk'];
if (kOps.includes(node.op) && kOps.includes(newOp)) {
param = node.param;
}

if (!aggregatorsWithParam.includes(node.op) && aggregatorsWithParam.includes(newOp)) {
param = { type: nodeType.placeholder, children: [] };
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/promql/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export enum aggregationType {
bottomk = 'bottomk',
topk = 'topk',
quantile = 'quantile',
limitK = 'limitk',
limitRatio = 'limit_ratio',
}

export enum binaryOperatorType {
Expand Down
1 change: 1 addition & 0 deletions app/src/promql/cmd/gen_functions_docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func main() {
"stdvar_over_time",
"last_over_time",
"present_over_time",
"mad_over_time",
} {
funcDocs[fn] = currentDocs
}
Expand Down
Loading

0 comments on commit 23b6826

Please sign in to comment.