diff options
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/metrics/collector.go | 69 | ||||
-rw-r--r-- | modules/setting/setting.go | 14 |
2 files changed, 50 insertions, 33 deletions
diff --git a/modules/metrics/collector.go b/modules/metrics/collector.go index dcc147631b..527202e0a6 100755 --- a/modules/metrics/collector.go +++ b/modules/metrics/collector.go @@ -15,33 +15,34 @@ const namespace = "gitea_" // Collector implements the prometheus.Collector interface and // exposes gitea metrics for prometheus type Collector struct { - Accesses *prometheus.Desc - Actions *prometheus.Desc - Attachments *prometheus.Desc - Comments *prometheus.Desc - Follows *prometheus.Desc - HookTasks *prometheus.Desc - Issues *prometheus.Desc - IssuesOpen *prometheus.Desc - IssuesClosed *prometheus.Desc - IssuesByLabel *prometheus.Desc - Labels *prometheus.Desc - LoginSources *prometheus.Desc - Milestones *prometheus.Desc - Mirrors *prometheus.Desc - Oauths *prometheus.Desc - Organizations *prometheus.Desc - Projects *prometheus.Desc - ProjectBoards *prometheus.Desc - PublicKeys *prometheus.Desc - Releases *prometheus.Desc - Repositories *prometheus.Desc - Stars *prometheus.Desc - Teams *prometheus.Desc - UpdateTasks *prometheus.Desc - Users *prometheus.Desc - Watches *prometheus.Desc - Webhooks *prometheus.Desc + Accesses *prometheus.Desc + Actions *prometheus.Desc + Attachments *prometheus.Desc + Comments *prometheus.Desc + Follows *prometheus.Desc + HookTasks *prometheus.Desc + Issues *prometheus.Desc + IssuesOpen *prometheus.Desc + IssuesClosed *prometheus.Desc + IssuesByLabel *prometheus.Desc + IssuesByRepository *prometheus.Desc + Labels *prometheus.Desc + LoginSources *prometheus.Desc + Milestones *prometheus.Desc + Mirrors *prometheus.Desc + Oauths *prometheus.Desc + Organizations *prometheus.Desc + Projects *prometheus.Desc + ProjectBoards *prometheus.Desc + PublicKeys *prometheus.Desc + Releases *prometheus.Desc + Repositories *prometheus.Desc + Stars *prometheus.Desc + Teams *prometheus.Desc + UpdateTasks *prometheus.Desc + Users *prometheus.Desc + Watches *prometheus.Desc + Webhooks *prometheus.Desc } // NewCollector returns a new Collector with all prometheus.Desc initialized @@ -88,6 +89,11 @@ func NewCollector() Collector { "Number of Issues", []string{"label"}, nil, ), + IssuesByRepository: prometheus.NewDesc( + namespace+"issues_by_repository", + "Number of Issues", + []string{"repository"}, nil, + ), IssuesOpen: prometheus.NewDesc( namespace+"issues_open", "Number of open Issues", @@ -196,6 +202,7 @@ func (c Collector) Describe(ch chan<- *prometheus.Desc) { ch <- c.HookTasks ch <- c.Issues ch <- c.IssuesByLabel + ch <- c.IssuesByRepository ch <- c.IssuesOpen ch <- c.IssuesClosed ch <- c.Labels @@ -264,6 +271,14 @@ func (c Collector) Collect(ch chan<- prometheus.Metric) { il.Label, ) } + for _, ir := range stats.Counter.IssueByRepository { + ch <- prometheus.MustNewConstMetric( + c.IssuesByRepository, + prometheus.GaugeValue, + float64(ir.Count), + ir.OwnerName+"/"+ir.Repository, + ) + } ch <- prometheus.MustNewConstMetric( c.IssuesClosed, prometheus.GaugeValue, diff --git a/modules/setting/setting.go b/modules/setting/setting.go index bdb3b1fd7b..88302be1d3 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -390,13 +390,15 @@ var ( // Metrics settings Metrics = struct { - Enabled bool - Token string - EnabledIssueByLabel bool + Enabled bool + Token string + EnabledIssueByLabel bool + EnabledIssueByRepository bool }{ - Enabled: false, - Token: "", - EnabledIssueByLabel: false, + Enabled: false, + Token: "", + EnabledIssueByLabel: false, + EnabledIssueByRepository: false, } // I18n settings |