Skip to content

Commit ed142a1

Browse files
author
Ankit Goel
committed
Load ingester tokens only when needed in ring status page
Signed-off-by: Ankit Goel <[email protected]>
1 parent 29a309d commit ed142a1

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

pkg/ring/http.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ const tpl = `
2121
<head>
2222
<meta charset="UTF-8">
2323
<title>Cortex Ring Status</title>
24-
<script>
25-
function showIngesterTokens() {
26-
document.getElementById('ingesterTokens').style.display = "block";
27-
document.getElementById('showTokensButton').style.display = "none";
28-
}
29-
</script>
3024
</head>
3125
<body>
3226
<h1>Cortex Ring Status</h1>
@@ -64,10 +58,12 @@ const tpl = `
6458
</tbody>
6559
</table>
6660
<br>
67-
<input id="showTokensButton" type="button" name="showTokens" style="display:block" value="Show Ingester Tokens" onclick="showIngesterTokens()" />
68-
<div id="ingesterTokens" style="display:none;">
61+
{{ if .ShowTokens }}
62+
<input type="button" value="Hide Ingester Tokens" onclick="window.location.href = '/ring'" />
63+
{{ else }}
64+
<input type="button" value="Show Ingester Tokens" onclick="window.location.href = '/ring?tokens=true'" />
65+
{{ end }}
6966
<pre>{{ .Ring }}</pre>
70-
</div>
7167
</form>
7268
</body>
7369
</html>`
@@ -139,14 +135,23 @@ func (r *Ring) ServeHTTP(w http.ResponseWriter, req *http.Request) {
139135
})
140136
}
141137

138+
tokensParam := req.URL.Query().Get("tokens")
139+
var ringDescString string
140+
showTokens := false
141+
if tokensParam == "true" {
142+
ringDescString = proto.MarshalTextString(r.ringDesc)
143+
showTokens = true
144+
}
142145
if err := tmpl.Execute(w, struct {
143-
Ingesters []interface{}
144-
Now time.Time
145-
Ring string
146+
Ingesters []interface{}
147+
Now time.Time
148+
Ring string
149+
ShowTokens bool
146150
}{
147-
Ingesters: ingesters,
148-
Now: time.Now(),
149-
Ring: proto.MarshalTextString(r.ringDesc),
151+
Ingesters: ingesters,
152+
Now: time.Now(),
153+
Ring: ringDescString,
154+
ShowTokens: showTokens,
150155
}); err != nil {
151156
http.Error(w, err.Error(), http.StatusInternalServerError)
152157
return

0 commit comments

Comments
 (0)