From 43c8ef5636f72e7acce9c6a48e4573f77522faff Mon Sep 17 00:00:00 2001 From: Mark Stansberry Date: Wed, 15 Apr 2020 13:09:56 -0400 Subject: [PATCH] Updates to allow multiple replication targets per-repo (#34) * Allow license/replication collection on trial license * Allow multiple push/pull targets per-repo --- collector/collector.go | 4 ++-- collector/replication.go | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index 392e068..f71f594 100755 --- a/collector/collector.go +++ b/collector/collector.go @@ -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 { @@ -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 { diff --git a/collector/replication.go b/collector/replication.go index 81e6dae..8938098 100644 --- a/collector/replication.go +++ b/collector/replication.go @@ -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"` @@ -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) } } }