add reports statistics
This commit is contained in:
parent
12312e6ac9
commit
08888165fd
|
@ -85,6 +85,18 @@ var (
|
|||
metricPrefix+"users_pending",
|
||||
"Number of pending users.",
|
||||
nil, nil)
|
||||
reportsNewest = prometheus.NewDesc(
|
||||
metricPrefix+"reports_newest",
|
||||
"Contains the datetime about the newest report of this Instance.",
|
||||
[]string{"datetime"}, nil)
|
||||
reportsOpen = prometheus.NewDesc(
|
||||
metricPrefix+"reports_open",
|
||||
"Number of open reports.",
|
||||
nil, nil)
|
||||
reportsClosed = prometheus.NewDesc(
|
||||
metricPrefix+"reports_closed",
|
||||
"Number of closed reports.",
|
||||
nil, nil)
|
||||
)
|
||||
|
||||
type friendicaCollector struct {
|
||||
|
@ -133,6 +145,9 @@ func (c *friendicaCollector) Describe(ch chan<- *prometheus.Desc) {
|
|||
ch <- postsOutbound
|
||||
ch <- packetsInbound
|
||||
ch <- packetsOutbound
|
||||
ch <- reportsNewest
|
||||
ch <- reportsOpen
|
||||
ch <- reportsClosed
|
||||
}
|
||||
|
||||
func (c *friendicaCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
|
@ -254,6 +269,14 @@ func collectSimpleMetrics(ch chan<- prometheus.Metric, status *serverinfo.Server
|
|||
desc: usersPending,
|
||||
value: float64(status.Users.Pending),
|
||||
},
|
||||
{
|
||||
desc: reportsOpen,
|
||||
value: float64(status.Reports.Open),
|
||||
},
|
||||
{
|
||||
desc: reportsClosed,
|
||||
value: float64(status.Reports.Closed),
|
||||
},
|
||||
}
|
||||
|
||||
for _, m := range metrics {
|
||||
|
@ -391,6 +414,13 @@ func collectLastExecutions(ch chan<- prometheus.Metric, status *serverinfo.Serve
|
|||
}
|
||||
ch <- metric
|
||||
|
||||
reportsInfo := status.Reports
|
||||
|
||||
metric, err = prometheus.NewConstMetric(reportsNewest, prometheus.GaugeValue, float64(reportsInfo.Newest.Timestamp), reportsInfo.Newest.DateTime)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating metric for %s: %w", reportsNewest, err)
|
||||
}
|
||||
ch <- metric
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue