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

Golang prometheus.NewGauge函数代码示例

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

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



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

示例1: NewRethinkDBExporter

func NewRethinkDBExporter(addr, auth, clusterName, namespace string) *Exporter {
	return &Exporter{
		addrs:       strings.Split(addr, ","),
		auth:        auth,
		clusterName: clusterName,
		namespace:   namespace,

		duration: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "exporter_last_scrape_duration_seconds",
			Help:      "The last scrape duration.",
		}),
		totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{
			Namespace: namespace,
			Name:      "exporter_scrapes_total",
			Help:      "Current total rethinkdb scrapes.",
		}),
		scrapeError: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "exporter_last_scrape_error",
			Help:      "The last scrape error status.",
		}),
		metrics: map[string]*prometheus.GaugeVec{},
	}
}
开发者ID:concur,项目名称:rethinkdb_exporter,代码行数:25,代码来源:rethinkdb_exporter.go


示例2: NewExporter

// NewExporter returns a new PostgreSQL exporter for the provided DSN.
func NewExporter(dsn string, userQueriesPath string) *Exporter {
	return &Exporter{
		dsn:             dsn,
		userQueriesPath: userQueriesPath,
		duration: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: exporter,
			Name:      "last_scrape_duration_seconds",
			Help:      "Duration of the last scrape of metrics from PostgresSQL.",
		}),
		totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: exporter,
			Name:      "scrapes_total",
			Help:      "Total number of times PostgresSQL was scraped for metrics.",
		}),
		error: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: exporter,
			Name:      "last_scrape_error",
			Help:      "Whether the last scrape of metrics from PostgreSQL resulted in an error (1 for error, 0 for success).",
		}),
		variableMap:    nil,
		metricMap:      nil,
		queryOverrides: nil,
	}
}
开发者ID:wrouesnel,项目名称:postgres_exporter,代码行数:28,代码来源:postgres_exporter.go


示例3: 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


示例4: NewRedisExporter

func NewRedisExporter(addrs []string, namespace string) *Exporter {
	e := Exporter{
		addrs:     addrs,
		namespace: namespace,

		duration: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "exporter_last_scrape_duration_seconds",
			Help:      "The last scrape duration.",
		}),
		totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{
			Namespace: namespace,
			Name:      "exporter_scrapes_total",
			Help:      "Current total redis scrapes.",
		}),
		scrapeErrors: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "exporter_last_scrape_error",
			Help:      "The last scrape error status.",
		}),
	}

	e.initGauges()
	return &e
}
开发者ID:DavidWittman,项目名称:redis_exporter,代码行数:25,代码来源:redis_exporter.go


示例5: NewClusterUsageCollector

// NewClusterUsageCollector creates and returns the reference to ClusterUsageCollector
// and internally defines each metric that display cluster stats.
func NewClusterUsageCollector(conn Conn) *ClusterUsageCollector {
	return &ClusterUsageCollector{
		conn: conn,

		GlobalCapacity: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: cephNamespace,
			Name:      "cluster_capacity_bytes",
			Help:      "Total capacity of the cluster",
		}),
		UsedCapacity: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: cephNamespace,
			Name:      "cluster_used_bytes",
			Help:      "Capacity of the cluster currently in use",
		}),
		AvailableCapacity: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: cephNamespace,
			Name:      "cluster_available_bytes",
			Help:      "Available space within the cluster",
		}),
		Objects: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: cephNamespace,
			Name:      "cluster_objects",
			Help:      "No. of rados objects within the cluster",
		}),
	}
}
开发者ID:XS4ALL,项目名称:ceph_exporter,代码行数:28,代码来源:cluster_usage.go


示例6: startMonitoring

