Skip to content

Conversation

@scunningham
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for PromQL (Prometheus Query Language) expressions to the prequel compiler, enabling metric-based correlation rules alongside existing log-based rules.

  • Introduces NodeTypePromQL schema type and parsing infrastructure for PromQL expressions
  • Implements AST building and validation for PromQL nodes with interval and duration support
  • Refactors node type checking into reusable helper methods (IsMatcherNode, IsPromNode)

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/schema/schema.go Adds NodeTypePromQL constant, replacing unused NodeTypeDesc
pkg/parser/parse.go Adds ParsePromQL struct and updates ParseTermT to support PromQL terms
pkg/parser/tree.go Implements PromQL parsing with nodeFromProm, adds type-checking helpers, refactors node assignment logic
pkg/parser/parse_test.go Adds test case for PromQL parsing and fixes whitespace formatting
pkg/ast/ast.go Updates AST builder to handle PromQL nodes and adds PromQL to valid node types
pkg/ast/ast_metrics.go New file implementing PromQL AST node builder with event and timing support
pkg/ast/ast_machine.go Adds PromQL case to machine node builder
pkg/ast/ast_log.go Minor whitespace cleanup
pkg/ast/ast_test.go Adds PromQL test case and updates line number for test after testdata changes
pkg/testdata/rules.go Removes unnecessary event sources from error test cases and adds PromQL test data
pkg/datasrc/parse.go Upgrades yaml dependency from v2 to v3
go.mod / go.sum Removes yaml.v2 dependency, retaining yaml.v3

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if promMatcher, err := b.buildPromQLNode(parserNode, machineAddress, nil); err != nil {
return nil, err
} else {
matchNode.Object = promMatcher
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

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

Inconsistent pattern: buildPromQLNode returns *AstNodeT while buildSeqMatcher and buildSetMatcher return *AstSeqMatcherT and *AstSetMatcherT respectively. Assigning the entire node (promMatcher) to matchNode.Object is incorrect - it should assign promMatcher.Object (which contains the *AstPromQL) to be consistent with the other cases. Alternatively, buildPromQLNode should be refactored to return *AstPromQL directly like the other builder functions.

Suggested change
matchNode.Object = promMatcher
matchNode.Object = promMatcher.Object

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I did this right. @tonymeehan ?


// Build children (either matcher children or nested machines)
if isMatcherNode(parserNode) {
if parserNode.IsMatcherNode() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@scunningham scunningham merged commit b9ed025 into main Nov 18, 2025
1 check passed
@scunningham scunningham deleted the promql branch November 18, 2025 19:32
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.

4 participants