本文整理匯總了Golang中github.com/prometheus/pushgateway/storage.MetricStore.GetMetricFamiliesMap方法的典型用法代碼示例。如果您正苦於以下問題:Golang MetricStore.GetMetricFamiliesMap方法的具體用法?Golang MetricStore.GetMetricFamiliesMap怎麽用?Golang MetricStore.GetMetricFamiliesMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/prometheus/pushgateway/storage.MetricStore
的用法示例。
在下文中一共展示了MetricStore.GetMetricFamiliesMap方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Status
// Status serves the status page.
func Status(
ms storage.MetricStore,
assetFunc func(string) ([]byte, error),
flags map[string]string,
) func(http.ResponseWriter, *http.Request) {
birth := time.Now()
return func(w http.ResponseWriter, _ *http.Request) {
t := template.New("status")
t.Funcs(template.FuncMap{
"value": func(f float64) string {
return strconv.FormatFloat(f, 'f', -1, 64)
},
})
tpl, err := assetFunc("template.html")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
_, err = t.Parse(string(tpl))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
buildInfo := map[string]string{
"version": version.Version,
"revision": version.Revision,
"branch": version.Branch,
"buildUser": version.BuildUser,
"buildDate": version.BuildDate,
"goVersion": version.GoVersion,
}
d := &data{
MetricGroups: ms.GetMetricFamiliesMap(),
Flags: flags,
BuildInfo: buildInfo,
Birth: birth,
}
err = t.Execute(w, d)
if err != nil {
// Hack to get a visible error message right at the top.
fmt.Fprintf(w, `<div id="template-error" class="alert alert-danger">Error executing template: %s</div>`, html.EscapeString(err.Error()))
fmt.Fprintln(w, `<script>$("#template-error").prependTo("body")</script>`)
}
}
}