func startMonitoring(addr string) {

	var redisActiveConn = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "redis_active_conn",
		Help: "Number of active redis connections.",
	})
	prometheus.MustRegister(redisActiveConn)

	var redisMaxConn = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "redis_max_conn",
		Help: "Maximum number of redis connections.",
	})
	prometheus.MustRegister(redisMaxConn)

	http.Handle("/metrics", prometheus.Handler())
	redisMaxConn.Set(float64(redisPool.MaxActive))
	go func() {
		tick := time.NewTicker(1 * time.Second)
		for range tick.C {
			if redisPool == nil {
				redisActiveConn.Set(0)
			} else {
				redisActiveConn.Set(float64(redisPool.ActiveCount()))
			}
		}
	}()
	err := http.ListenAndServe(addr, nil)
	if err != nil {
		lg.Fatal(err)
	}
}
开发者ID:thomasf,项目名称:alkasir,代码行数:31,代码来源:central.go


示例7: NewExporter

// NewExporter returns a new MySQL exporter for the provided DSN.
func NewExporter(dsn string) *Exporter {
	return &Exporter{
		dsn: dsn,
		duration: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: exporter,
			Name:      "last_scrape_duration_seconds",
			Help:      "Duration of the last scrape of metrics from MySQL.",
		}),
		totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: exporter,
			Name:      "scrapes_total",
			Help:      "Total number of times MySQL was scraped for metrics.",
		}),
		scrapeErrors: prometheus.NewCounterVec(prometheus.CounterOpts{
			Namespace: namespace,
			Subsystem: exporter,
			Name:      "scrape_errors_total",
			Help:      "Total number of times an error occurred scraping a MySQL.",
		}, []string{"collector"}),
		error: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: exporter,
			Name:      "last_scrape_error",
			Help:      "Whether the last scrape of metrics from MySQL resulted in an error (1 for error, 0 for success).",
		}),
		mysqldUp: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "up",
			Help:      "Whether the MySQL server is up.",
		}),
	}
}
开发者ID:roman-vynar,项目名称:mysqld_exporter,代码行数:35,代码来源:mysqld_exporter.go


示例8: NewPostgreSQLExporter

func NewPostgreSQLExporter(dsn string, cq []metrics.CustomQuery) *Exporter {
	e := &Exporter{
		dsn: dsn,
		metrics: []metrics.Collection{
			metrics.NewBufferMetrics(),
			metrics.NewDBMetrics(strings.Split(*databases, ",")),
			metrics.NewSlowQueryMetrics(*slow),
			metrics.NewCustomQueryMetrics(cq),
		},
		totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{
			Namespace: namespace,
			Name:      "exporter_scrapes_total",
			Help:      "Current total postgresql scrapes.",
		}),
		duration: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "exporter_last_scrape_duration_seconds",
			Help:      "The last scrape duration.",
		}),
		errors: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "exporter_last_scrape_error",
			Help:      "The last scrape error status.",
		}),
	}

	if len(*tables) > 0 {
		e.metrics = append(e.metrics, metrics.NewTableMetrics(strings.Split(*tables, ",")))
	}

	return e
}
开发者ID:mc2soft,项目名称:postgresql_exporter,代码行数:32,代码来源:postgresql_exporter.go


示例9: initPrometheusMetrics

