Skip to content

Commit

Permalink
Merge pull request #247 from marcusramberg/marcus/add_seats
Browse files Browse the repository at this point in the history
  • Loading branch information
tboerger committed Aug 16, 2023
2 parents 349b340 + d84ee36 commit 8bf7ded
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/exporter/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/go-kit/log/level"
"github.com/google/go-github/v53/github"
"github.com/prometheus/client_golang/prometheus"

"github.com/promhippie/github_exporter/pkg/config"
)

Expand All @@ -28,6 +29,8 @@ type OrgCollector struct {
DiskUsage *prometheus.Desc
PrivateReposTotal *prometheus.Desc
PrivateReposOwned *prometheus.Desc
Seats *prometheus.Desc
FilledSeats *prometheus.Desc
Created *prometheus.Desc
Updated *prometheus.Desc
}
Expand Down Expand Up @@ -100,6 +103,18 @@ func NewOrgCollector(logger log.Logger, client *github.Client, failures *prometh
labels,
nil,
),
FilledSeats: prometheus.NewDesc(
"github_org_filled_seats",
"Filled seats for org",
labels,
nil,
),
Seats: prometheus.NewDesc(
"github_org_seats",
"Seats for org",
labels,
nil,
),
Created: prometheus.NewDesc(
"github_org_create_timestamp",
"Timestamp of the creation of org",
Expand Down Expand Up @@ -127,6 +142,8 @@ func (c *OrgCollector) Metrics() []*prometheus.Desc {
c.DiskUsage,
c.PrivateReposTotal,
c.PrivateReposOwned,
c.FilledSeats,
c.Seats,
c.Created,
c.Updated,
}
Expand All @@ -143,6 +160,8 @@ func (c *OrgCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- c.DiskUsage
ch <- c.PrivateReposTotal
ch <- c.PrivateReposOwned
ch <- c.Seats
ch <- c.FilledSeats
ch <- c.Created
ch <- c.Updated
}
Expand Down Expand Up @@ -254,6 +273,20 @@ func (c *OrgCollector) Collect(ch chan<- prometheus.Metric) {
labels...,
)

ch <- prometheus.MustNewConstMetric(
c.Seats,
prometheus.GaugeValue,
float64(record.GetPlan().GetSeats()),
labels...,
)

ch <- prometheus.MustNewConstMetric(
c.FilledSeats,
prometheus.GaugeValue,
float64(record.GetPlan().GetFilledSeats()),
labels...,
)

ch <- prometheus.MustNewConstMetric(
c.Created,
prometheus.GaugeValue,
Expand Down

0 comments on commit 8bf7ded

Please sign in to comment.