• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang prometheus.MustRegister函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/prometheus/client_golang/prometheus.MustRegister函数的典型用法代码示例。如果您正苦于以下问题:Golang MustRegister函数的具体用法?Golang MustRegister怎么用?Golang MustRegister使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MustRegister函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Metrics

// Metrics registers the DNS metrics to Prometheus, and starts the internal metrics
// server if the environment variable PROMETHEUS_PORT is set.
func Metrics() error {
	// We do this in a function instead of using var + init(), because we want to
	// able to set Namespace and/or Subsystem.
	if Port == "" {
		return nil
	}

	_, err := strconv.Atoi(Port)
	if err != nil {
		fmt.Errorf("bad port for prometheus: %s", Port)
	}

	defineMetrics()

	prometheus.MustRegister(requestCount)
	prometheus.MustRegister(requestDuration)
	prometheus.MustRegister(responseSize)
	prometheus.MustRegister(errorCount)
	prometheus.MustRegister(cacheMiss)

	http.Handle(Path, prometheus.Handler())
	go func() {
		fmt.Errorf("%s", http.ListenAndServe(":"+Port, nil))
	}()
	return nil
}
开发者ID:40a,项目名称:bootkube,代码行数:28,代码来源:metrics.go


示例2: init

func init() {
	prometheus.MustRegister(cpuUsage)
	prometheus.MustRegister(memUsage)
	prometheus.MustRegister(deviceCount)
	prometheus.MustRegister(serverCount)
	prometheus.MustRegister(threadCount)
}
开发者ID:carriercomm,项目名称:pritunl-monitor,代码行数:7,代码来源:prometheus.go


示例3: New

func New(configFile string) (e exporter, err error) {

	e = exporter{
		configFile: configFile,
		Metrics:    map[string]*prometheus.GaugeVec{},
		scrapeDuration: prometheus.NewSummaryVec(
			prometheus.SummaryOpts{
				Namespace: namespace,
				Name:      "scrape_duration_seconds",
				Help:      "gmond_exporter: Duration of a scrape job.",
			},
			[]string{"endpoint", "result"},
		),
		metricsUpdated: prometheus.NewGaugeVec(
			prometheus.GaugeOpts{
				Namespace: namespace,
				Name:      "metrics_updated_count",
				Help:      "gmond_exporter: Number of metrics updated.",
			},
			[]string{"endpoint"},
		),
		metricsExported: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "metrics_exported_count",
			Help:      "gmond_exporter: Number of metrics exported.",
		}),
		configChan:            make(chan config),
		listeningAddress:      ":8080",
		gangliaScrapeInterval: 60 * time.Second,
	}

	conf, err := e.readConfig()
	if err != nil {
		return e, fmt.Errorf("Couldn't read config: %s", err)
	}
	e.conf = conf

	if conf.ListeningAddress != "" {
		e.listeningAddress = conf.ListeningAddress
	}
	if conf.GangliaScrapeInterval != 0 {
		e.gangliaScrapeInterval = time.Duration(conf.GangliaScrapeInterval) * time.Second
	}

	prometheus.MustRegister(e.scrapeDuration)
	prometheus.MustRegister(e.metricsUpdated)
	prometheus.MustRegister(e.metricsExported)
	debug("Registered internal metrics")

	sig := make(chan os.Signal, 1)
	signal.Notify(sig, syscall.SIGHUP)
	go func() {
		for _ = range sig {
			e.reloadConfig() // sends a new config to configChan
		}
	}()

	go e.serveStatus()
	return e, nil
}
开发者ID:prometheus-junkyard,项目名称:gmond_exporter,代码行数:60,代码来源:exporter.go


示例4: Register

// Register registers all metrics to Prometheus with
// respect to the RequestLatency.
func Register() {
	// Register the metrics.
	registerMetrics.Do(func() {
		prometheus.MustRegister(RequestLatency)
		prometheus.MustRegister(RequestResult)
	})
}
开发者ID:40a,项目名称:bootkube,代码行数:9,代码来源:metrics.go


示例5: init

func init() {
	prometheus.MustRegister(leaderGauge)
	prometheus.MustRegister(engineTaskCount)
	prometheus.MustRegister(engineTaskFailureCount)
	prometheus.MustRegister(engineReconcileCount)
	prometheus.MustRegister(engineReconcileFailureCount)
}
开发者ID:jonboulle,项目名称:fleet,代码行数:7,代码来源:metrics.go


示例6: init

