Skip to content

Commit

Permalink
Merge pull request #1810 from ankit1ank/ring_page
Browse files Browse the repository at this point in the history
Show ingester tokens after button click in ring status page
  • Loading branch information
bboreham authored Nov 29, 2019
2 parents 0f3143d + ed142a1 commit 241d457
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions pkg/ring/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ const tpl = `
{{ end }}
</tbody>
</table>
<br>
{{ if .ShowTokens }}
<input type="button" value="Hide Ingester Tokens" onclick="window.location.href = '/ring'" />
{{ else }}
<input type="button" value="Show Ingester Tokens" onclick="window.location.href = '/ring?tokens=true'" />
{{ end }}
<pre>{{ .Ring }}</pre>
</form>
</body>
Expand Down Expand Up @@ -129,14 +135,23 @@ func (r *Ring) ServeHTTP(w http.ResponseWriter, req *http.Request) {
})
}

tokensParam := req.URL.Query().Get("tokens")
var ringDescString string
showTokens := false
if tokensParam == "true" {
ringDescString = proto.MarshalTextString(r.ringDesc)
showTokens = true
}
if err := tmpl.Execute(w, struct {
Ingesters []interface{}
Now time.Time
Ring string
Ingesters []interface{}
Now time.Time
Ring string
ShowTokens bool
}{
Ingesters: ingesters,
Now: time.Now(),
Ring: proto.MarshalTextString(r.ringDesc),
Ingesters: ingesters,
Now: time.Now(),
Ring: ringDescString,
ShowTokens: showTokens,
}); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down

0 comments on commit 241d457

Please sign in to comment.