Skip to content

Commit

Permalink
Add Colo Bytes/Visits per host (lablabs#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcollom authored Jul 24, 2022
1 parent 8e97133 commit 3034d18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type zoneRespColo struct {
Dimensions struct {
Datetime string `json:"datetime"`
ColoCode string `json:"coloCode"`
Host string `json:"clientRequestHTTPHost"`
} `json:"dimensions"`
Count uint64 `json:"count"`
Sum struct {
Expand Down Expand Up @@ -381,6 +382,7 @@ func fetchColoTotals(zoneIDs []string) (*cloudflareResponseColo, error) {
sampleInterval
}
dimensions {
clientRequestHTTPHost
coloCode
datetime
}
Expand Down
8 changes: 4 additions & 4 deletions prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ var (
zoneColocationVisits = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "cloudflare_zone_colocation_visits",
Help: "Total visits per colocation",
}, []string{"zone", "colocation"},
}, []string{"zone", "colocation", "host"},
)

zoneColocationEdgeResponseBytes = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "cloudflare_zone_colocation_edge_response_bytes",
Help: "Edge response bytes per colocation",
}, []string{"zone", "colocation"},
}, []string{"zone", "colocation", "host"},
)

zoneFirewallEventsCount = promauto.NewCounterVec(prometheus.CounterOpts{
Expand Down Expand Up @@ -228,8 +228,8 @@ func fetchZoneColocationAnalytics(zones []cloudflare.Zone, wg *sync.WaitGroup) {
cg := z.ColoGroups
name := findZoneName(zones, z.ZoneTag)
for _, c := range cg {
zoneColocationVisits.With(prometheus.Labels{"zone": name, "colocation": c.Dimensions.ColoCode}).Add(float64(c.Sum.Visits))
zoneColocationEdgeResponseBytes.With(prometheus.Labels{"zone": name, "colocation": c.Dimensions.ColoCode}).Add(float64(c.Sum.EdgeResponseBytes))
zoneColocationVisits.With(prometheus.Labels{"zone": name, "colocation": c.Dimensions.ColoCode, "host": c.Dimensions.Host}).Add(float64(c.Sum.Visits))
zoneColocationEdgeResponseBytes.With(prometheus.Labels{"zone": name, "colocation": c.Dimensions.ColoCode, "host": c.Dimensions.Host}).Add(float64(c.Sum.EdgeResponseBytes))
}
}
}
Expand Down

0 comments on commit 3034d18

Please sign in to comment.