Skip to content

Commit

Permalink
Updates to allow multiple replication targets per-repo (#34)
Browse files Browse the repository at this point in the history
* Allow license/replication collection on trial license

* Allow multiple push/pull targets per-repo
  • Loading branch information
mstansberry authored Apr 15, 2020
1 parent 03684a0 commit 43c8ef5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
var (
filestoreLabelNames = []string{"storage_type", "storage_dir"}
repoLabelNames = []string{"name", "type", "package_type"}
replicationLabelNames = []string{"name", "type", "cron_exp"}
replicationLabelNames = []string{"name", "type", "url", "cron_exp"}
)

func newMetric(metricName string, subsystem string, docString string, labelNames []string) *prometheus.Desc {
Expand Down Expand Up @@ -252,7 +252,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) (up float64) {
e.extractRepoSummary(storageInfo, ch)

// Some API endpoints are not available in OSS
if licenseType != "oss" && licenseType != "trial" {
if licenseType != "oss" {
// Fetch Security stats
users, err := e.fetchUsers()
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions collector/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type replication struct {
SyncProperties bool `json:"syncProperties"`
PathPrefix string `json:"pathPrefix"`
RepoKey string `json:"repoKey"`
URL string `json:"url"`
EnableEventReplication bool `json:"enableEventReplication"`
CheckBinaryExistenceInFilestore bool `json:"checkBinaryExistenceInFilestore"`
SyncStatistics bool `json:"syncStatistics"`
Expand Down Expand Up @@ -48,9 +49,10 @@ func (e *Exporter) exportReplications(replications []replication, ch chan<- prom
enabled := b2f(replication.Enabled)
repo := replication.RepoKey
rType := strings.ToLower(replication.ReplicationType)
rURL := strings.ToLower(replication.URL)
cronExp := replication.CronExp
level.Debug(e.logger).Log("msg", "Registering metric", "metric", metricName, "repo", replication.RepoKey, "type", rType, "cron", cronExp, "value", enabled)
ch <- prometheus.MustNewConstMetric(metric, prometheus.GaugeValue, enabled, repo, rType, cronExp)
level.Debug(e.logger).Log("msg", "Registering metric", "metric", metricName, "repo", replication.RepoKey, "type", rType, "url", rURL, "cron", cronExp, "value", enabled)
ch <- prometheus.MustNewConstMetric(metric, prometheus.GaugeValue, enabled, repo, rType, rURL, cronExp)
}
}
}
Expand Down

0 comments on commit 43c8ef5

Please sign in to comment.