Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ var (
log = logrus.New()
)

// var (
// cfgListen = ":8080"
// cfgCfAPIKey = ""
// cfgCfAPIEmail = ""
// cfgCfAPIToken = ""
// cfgMetricsPath = "/metrics"
// cfgZones = ""
// cfgExcludeZones = ""
// cfgScrapeDelay = 300
// cfgFreeTier = false
// cfgMetricsDenylist = ""
// )

func getTargetZones() []string {
var zoneIDs []string

Expand Down Expand Up @@ -103,7 +90,7 @@ func filterExcludedZones(all []cfzones.Zone, exclude []string) []cfzones.Zone {
return filtered
}

func fetchMetrics(deniedMetricsSet MetricsSet) {
func fetchMetrics(deniedMetricsSet []string) {
var wg sync.WaitGroup
accounts := fetchAccounts()

Expand Down Expand Up @@ -163,19 +150,15 @@ func runExporter() {
if len(viper.GetString("metrics_denylist")) > 0 {
metricsDenylist = strings.Split(viper.GetString("metrics_denylist"), ",")
}
metricsSet, err := buildFilteredMetricsSet(metricsDenylist)
if err != nil {
log.Fatalf("Error building metrics set: %v", err)
}
log.Debugf("Metrics set: %v", metricsSet)
mustRegisterMetrics(metricsSet)

mustRegisterMetrics(metricsDenylist)

scrapeInterval := time.Duration(viper.GetInt("scrape_interval")) * time.Second
log.Info("Scrape interval set to ", scrapeInterval)

go func() {
for ; true; <-time.NewTicker(scrapeInterval).C {
go fetchMetrics(metricsSet)
go fetchMetrics(metricsDenylist)
}
}()

Expand Down
Loading