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

Alert rules parser breaks on valid input #5047

Closed
RichiH opened this Issue Dec 28, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@RichiH
Copy link
Member

RichiH commented Dec 28, 2018

I just broke Prometheus at 35C3 with the following rule:

  - alert: APHighAssociations                       
    expr: {__name__=~"AP_Data_radio._Clients"} > 150                                                                                                           
    for: 15m                                        
    labels:                                         
      severity: sev3                                
    annotations:                                    
      summary: "AP {{ $labels.host }} has more than 150 clients"
      description: "AP {{$labels.host}} has had more than 150 clients for 15 minutes."

It works when expanding on the regex:

  - alert: APHighAssociations
    expr: (AP_Data_radio0_Clients > 150) or (AP_Data_radio1_Clients > 150)
    for: 15m
    labels:
      severity: sev3
    annotations:
      summary: "AP {{ $labels.host }} has more than 150 clients"
      description: "AP {{$labels.host}} has had more than 150 clients for 15 minutes."

Verified with 2.6.0

@RichiH

This comment has been minimized.

Copy link
Member Author

RichiH commented Dec 28, 2018

PS:

% ./promtool check rules first_rules.yml
Checking test.yml
  FAILED:
yaml: line XX: did not find expected comment or line break
%
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Dec 28, 2018

That's not valid yaml.

@brian-brazil brian-brazil added kind/question and removed kind/bug labels Dec 28, 2018

@RichiH

This comment has been minimized.

Copy link
Member Author

RichiH commented Dec 28, 2018

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Dec 28, 2018

I did, it's still not valid YAML. You need to quote it.

@beorn7

This comment has been minimized.

Copy link
Member

beorn7 commented Dec 28, 2018

To be more concrete: Strings starting with { need to be quoted in YAML.

@RichiH

This comment has been minimized.

Copy link
Member Author

RichiH commented Dec 28, 2018

Aye, thanks.

@RichiH RichiH closed this Dec 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.