本文整理汇总了Golang中github.com/prometheus/client_golang/prometheus.NewCounter函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCounter函数的具体用法?Golang NewCounter怎么用?Golang NewCounter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewCounter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ExampleCounter
func ExampleCounter() {
pushCounter := prometheus.NewCounter(prometheus.CounterOpts{
Name: "repository_pushes", // Note: No help string...
})
err := prometheus.Register(pushCounter) // ... so this will return an error.
if err != nil {
fmt.Println("Push counter couldn't be registered, no counting will happen:", err)
return
}
// Try it once more, this time with a help string.
pushCounter = prometheus.NewCounter(prometheus.CounterOpts{
Name: "repository_pushes",
Help: "Number of pushes to external repository.",
})
err = prometheus.Register(pushCounter)
if err != nil {
fmt.Println("Push counter couldn't be registered AGAIN, no counting will happen:", err)
return
}
pushComplete := make(chan struct{})
// TODO: Start a goroutine that performs repository pushes and reports
// each completion via the channel.
for _ = range pushComplete {
pushCounter.Inc()
}
// Output:
// Push counter couldn't be registered, no counting will happen: descriptor Desc{fqName: "repository_pushes", help: "", constLabels: {}, variableLabels: []} is invalid: empty help string
}
开发者ID:eghobo,项目名称:kubedash,代码行数:30,代码来源:examples_test.go
示例2: newMetrics
func newMetrics(r prometheus.Registerer) *metrics {
m := &metrics{}
m.gcDuration = prometheus.NewSummary(prometheus.SummaryOpts{
Name: "alertmanager_nflog_gc_duration_seconds",
Help: "Duration of the last notification log garbage collection cycle.",
})
m.snapshotDuration = prometheus.NewSummary(prometheus.SummaryOpts{
Name: "alertmanager_nflog_snapshot_duration_seconds",
Help: "Duration of the last notification log snapshot.",
})
m.queriesTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: "alertmanager_nflog_queries_total",
Help: "Number of notification log queries were received.",
})
m.queryErrorsTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: "alertmanager_nflog_query_errors_total",
Help: "Number notification log received queries that failed.",
})
m.queryDuration = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "alertmanager_nflog_query_duration_seconds",
Help: "Duration of notification log query evaluation.",
})
if r != nil {
r.MustRegister(
m.gcDuration,
m.snapshotDuration,
m.queriesTotal,
m.queryErrorsTotal,
m.queryDuration,
)
}
return m
}
开发者ID:prometheus,项目名称:alertmanager,代码行数:35,代码来源:nflog.go
示例3: 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
示例4: NewExporter
// NewExporter returns an initialized Exporter.
func NewExporter(apiKey, serverType string, hostURL *url.URL) *Exporter {
var gaugeDefs []gaugeDefinition
var counterVecDefs []counterVecDefinition
gaugeMetrics := make(map[int]prometheus.Gauge)
counterVecMetrics := make(map[int]*prometheus.CounterVec)
switch serverType {
case "recursor":
gaugeDefs = recursorGaugeDefs
counterVecDefs = recursorCounterVecDefs
case "authoritative":
gaugeDefs = authoritativeGaugeDefs
counterVecDefs = authoritativeCounterVecDefs
case "dnsdist":
gaugeDefs = dnsdistGaugeDefs
counterVecDefs = dnsdistCounterVecDefs
}
for _, def := range gaugeDefs {
gaugeMetrics[def.id] = newGaugeMetric(serverType, def.name, def.desc)
}
for _, def := range counterVecDefs {
counterVecMetrics[def.id] = newCounterVecMetric(serverType, def.name, def.desc, []string{def.label})
}
return &Exporter{
HostURL: hostURL,
ServerType: serverType,
ApiKey: apiKey,
up: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: serverType,
Name: "up",
Help: "Was the last scrape of PowerDNS successful.",
}),
totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: serverType,
Name: "exporter_total_scrapes",
Help: "Current total PowerDNS scrapes.",
}),
jsonParseFailures: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: serverType,
Name: "exporter_json_parse_failures",
Help: "Number of errors while parsing PowerDNS JSON stats.",
}),
gaugeMetrics: gaugeMetrics,
counterVecMetrics: counterVecMetrics,
gaugeDefs: gaugeDefs,
counterVecDefs: counterVecDefs,
}
}
开发者ID:janeczku,项目名称:powerdns_exporter,代码行数:56,代码来源:powerdns_exporter.go
示例5: New
// NewHandler constructs a new Handler.
func New(o *HandlerOptions) *Handler {
ctx, cancel := context.WithCancel(context.Background())
return &Handler{
queue: make(model.Alerts, 0, o.QueueCapacity),
ctx: ctx,
cancel: cancel,
more: make(chan struct{}, 1),
opts: o,
latency: prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "latency_seconds",
Help: "Latency quantiles for sending alert notifications (not including dropped notifications).",
}),
errors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "errors_total",
Help: "Total number of errors sending alert notifications.",
}),
sent: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "sent_total",
Help: "Total number of alerts successfully sent.",
}),
dropped: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "dropped_total",
Help: "Total number of alerts dropped due to alert manager missing in configuration.",
}),
queueLength: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "queue_length",
Help: "The number of alert notifications in the queue.",
}),
queueCapacity: prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "queue_capacity"),
"The capacity of the alert notifications queue.",
nil, nil,
),
prometheus.GaugeValue,
float64(o.QueueCapacity),
),
}
}
开发者ID:ekesken,项目名称:prometheus,代码行数:52,代码来源:notification.go
示例6: 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
示例7: 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
示例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: NewExporter
// NewExporter returns an initialized Exporter.
func NewExporter(uri string) *Exporter {
return &Exporter{
URI: uri,
scrapeFailures: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "exporter_scrape_failures_total",
Help: "Number of errors while scraping nginx.",
}),
processedConnections: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Name: "connections_processed_total",
Help: "Number of connections processed by nginx",
},
[]string{"stage"},
),
currentConnections: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "connections_current",
Help: "Number of connections currently processed by nginx",
},
[]string{"state"},
),
client: &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: *insecure},
},
},
}
}
开发者ID:life360,项目名称:nginx_exporter,代码行数:30,代码来源:nginx_exporter.go
示例10: 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
示例11: 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
示例12: init
// Add prometheus logging to SkyDNS
func init() {
server.StatsForwardCount = newCounter(prometheus.NewCounter(prometheus.CounterOpts{
Name: "dns_forward_count",
Help: "Counter of DNS requests forwarded",
}))
server.StatsLookupCount = newCounter(prometheus.NewCounter(prometheus.CounterOpts{
Name: "dns_lookup_count",
Help: "Counter of DNS lookups performed",
}))
server.StatsRequestCount = newCounter(prometheus.NewCounter(prometheus.CounterOpts{
Name: "dns_request_count",
Help: "Counter of DNS requests made",
}))
server.StatsDnssecOkCount = newCounter(prometheus.NewCounter(prometheus.CounterOpts{
Name: "dns_dnssec_ok_count",
Help: "Counter of DNSSEC requests that were valid",
}))
server.StatsDnssecCacheMiss = newCounter(prometheus.NewCounter(prometheus.CounterOpts{
Name: "dns_dnssec_cache_miss_count",
Help: "Counter of DNSSEC requests that missed the cache",
}))
server.StatsNameErrorCount = newCounter(prometheus.NewCounter(prometheus.CounterOpts{
Name: "dns_name_error_count",
Help: "Counter of DNS requests resulting in a name error",
}))
server.StatsNoDataCount = newCounter(prometheus.NewCounter(prometheus.CounterOpts{
Name: "dns_no_data_count",
Help: "Counter of DNS requests that contained no data",
}))
}
开发者ID:cjnygard,项目名称:origin,代码行数:31,代码来源:server.go
示例13: NewExporter
// NewExporter returns an initialized exporter
func NewExporter(server string) *Exporter {
return &Exporter{
mc: memcache.New(server),
up: prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "up",
Namespace: namespace,
Help: "Are the servers up.",
ConstLabels: prometheus.Labels{"server": server},
},
),
uptime: prometheus.NewCounter(
prometheus.CounterOpts{
Name: "uptime",
Namespace: namespace,
Help: "The uptime of the server.",
ConstLabels: prometheus.Labels{"server": server},
},
),
cache: prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "cache",
Namespace: namespace,
Help: "The cache hits/misses broken down by command (get, set, etc.).",
ConstLabels: prometheus.Labels{"server": server},
},
[]string{"command", "status"},
),
usage: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "usage",
Namespace: namespace,
Help: "Details the resource usage (items/connections) of the server, by time (current/total).",
ConstLabels: prometheus.Labels{"server": server},
},
[]string{"time", "resource"},
),
bytes: prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "bytes",
Namespace: namespace,
Help: "The bytes sent/received by the server.",
ConstLabels: prometheus.Labels{"server": server},
},
[]string{"direction"},
),
removals: prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "removal",
Namespace: namespace,
Help: "Number of items that have been evicted/expired (status), and if the were fetched ever or not.",
ConstLabels: prometheus.Labels{"server": server},
},
[]string{"status", "fetched"},
),
}
}
开发者ID:sciffer,项目名称:memcache_exporter,代码行数:58,代码来源:main.go
示例14: NewAddsMetric
func (_ prometheusMetricsProvider) NewAddsMetric(name string) workqueue.CounterMetric {
adds := prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: name,
Name: "adds",
Help: "Total number of adds handled by workqueue: " + name,
})
prometheus.Register(adds)
return adds
}
开发者ID:humblec,项目名称:kubernetes,代码行数:9,代码来源:prometheus.go
示例15: NewRetriesMetric
func (_ prometheusMetricsProvider) NewRetriesMetric(name string) workqueue.CounterMetric {
retries := prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: name,
Name: "retries",
Help: "Total number of retries handled by workqueue: " + name,
})
prometheus.Register(retries)
return retries
}
开发者ID:humblec,项目名称:kubernetes,代码行数:9,代码来源:prometheus.go
示例16: NewTimeCollector
// Takes a prometheus registry and returns a new Collector exposing
// the current system time in seconds since epoch.
func NewTimeCollector() (Collector, error) {
return &timeCollector{
metric: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: Namespace,
Name: "time",
Help: "System time in seconds since epoch (1970).",
}),
}, nil
}
开发者ID:juergenhoetzel,项目名称:node_exporter,代码行数:11,代码来源:time.go
示例17: NewSensors
// NewSensors creates new sensors from a raw config
func NewSensors(raw []interface{}) ([]*Sensor, error) {
var sensors []*Sensor
if err := utils.DecodeRaw(raw, &sensors); err != nil {
return nil, fmt.Errorf("Sensor configuration error: %v", err)
}
for _, s := range sensors {
check, err := commands.NewCommand(s.CheckExec, s.Timeout)
if err != nil {
return nil, fmt.Errorf("could not parse check in sensor %s: %s", s.Name, err)
}
check.Name = fmt.Sprintf("%s.sensor", s.Name)
s.checkCmd = check
// the prometheus client lib's API here is baffling... they don't expose
// an interface or embed their Opts type in each of the Opts "subtypes",
// so we can't share the initialization.
switch {
case s.Type == "counter":
s.collector = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: s.Namespace,
Subsystem: s.Subsystem,
Name: s.Name,
Help: s.Help,
})
case s.Type == "gauge":
s.collector = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: s.Namespace,
Subsystem: s.Subsystem,
Name: s.Name,
Help: s.Help,
})
case s.Type == "histogram":
s.collector = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: s.Namespace,
Subsystem: s.Subsystem,
Name: s.Name,
Help: s.Help,
})
case s.Type == "summary":
s.collector = prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: s.Namespace,
Subsystem: s.Subsystem,
Name: s.Name,
Help: s.Help,
})
default:
return nil, fmt.Errorf("invalid sensor type: %s", s.Type)
}
// we're going to unregister before every attempt to register
// so that we can reload config
prometheus.Unregister(s.collector)
if err := prometheus.Register(s.collector); err != nil {
return nil, err
}
}
return sensors, nil
}
开发者ID:joyent,项目名称:containerpilot,代码行数:58,代码来源:sensors.go
示例18: NewExporter
func NewExporter(uri string) *Exporter {
return &Exporter{
URI: uri,
up: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "up"),
"Could the apache server be reached",
nil,
nil),
scrapeFailures: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "exporter_scrape_failures_total",
Help: "Number of errors while scraping apache.",
}),
accessesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "accesses_total"),
"Current total apache accesses",
nil,
nil),
kBytesTotal: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "sent_kilobytes_total"),
"Current total kbytes sent",
nil,
nil),
uptime: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "uptime_seconds_total"),
"Current uptime in seconds",
nil,
nil),
workers: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "workers",
Help: "Apache worker statuses",
},
[]string{"state"},
),
scoreboard: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "scoreboard",
Help: "Apache scoreboard statuses",
},
[]string{"state"},
),
connections: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "connections",
Help: "Apache connection statuses",
},
[]string{"state"},
),
client: &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: *insecure},
},
},
}
}
开发者ID:neezgee,项目名称:apache_exporter,代码行数:56,代码来源:apache_exporter.go
示例19: NewNotificationHandler
// NewNotificationHandler constructs a new NotificationHandler.
func NewNotificationHandler(o *NotificationHandlerOptions) *NotificationHandler {
return &NotificationHandler{
alertmanagerURL: strings.TrimRight(o.AlertmanagerURL, "/"),
pendingNotifications: make(chan NotificationReqs, o.QueueCapacity),
httpClient: httputil.NewDeadlineClient(o.Deadline, nil),
notificationLatency: prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "latency_milliseconds",
Help: "Latency quantiles for sending alert notifications (not including dropped notifications).",
}),
notificationErrors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "errors_total",
Help: "Total number of errors sending alert notifications.",
}),
notificationDropped: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "dropped_total",
Help: "Total number of alert notifications dropped due to alert manager missing in configuration.",
}),
notificationsQueueLength: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "queue_length",
Help: "The number of alert notifications in the queue.",
}),
notificationsQueueCapacity: prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, "queue_capacity"),
"The capacity of the alert notifications queue.",
nil, nil,
),
prometheus.GaugeValue,
float64(o.QueueCapacity),
),
stopped: make(chan struct{}),
}
}
开发者ID:robbiet480,项目名称:prometheus,代码行数:44,代码来源:notification.go
示例20: NewStatCollector
// Takes a prometheus registry and returns a new Collector exposing
// network device stats.
func NewStatCollector() (Collector, error) {
return &statCollector{
cpu: prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: Namespace,
Name: "cpu",
Help: "Seconds the cpus spent in each mode.",
},
[]string{"cpu", "mode"},
),
intr: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: Namespace,
Name: "intr",
Help: "Total number of interrupts serviced.",
}),
ctxt: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: Namespace,
Name: "context_switches",
Help: "Total number of context switches.",
}),
forks: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: Namespace,
Name: "forks",
Help: "Total number of forks.",
}),
btime: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "boot_time",
Help: "Node boot time, in unixtime.",
}),
procsRunning: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "procs_running",
Help: "Number of processes in runnable state.",
}),
procsBlocked: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "procs_blocked",
Help: "Number of processes blocked waiting for I/O to complete.",
}),
}, nil
}
开发者ID:fin09pcap,项目名称:node_exporter,代码行数:44,代码来源:stat.go
注:本文中的github.com/prometheus/client_golang/prometheus.NewCounter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论