func init() {
	prometheus.MustRegister(sentBytes)
	prometheus.MustRegister(receivedBytes)
	prometheus.MustRegister(sentFailures)
	prometheus.MustRegister(recvFailures)
	prometheus.MustRegister(rtts)
}
开发者ID:nhr,项目名称:origin,代码行数:7,代码来源:metrics.go


示例7: init

func init() {
	prometheus.MustRegister(promErrorsTotal)
	prometheus.MustRegister(promCacheHitsTotal)
	prometheus.MustRegister(promCacheQueriesTotal)
	prometheus.MustRegister(promQueryDurationMilliseconds)
	prometheus.MustRegister(promConcurrentLockVAFV)
}
开发者ID:robinjha,项目名称:clair,代码行数:7,代码来源:pgsql.go


示例8: init

func init() {
	prometheus.MustRegister(readCounter)
	prometheus.MustRegister(writeCounter)
	prometheus.MustRegister(expireCounter)
	prometheus.MustRegister(watchRequests)
	prometheus.MustRegister(watcherCount)
}
开发者ID:CliffYuan,项目名称:etcd,代码行数:7,代码来源:metrics.go


示例9: main

func main() {
	flag.Parse()
	if *consumeTime < 1 {
		log.Fatal("consume time should be >0")
	}

	resp, err := http.Get(fmt.Sprintf("http://%s/varz", *natsaddr))
	if err != nil {
		log.Fatal(err)
	}

	if resp.StatusCode != http.StatusOK {
		log.Fatalf("expected statuscode 200 got %v", resp.StatusCode)
	}

	resp.Body.Close()

	prometheus.MustRegister(bytesCounter)
	prometheus.MustRegister(messageCounter)
	prometheus.MustRegister(connections)
	prometheus.MustRegister(slowConsumers)

	go consume()

	http.Handle("/metrics", prometheus.Handler())
	if err := http.ListenAndServe(*addr, nil); err != nil {
		log.Fatal(err)
	}
}
开发者ID:SLASH2NL,项目名称:nats-prometheus,代码行数:29,代码来源:main.go


示例10: init

func init() {
	prometheus.MustRegister(targetIntervalLength)
	prometheus.MustRegister(targetSkippedScrapes)
	prometheus.MustRegister(targetReloadIntervalLength)
	prometheus.MustRegister(targetSyncIntervalLength)
	prometheus.MustRegister(targetScrapePoolSyncsCounter)
}
开发者ID:yershalom,项目名称:prometheus,代码行数:7,代码来源:scrape.go


示例11: init

func init() {
	prometheus.MustRegister(cmdCounter)
	prometheus.MustRegister(cmdFailedCounter)
	prometheus.MustRegister(cmdDuration)
	prometheus.MustRegister(cmdFailedDuration)
	prometheus.MustRegister(requestDuration)
}
开发者ID:jmptrader,项目名称:tidb,代码行数:7,代码来源:metrics.go


示例12: init

func init() {
	prometheus.MustRegister(failedLookfor)
	prometheus.MustRegister(successfulLookfor)
	prometheus.MustRegister(successfulGarbageCollect)
	prometheus.MustRegister(successfulSanityFeed)
	prometheus.MustRegister(lastSanityCheckStarted)
}
开发者ID:jamessan,项目名称:dcs,代码行数:7,代码来源:feeder.go


示例13: main

func main() {
	flag.Parse()

	handler := prometheus.Handler()
	prometheus.MustRegister(watts)
	prometheus.MustRegister(updatesPerPost)
	prometheus.MustRegister(voltage)

	http.Handle(*metricsPath, handler)
	http.HandleFunc("/activate", activateHandler)
	http.HandleFunc("/post", postHandler)
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte(`<html>
			<head><title>TED Exporter</title></head>
			<body>
			<h1>TED Exporter</h1>
			<p><a href="` + *metricsPath + `">Metrics</a></p>
			</body>
			</html>`))
	})

	log.Infof("Starting ted_exporter v%s at %s", Version, *listenAddress)
	err := http.ListenAndServe(*listenAddress, nil)
	if err != nil {
		log.Fatal(err)
	}
}
开发者ID:wrong-kendall,项目名称:ted_exporter,代码行数:27,代码来源:ted_exporter.go


示例14: registerProbes

