Skip to content

Rule UI fails to load, template expansion failed, can't evaluate field GetEvaluationTimestamp #3311

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

Closed
sevagh opened this issue Oct 13, 2020 · 14 comments · Fixed by #3346
Closed

Comments

@sevagh
Copy link
Contributor

sevagh commented Oct 13, 2020

I can no longer load the loaded rules page (/rules) in the Thanos Rule UI since upgrading Prometheus to 2.21.0 and Thanos to 0.16.0-rc.0:

Oct 13 13:11:14 thanos[37515]:
level=warn
ts=2020-10-13T20:11:14.835535904Z
caller=ui.go:152
component=rules
msg="template expansion failed"
err="template: :67:48: executing \"content\" at <.GetEvaluationTimestamp.IsZero>: 
can't evaluate field GetEvaluationTimestamp in type rules.Group"

I see the following issue in the Prometheus project that may be related? prometheus/prometheus#7865

@sevagh sevagh changed the title Rule UI fails to load, template expansion failed Rule UI fails to load, template expansion failed, can't evaluate field GetEvaluationTimestamp Oct 13, 2020
@onprem
Copy link
Member

onprem commented Oct 14, 2020

I see the following issue in the Prometheus project that may be related? prometheus/prometheus#7865

Yes, that seems to be the case. Help wanted, this should be easy enough.

@allenmqcymp
Copy link

Hi, is the issue located here

<td><h2>{{if .GetEvaluationTimestamp.IsZero}}Never{{else}}{{since .GetEvaluationTimestamp}} ago{{end}}</h2></td>

where

GetEvaluationTimestamp

needs to be changed to

GetLastEvaluation

wherever GetEvaluationTimestamp occurs?

Like how prometheus/prometheus#7865 does it?

@onprem
Copy link
Member

onprem commented Oct 15, 2020

Yep, exactly.

@allenmqcymp
Copy link

@prmsrswt How would I go about verifying the change works - ie. how do I run the Thanos Rule UI? Thanks!

@sevagh
Copy link
Contributor Author

sevagh commented Oct 15, 2020

If you have a branch, I can build from it to test it. I have a fully working Thanos environment with broken rules UIs.

@allenmqcymp
Copy link

Alright, do you want to try build and test from https://github.com/allenmqcymp/thanos/tree/rulefix.

@onprem
Copy link
Member

onprem commented Oct 15, 2020

Also for future you can use https://github.com/thanos-community/thanos-docker-compose for a local set-up using docker and docker-compose.

@sevagh
Copy link
Contributor Author

sevagh commented Oct 19, 2020

I'll be able to test this shortly. Do I need to run "make assets" before "make build"? I only did "make build" which didn't fix the issue. Trying "make assets && make build" now.

@sevagh
Copy link
Contributor Author

sevagh commented Oct 19, 2020

With the fixed binary I get this error now:

Oct 19 06:49:08 dc6-thanos2 thanos[3244]: level=warn ts=2020-10-19T13:49:08.115333884Z caller=ui.go:152
component=rules
msg="template expansion failed"
err="template: :93:37: executing \"content\" at <.GetLastEvaluation.IsZero>: 
can't evaluate field GetLastEvaluation in type rules.Rule"

@sevagh
Copy link
Contributor Author

sevagh commented Oct 19, 2020

I think you made one change too many. The original Prometheus PR only changes 2 lines: https://github.com/prometheus/prometheus/pull/7865/files

You changed 4: allenmqcymp@26ef1dc

I'm trying with just the first 2 lines now.

Nah I'm probably wrong.

@sevagh
Copy link
Contributor Author

sevagh commented Oct 19, 2020

Actually, that worked. This is the final change I made (+ make assets && make build):

$ git diff --cached pkg/ui/templates/rules.html
diff --git a/pkg/ui/templates/rules.html b/pkg/ui/templates/rules.html
index 41bb9083..01270ff4 100644
--- a/pkg/ui/templates/rules.html
+++ b/pkg/ui/templates/rules.html
@@ -10,8 +10,8 @@
         <thead>
           <tr>
             <td colspan="3"><h2><a href="#{{reReplaceAll "([^a-zA-Z0-9])" "$1" .Name}}" name="{{reReplaceAll "([^a-zA-Z0-9])" "$1" .Name}}">{{.Name}}</h2></td>
-            <td><h2>{{if .GetEvaluationTimestamp.IsZero}}Never{{else}}{{since .GetEvaluationTimestamp}} ago{{end}}</h2></td>
-            <td><h2>{{humanizeDuration .GetEvaluationDuration.Seconds}}</h2></td>
+            <td><h2>{{if .GetLastEvaluation.IsZero}}Never{{else}}{{since .GetLastEvaluation}} ago{{end}}</h2></td>
+            <td><h2>{{humanizeDuration .GetEvaluationTime.Seconds}}</h2></td>
           </tr>
         </thead>
         <tbody>

Can anyone who knows the code better confirm that these lines don't need to be changed? allenmqcymp@26ef1dc#diff-f46df6e62ca9bd8a2374a0b3431590f859f6766e73be74c5e93ab86a42108886L39-L41

@onprem
Copy link
Member

onprem commented Oct 19, 2020

Looking at https://github.com/prometheus/prometheus/blob/master/rules/recording.go#L177 I think that we don't need to change anything on line 39 and 41. What you did seems correct, we only need to change those two lines.

@allenmqcymp
Copy link

Cool. @sevagh if you want to submit a PR fixing it, that's fine by me since you ended up testing. @prmsrswt thanks for the help. Will try look for another issue

@sevagh
Copy link
Contributor Author

sevagh commented Oct 20, 2020

As soon as I get my other open PR merged, I'll open one for this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants