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

Moving location of statuszTmpl #206

Merged
merged 9 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM gcr.io/distroless/static:latest
LABEL maintainer "Stackdriver Engineering <engineering@stackdriver.com>"

COPY stackdriver-prometheus-sidecar /bin/stackdriver-prometheus-sidecar
COPY cmd/stackdriver-prometheus-sidecar/statusz-tmpl.html /statusz-tmpl.html

EXPOSE 9091
ENTRYPOINT [ "/bin/stackdriver-prometheus-sidecar" ]
2 changes: 1 addition & 1 deletion cmd/stackdriver-prometheus-sidecar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ type fileConfig struct {
}

// Note: When adding a new config field, consider adding it to
// statusz-tmpl.html
// const statusHtml in statusz.go
type mainConfig struct {
ConfigFilename string
ProjectIDResource string
Expand Down
124 changes: 0 additions & 124 deletions cmd/stackdriver-prometheus-sidecar/statusz-tmpl.html

This file was deleted.

130 changes: 129 additions & 1 deletion cmd/stackdriver-prometheus-sidecar/statusz.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,137 @@ import (
"github.com/prometheus/common/version"
)

const(
statuszHtml = `
jkohen marked this conversation as resolved.
Show resolved Hide resolved
<!DOCTYPE html>
<html>
<head>
<title>Status for {{.ServerName}}</title>
<style>
body {
font-family: sans-serif;
}
h1 {
clear: both;
width: 100%;
text-align: center;
font-size: 120%;
background: #eef;
}
h2 {
font-size: 110%;
}
.lefthand {
float: left;
width: 80%;
}
.righthand {
text-align: right;
}
td, th {
background-color: rgba(0, 0, 0, 0.05);
}
th {
text-align: left;
}
</style>
</head>

<body>
<h1>Status for {{.ServerName}}</h1>

<div>
<div class="lefthand">
Started: {{.StartTime}}<br>
Up {{.Uptime}}<br>
Version: {{.VersionInfo}}<br>
Build context: {{.BuildContext}}<br>
Host details: {{.Uname}}<br>
FD limits: {{.FdLimits}}<br>
{{if (and .GKEInfo.ProjectId .GKEInfo.ClusterLocation .GKEInfo.ClusterName .PodName .NodeName .NamespaceName)}}
<p>
Pod <a href="https://console.cloud.google.com/kubernetes/pod/{{.GKEInfo.ClusterLocation}}/{{.GKEInfo.ClusterName}}/{{if .NamespaceName}}{{.NamespaceName}}{{else}}default{{end}}/{{.PodName}}?project={{.GKEInfo.ProjectId}}">{{.PodName}}</a><br>
Node <a href="https://console.cloud.google.com/kubernetes/node/{{.GKEInfo.ClusterLocation}}/{{.GKEInfo.ClusterName}}/{{.NodeName}}?project={{.GKEInfo.ProjectId}}">{{.NodeName}}</a><br>
Cluster <a href="https://console.cloud.google.com/kubernetes/clusters/details/{{.GKEInfo.ClusterLocation}}/{{.GKEInfo.ClusterName}}?project={{.GKEInfo.ProjectId}}">{{.GKEInfo.ClusterName}}</a>
</p>
{{end}}
</div>
<div class="righthand">
View <a href="/metrics">metrics</a><br>
</div>
</div>

<h1>Parsed configuration</h1>

{{with .Config}}

<table>
<tr><th>Config filename</th><td>{{.ConfigFilename}}</td></tr>
<tr><th>Filters</th><td>{{.Filters}}</td></tr>
<tr><th>Filter sets</th><td>{{.Filtersets}}</td></tr>
<tr><th>Generic labels: location</th><td>{{.GenericLabels.Location}}</td></tr>
<tr><th>Generic labels: namespace</th><td>{{.GenericLabels.Namespace}}</td></tr>
<tr><th>Kubernetes labels: cluster name</th><td>{{.KubernetesLabels.ClusterName}}</td></tr>
<tr><th>Kubernetes labels: location</th><td>{{.KubernetesLabels.Location}}</td></tr>
<tr><th>Listen address</th><td>{{.ListenAddress}}</td></tr>
<tr><th>Log level</th><td>{{.PromlogConfig.Level}}</td></tr>
<tr><th>Log format</th><td>{{.PromlogConfig.Format}}</td></tr>
<tr><th>Metrics prefix</th><td>{{.MetricsPrefix}}</td></tr>
<tr><th>Monitoring backends</th><td>{{.MonitoringBackends}}</td></tr>
<tr><th>Project ID resource</th><td>{{.ProjectIDResource}}</td></tr>
<tr><th>Prometheus URL</th><td>{{.PrometheusURL}}</td></tr>
<tr><th>Stackdriver address</th><td>{{.StackdriverAddress}}</td></tr>
<tr><th>Store in files directory</th><td>{{.StoreInFilesDirectory}}</td></tr>
<tr><th>Use GKE resource</th><td>{{.UseGKEResource}}</td></tr>
<tr><th>Use restricted IPs</th><td>{{.UseRestrictedIPs}}</td></tr>
<tr><th>WAL directory</th><td>{{.WALDirectory}}</td></tr>
</table>

<h2>Aggregations</h2>
{{if .Aggregations}}
<table>
<tr><th>metric</th><th>matchers</th></tr>
{{range $metric, $metricConfig := .Aggregations}}
<tr><td>{{$metric}}</td><td>{{$metricConfig.Matchers}}</td></tr>
{{end}}
</table>
{{else}}
none
{{end}}

<h2>Metric renames</h2>
{{if .MetricRenames}}
<table>
<tr><th>from</th><th>to</th></tr>
{{range $from, $to := .MetricRenames}}
<tr><td>{{$from}}</td><td>{{$to}}</td></tr>
{{end}}
</table>
{{else}}
none
{{end}}

<h2>Static metadata</h2>
{{if .StaticMetadata}}
<table>
<tr><th>metric</th><th>type</th><th>unit</th></tr>
{{range .StaticMetadata}}
<tr><td>{{.Metric}}</td><td>{{.MetricType}}</td><td>{{.ValueType}}</td></tr>
{{end}}
</table>
{{else}}
none
{{end}}

{{end}}

</body>
</html>
`
)
var (
serverStart = time.Now()
statuszTmpl = template.Must(template.ParseFiles("statusz-tmpl.html"))
statuszTmpl = template.Must(template.New("statusz-tmpl.html").Parse(statuszHtml))
)

type statuszHandler struct {
Expand Down