func registerProbes() {
	for _, probe := range config.Probes {
		probeURL, _ := url.Parse(probe)

		monitors := &probeMonitor{}
		monitors.Expires = prometheus.NewGauge(prometheus.GaugeOpts{
			Name: "certcheck_expires",
			Help: "Expiration date in unix timestamp (UTC)",
			ConstLabels: prometheus.Labels{
				"host": probeURL.Host,
			},
		})
		monitors.IsValid = prometheus.NewGauge(prometheus.GaugeOpts{
			Name: "certcheck_valid",
			Help: "Validity of the certificate (0/1)",
			ConstLabels: prometheus.Labels{
				"host": probeURL.Host,
			},
		})

		prometheus.MustRegister(monitors.Expires)
		prometheus.MustRegister(monitors.IsValid)

		probeMonitors[probeURL.Host] = monitors
	}
}
开发者ID:Luzifer,项目名称:promcertcheck,代码行数:26,代码来源:main.go


示例15: init

// Register metrics to Prometheus
func init() {
	prometheus.MustRegister(channelsTotal)
	prometheus.MustRegister(connectionsTotal)
	prometheus.MustRegister(queuesTotal)
	prometheus.MustRegister(exchangesTotal)
	prometheus.MustRegister(consumersTotal)
}
开发者ID:tomstaijen,项目名称:rabbitmq_exporter,代码行数:8,代码来源:main.go


示例16: setupMetrics

func setupMetrics(ctx *grader.Context) {
	for _, gauge := range gauges {
		prometheus.MustRegister(gauge)
	}
	for _, counter := range counters {
		prometheus.MustRegister(counter)
	}
	for _, summary := range summaries {
		prometheus.MustRegister(summary)
	}

	metricsMux := http.NewServeMux()
	metricsMux.Handle("/metrics", prometheus.Handler())
	go func() {
		addr := fmt.Sprintf(":%d", ctx.Config.Metrics.Port)
		ctx.Log.Error(
			"http listen and serve",
			"err", http.ListenAndServe(addr, metricsMux),
		)
	}()
	go func() {
		gaugesUpdate()
		time.Sleep(time.Duration(1) * time.Minute)
	}()
}
开发者ID:lhchavez,项目名称:quark,代码行数:25,代码来源:metrics.go


示例17: initMonitoring

func initMonitoring() {
	prometheus.MustRegister(UserCount)
	prometheus.MustRegister(MessageSentCount)
	prometheus.MustRegister(MessageReadCount)
	prometheus.MustRegister(PublicMessageCount)
	prometheus.MustRegister(DirectMessageCount)
}
开发者ID:desmondmcnamee,项目名称:populr_go_api,代码行数:7,代码来源:monitor.go


示例18: NewMiddleware

// NewMiddleware returns a new prometheus Middleware handler.
func NewMiddleware(name string, buckets ...float64) *Middleware {
	var m Middleware
	m.reqs = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name:        reqsName,
			Help:        "How many HTTP requests processed, partitioned by status code, method and HTTP path.",
			ConstLabels: prometheus.Labels{"service": name},
		},
		[]string{"code", "method", "path"},
	)
	prometheus.MustRegister(m.reqs)

	if len(buckets) == 0 {
		buckets = dflBuckets
	}
	m.latency = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:        latencyName,
		Help:        "How long it took to process the request, partitioned by status code, method and HTTP path.",
		ConstLabels: prometheus.Labels{"service": name},
		Buckets:     buckets,
	},
		[]string{"code", "method", "path"},
	)
	prometheus.MustRegister(m.latency)
	return &m
}
开发者ID:zbindenren,项目名称:negroni-prometheus,代码行数:27,代码来源:middleware.go


示例19: init

func init() {
	prometheus.MustRegister(watchersCoalescing)
	prometheus.MustRegister(eventsCoalescing)
	prometheus.MustRegister(cacheKeys)
	prometheus.MustRegister(cacheHits)
	prometheus.MustRegister(cachedMisses)
}
开发者ID:hongchaodeng,项目名称:etcd,代码行数:7,代码来源:metrics.go


示例20: init

func init() {
	prometheus.MustRegister(backupDuration)
	prometheus.MustRegister(backupSeen)
	prometheus.MustRegister(backupSize)
	prometheus.MustRegister(backupsTotal)
	prometheus.MustRegister(backupsFailed)
}
开发者ID:discordianfish,项目名称:byte-piper,代码行数:7,代码来源:main.go



注:本文中的github.com/prometheus/client_golang/prometheus.MustRegister函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang prometheus.NewCounter函数代码示例发布时间:2022-05-28
下一篇:
Golang prometheus.MustNewConstMetric函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap