|
8 | 8 |
|
9 | 9 | activities_model "code.gitea.io/gitea/models/activities" |
10 | 10 | "code.gitea.io/gitea/models/db" |
| 11 | + "code.gitea.io/gitea/models/system" |
11 | 12 | "code.gitea.io/gitea/modules/setting" |
12 | 13 |
|
13 | 14 | "github.com/prometheus/client_golang/prometheus" |
@@ -41,6 +42,7 @@ type Collector struct { |
41 | 42 | Releases *prometheus.Desc |
42 | 43 | Repositories *prometheus.Desc |
43 | 44 | Stars *prometheus.Desc |
| 45 | + SystemNotices *prometheus.Desc |
44 | 46 | Teams *prometheus.Desc |
45 | 47 | UpdateTasks *prometheus.Desc |
46 | 48 | Users *prometheus.Desc |
@@ -171,6 +173,10 @@ func NewCollector() Collector { |
171 | 173 | "Number of Stars", |
172 | 174 | nil, nil, |
173 | 175 | ), |
| 176 | + SystemNotices: prometheus.NewDesc( |
| 177 | + namespace+"system_notices", |
| 178 | + "Number of system notices", |
| 179 | + nil, nil), |
174 | 180 | Teams: prometheus.NewDesc( |
175 | 181 | namespace+"teams", |
176 | 182 | "Number of Teams", |
@@ -234,6 +240,7 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) { |
234 | 240 | // Collect returns the metrics with values |
235 | 241 | func (c Collector) Collect(ch chan<- prometheus.Metric) { |
236 | 242 | stats := activities_model.GetStatistic(db.DefaultContext) |
| 243 | + noticeCount := system.CountNotices(db.DefaultContext) |
237 | 244 |
|
238 | 245 | ch <- prometheus.MustNewConstMetric( |
239 | 246 | c.Accesses, |
@@ -366,6 +373,11 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) { |
366 | 373 | prometheus.GaugeValue, |
367 | 374 | float64(stats.Counter.Star), |
368 | 375 | ) |
| 376 | + ch <- prometheus.MustNewConstMetric( |
| 377 | + c.SystemNotices, |
| 378 | + prometheus.GaugeValue, |
| 379 | + float64(noticeCount), |
| 380 | + ) |
369 | 381 | ch <- prometheus.MustNewConstMetric( |
370 | 382 | c.Teams, |
371 | 383 | prometheus.GaugeValue, |
|
0 commit comments