func initPrometheusMetrics() {
	TotalClientCounter = stat.NewGauge(stat.GaugeOpts{
		Name: "total_clients",
		Help: "Total number of connected clients",
	})

	TotalNodes = stat.NewGauge(stat.GaugeOpts{
		Name: "meshnodes_total",
		Help: "Total number of Nodes",
	})

	TotalNodeTrafficRx = stat.NewCounter(stat.CounterOpts{
		Name: "total_traffic_rx",
		Help: "Total accumulated received traffic as reported by Nodes",
	})

	TotalNodeTrafficTx = stat.NewCounter(stat.CounterOpts{
		Name: "total_traffic_tx",
		Help: "Total accumulated transmitted traffic as reported by Nodes",
	})

	TotalNodeMgmtTrafficRx = stat.NewCounter(stat.CounterOpts{
		Name: "total_traffic_mgmt_rx",
		Help: "Total accumulated received management traffic as reported by Nodes",
	})

	TotalNodeMgmtTrafficTx = stat.NewCounter(stat.CounterOpts{
		Name: "total_traffic_mgmt_tx",
		Help: "Total accumulated transmitted management traffic as reported by Nodes",
	})

	OnlineNodes = stat.NewGauge(stat.GaugeOpts{
		Name: "meshnodes_online_total",
		Help: "All online nodes",
	})

	NodesTrafficRx = stat.NewCounterVec(stat.CounterOpts{
		Name: "meshnode_traffic_rx",
		Help: "Transmitted traffic from nodes",
	}, append(nodeLabels, "type"))

	NodesTrafficTx = stat.NewCounterVec(stat.CounterOpts{
		Name: "meshnode_traffic_tx",
		Help: "Received traffic on nodes",
	}, append(nodeLabels, "type"))

	NodesUptime = stat.NewCounterVec(stat.CounterOpts{
		Name: "meshnode_uptime",
		Help: "Uptime of meshnodes",
	}, nodeLabels)

	NodesClients = stat.NewGaugeVec(stat.GaugeOpts{
		Name: "meshnode_clients",
		Help: "Clients on single meshnodes",
	}, nodeLabels)
}
开发者ID:tantive,项目名称:node-informant,代码行数:56,代码来源:prometheus.go


示例10: NewMgoStatsCollector

// NewMgoStatsCollector creates a MgoStatsCollector for the given
// namespace (which may be empty).
func NewMgoStatsCollector(namespace string) *MgoStatsCollector {
	// Enable stats in the mgo driver.
	mgo.SetStats(true)
	return &MgoStatsCollector{
		clusters: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "mgo",
			Name:      "clusters",
			Help:      "Number of alive clusters.",
		}),
		masterConns: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "mgo",
			Name:      "master_connections",
			Help:      "Number of master connections.",
		}),
		slaveConns: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "mgo",
			Name:      "slave_connections",
			Help:      "Number of slave connections.",
		}),
		sentOps: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "mgo",
			Name:      "sent_operations",
			Help:      "Number of operations sent.",
		}),
		receivedOps: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "mgo",
			Name:      "received_operations",
			Help:      "Number of operations received.",
		}),
		receivedDocs: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "mgo",
			Name:      "received_documents",
			Help:      "Number of documents received.",
		}),
		socketsAlive: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "mgo",
			Name:      "sockets_alive",
			Help:      "Number of alive sockets.",
		}),
		socketsInUse: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "mgo",
			Name:      "sockets_in_use",
			Help:      "Number of in use sockets.",
		}),
		socketRefs: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Subsystem: "mgo",
			Name:      "socket_references",
			Help:      "Number of references to sockets.",
		}),
	}
}
开发者ID:cloud-green,项目名称:monitoring,代码行数:62,代码来源:mgo.go


示例11: defineDnsmasqMetrics

func defineDnsmasqMetrics(options *Options) {
	const dnsmasqSubsystem = "dnsmasq"

	gauges[dnsmasq.CacheHits] = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: options.PrometheusNamespace,
			Subsystem: dnsmasqSubsystem,
			Name:      "hits",
			Help:      "Number of DNS cache hits (from start of process)",
		})
	gauges[dnsmasq.CacheMisses] = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: options.PrometheusNamespace,
			Subsystem: dnsmasqSubsystem,
			Name:      "misses",
			Help:      "Number of DNS cache misses (from start of process)",
		})
	gauges[dnsmasq.CacheEvictions] = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: options.PrometheusNamespace,
			Subsystem: dnsmasqSubsystem,
			Name:      "evictions",
			Help:      "Counter of DNS cache evictions (from start of process)",
		})
	gauges[dnsmasq.CacheInsertions] = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: options.PrometheusNamespace,
			Subsystem: dnsmasqSubsystem,
			Name:      "insertions",
			Help:      "Counter of DNS cache insertions (from start of process)",
		})
	gauges[dnsmasq.CacheSize] = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: options.PrometheusNamespace,
			Subsystem: dnsmasqSubsystem,
			Name:      "max_size",
			Help:      "Maximum size of the DNS cache",
		})

	for i := range gauges {
		prometheus.MustRegister(gauges[i])
	}

	errorsCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: options.PrometheusNamespace,
			Subsystem: dnsmasqSubsystem,
			Name:      "errors",
			Help:      "Number of errors that have occurred getting metrics",
		})
	prometheus.MustRegister(errorsCounter)
}
开发者ID:kubernetes,项目名称:contrib,代码行数:52,代码来源:metrics.go


示例12: NewGauge

func (n *Namespace) NewGauge(name, help string, unit Unit) Gauge {
	g := &gauge{
		pg: prometheus.NewGauge(n.newGaugeOpts(name, help, unit)),
	}
	n.addMetric(g)
	return g
}
开发者ID:Mic92,项目名称:docker,代码行数:7,代码来源:namespace.go


示例13: metricsInit

func metricsInit(servicename string) *syndicateMetrics {
	m := syndicateMetrics{}
	m.managedNodes = prometheus.NewGauge(prometheus.GaugeOpts{
		Name:        "ManagedNodes",
		Help:        "Current number of nodes managed.",
		ConstLabels: prometheus.Labels{"servicename": servicename},
	})
	m.subscriberNodes = prometheus.NewGauge(prometheus.GaugeOpts{
		Name:        "SubscriberNodes",
		Help:        "Current number of unmanaged nodes subscribed for ring changes.",
		ConstLabels: prometheus.Labels{"servicename": servicename},
	})
	prometheus.Register(m.managedNodes)
	prometheus.Register(m.subscriberNodes)
	return &m
}
开发者ID:wreese,项目名称:cfs-binary-release,代码行数:16,代码来源:syndicate.go


示例14: Update

func (c *netStatCollector) Update(ch chan<- prometheus.Metric) (err error) {
	netStats, err := getNetStats()
	if err != nil {
		return fmt.Errorf("couldn't get netstats: %s", err)
	}
	for protocol, protocolStats := range netStats {
		for name, value := range protocolStats {
			key := protocol + "_" + name
			if _, ok := c.metrics[key]; !ok {
				c.metrics[key] = prometheus.NewGauge(
					prometheus.GaugeOpts{
						Namespace: Namespace,
						Subsystem: netStatsSubsystem,
						Name:      key,
						Help:      fmt.Sprintf("%s %s from /proc/net/netstat.", protocol, name),
					},
				)
			}
			v, err := strconv.ParseFloat(value, 64)
			if err != nil {
				return fmt.Errorf("invalid value %s in netstats: %s", value, err)
			}
			c.metrics[key].Set(v)
		}
	}
	for _, m := range c.metrics {
		m.Collect(ch)
	}
	return err
}
开发者ID:fin09pcap,项目名称:node_exporter,代码行数:30,代码来源:netstat.go


示例15: TestSensorRecordGauge

func TestSensorRecordGauge(t *testing.T) {
	testServer := httptest.NewServer(prometheus.UninstrumentedHandler())
	defer testServer.Close()

	sensor := &Sensor{
		Type: "gauge",
		collector: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: "telemetry",
			Subsystem: "sensors",
			Name:      "TestSensorRecordGauge",
			Help:      "help",
		})}

	prometheus.MustRegister(sensor.collector)
	sensor.record("1.2")
	resp := getFromTestServer(t, testServer)
	if strings.Count(resp, "telemetry_sensors_TestSensorRecordGauge 1.2") != 1 {
		t.Fatalf("Failed to get match for sensor in response: %s", resp)
	}
	sensor.record("2.3")
	resp = getFromTestServer(t, testServer)
	if strings.Count(resp, "telemetry_sensors_TestSensorRecordGauge 2.3") != 1 {
		t.Fatalf("Failed to get match for sensor in response: %s", resp)
	}
}
开发者ID:joyent,项目名称:containerpilot,代码行数:25,代码来源:sensors_test.go


