本文整理汇总了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>`)
}
}
}