Skip to content

Commit

Permalink
Filter non Free plan zones from graphql metrics (#70)
Browse files Browse the repository at this point in the history
Co-authored-by: Laurynas Četyrkinas <[email protected]>
  • Loading branch information
stnby and stnby authored Jul 27, 2022
1 parent 44a539f commit fa0fe1b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,12 @@ func extractZoneIDs(zones []cloudflare.Zone) []string {

return IDs
}

func filterNonFreePlanZones(zones []cloudflare.Zone) (filteredZones []cloudflare.Zone) {
for _, z := range zones {
if z.Plan.ZonePlanCommon.ID != "0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee" {
filteredZones = append(filteredZones, z)
}
}
return
}
16 changes: 13 additions & 3 deletions prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ func fetchZoneColocationAnalytics(zones []cloudflare.Zone, wg *sync.WaitGroup) {
if cfgFreeTier {
return
}
zoneIDs := extractZoneIDs(zones)

zoneIDs := extractZoneIDs(filterNonFreePlanZones(zones))
if len(zoneIDs) == 0 {
return
}

r, err := fetchColoTotals(zoneIDs)
if err != nil {
Expand Down Expand Up @@ -256,7 +260,10 @@ func fetchZoneAnalytics(zones []cloudflare.Zone, wg *sync.WaitGroup) {
return
}

zoneIDs := extractZoneIDs(zones)
zoneIDs := extractZoneIDs(filterNonFreePlanZones(zones))
if len(zoneIDs) == 0 {
return
}

r, err := fetchZoneTotals(zoneIDs)
if err != nil {
Expand Down Expand Up @@ -389,7 +396,10 @@ func fetchLoadBalancerAnalytics(zones []cloudflare.Zone, wg *sync.WaitGroup) {
return
}

zoneIDs := extractZoneIDs(zones)
zoneIDs := extractZoneIDs(filterNonFreePlanZones(zones))
if len(zoneIDs) == 0 {
return
}

l, err := fetchLoadBalancerTotals(zoneIDs)
if err != nil {
Expand Down

0 comments on commit fa0fe1b

Please sign in to comment.