示例16: Update

func (c *fileFDStatCollector) Update(ch chan<- prometheus.Metric) (err error) {
	fileFDStat, err := getFileFDStats(procFilePath("sys/fs/file-nr"))
	if err != nil {
		return fmt.Errorf("couldn't get file-nr: %s", err)
	}
	for name, value := range fileFDStat {
		if _, ok := c.metrics[name]; !ok {
			c.metrics[name] = prometheus.NewGauge(
				prometheus.GaugeOpts{
					Namespace: Namespace,
					Subsystem: fileFDStatSubsystem,
					Name:      name,
					Help:      fmt.Sprintf("File descriptor statistics: %s.", name),
				},
			)
		}
		v, err := strconv.ParseFloat(value, 64)
		if err != nil {
			return fmt.Errorf("invalid value %s in file-nr: %s", value, err)
		}
		c.metrics[name].Set(v)
	}
	for _, m := range c.metrics {
		m.Collect(ch)
	}
	return err
}
开发者ID:xuzhaokui,项目名称:node_exporter,代码行数:27,代码来源:filefd_linux.go


示例17: 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


示例18: main

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)
	flag.Parse()

	if !*runBackup && !*runSync {
		log.Fatal("Neither -backup nor -sync enabled, nothing to do.")
	}

	storageList := strings.Split(*storageHosts, ",")
	if len(storageList) > 2 {
		log.Fatal("More than 2 -storage_hosts are not supported. Please send a patch to fix.")
	}

	if *runBackup {
		backup(storageList)
	}

	if *runSync {
		sync(storageList)
	}

	lastSuccess := prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "last_success",
		Help: "Timestamp of the last success",
	})
	prometheus.MustRegister(lastSuccess)
	lastSuccess.Set(float64(time.Now().Unix()))

	if err := prometheus.Push("dornroeschen", "dornroeschen", *pushGateway); err != nil {
		log.Fatal(err)
	}
}
开发者ID:stapelberg,项目名称:zkj-nas-tools,代码行数:32,代码来源:dornröschen.go


示例19: Update

func (c *sockStatCollector) Update(ch chan<- prometheus.Metric) (err error) {
	sockStats, err := getSockStats(procFilePath("net/sockstat"))
	if err != nil {
		return fmt.Errorf("couldn't get sockstats: %s", err)
	}
	for protocol, protocolStats := range sockStats {
		for name, value := range protocolStats {
			key := protocol + "_" + name
			if _, ok := c.metrics[key]; !ok {
				c.metrics[key] = prometheus.NewGauge(
					prometheus.GaugeOpts{
						Namespace: Namespace,
						Subsystem: sockStatSubsystem,
						Name:      key,
						Help:      fmt.Sprintf("Number of %s sockets in state %s.", protocol, name),
					},
				)
			}
			v, err := strconv.ParseFloat(value, 64)
			if err != nil {
				return fmt.Errorf("invalid value %s in sockstats: %s", value, err)
			}
			c.metrics[key].Set(v)
		}
	}
	for _, m := range c.metrics {
		m.Collect(ch)
	}
	return err
}
开发者ID:juergenhoetzel,项目名称:node_exporter,代码行数:30,代码来源:sockstat_linux.go


示例20: Describe

func (c miniCollector) Describe(ch chan<- *prometheus.Desc) {
	prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "fake",
		Subsystem: "fake",
		Name:      "fake",
		Help:      "fake",
	}).Describe(ch)
}
开发者ID:juergenhoetzel,项目名称:node_exporter,代码行数:8,代码来源:ipvs_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang prometheus.NewGaugeFunc函数代码示例发布时间:2022-05-28
下一篇:
Golang prometheus.NewDesc函数代码示例发布时间: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