Skip to content
Closed
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
7 changes: 7 additions & 0 deletions director/director.go
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,7 @@ func collectDirectorRedirectionMetric(ctx *gin.Context, destination string) {
"destination": destination,
"status_code": strconv.Itoa(ctx.Writer.Status()),
"version": "",
"network": "",
}

version, _, err := extractVersionAndService(ctx)
Expand All @@ -1374,6 +1375,12 @@ func collectDirectorRedirectionMetric(ctx *gin.Context, destination string) {
labels["version"] = "unknown"
}

maskedIp, ok := utils.ApplyIPMask(ctx.ClientIP())
if ok {
labels["network"] = maskedIp
} else {
labels["network"] = "unknown"
}
metrics.PelicanDirectorRedirectionsTotal.With(labels).Inc()
}

Expand Down
14 changes: 12 additions & 2 deletions director/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/pelicanplatform/pelican/metrics"
"github.com/pelicanplatform/pelican/param"
"github.com/pelicanplatform/pelican/server_structs"
"github.com/pelicanplatform/pelican/utils"
)

type (
Expand Down Expand Up @@ -156,8 +157,17 @@ func getLatLong(ctx context.Context, addr netip.Addr) (lat float64, long float64
}

labels := prometheus.Labels{
"source": "",
"proj": "",
"network": "",
"source": "",
"proj": "",
}

network, ok := utils.ApplyIPMask(addr.String())
if !ok {
log.Warningf("Failed to apply IP mask to address %s", ip.String())
labels["network"] = "unknown"
} else {
labels["network"] = network
}

project, ok := ctx.Value(ProjectContextKey{}).(string)
Expand Down
4 changes: 2 additions & 2 deletions metrics/director.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ var (
PelicanDirectorRedirectionsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "pelican_director_redirections_total",
Help: "The total number of redirections the director issued.",
}, []string{"destination", "status_code", "version"})
}, []string{"destination", "status_code", "version", "network"})

PelicanDirectorGeoIPErrors = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "pelican_director_geoip_errors",
Help: "The total number of errors encountered trying to resolve coordinates using the GeoIP MaxMind database",
}, []string{"source", "proj"})
}, []string{"network", "source", "proj"})
)
Loading