aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/atlas/config.go3
-rw-r--r--pkg/atlas/server.go7
2 files changed, 8 insertions, 2 deletions
diff --git a/pkg/atlas/config.go b/pkg/atlas/config.go
index 149c9ab..af70817 100644
--- a/pkg/atlas/config.go
+++ b/pkg/atlas/config.go
@@ -172,7 +172,8 @@ type Config struct {
// country and region fields. The database must not be modified while atlas
// is running, but it can be replaced (and a reload can be triggered with
// SIGHUP). If not provided, geolocation-dependent features like server
- // regions will not be enabled.
+ // regions and geo metrics will not be enabled. If it doesn't include latlon
+ // info, geo metrics will be disabled too.
IP2Location string `env:"ATLAS_IP2LOCATION"`
// For sd-notify.
diff --git a/pkg/atlas/server.go b/pkg/atlas/server.go
index 55f1b5c..3c881dd 100644
--- a/pkg/atlas/server.go
+++ b/pkg/atlas/server.go
@@ -763,12 +763,13 @@ func (s *Server) HandleSIGHUP() {
// serveRest handles endpoints not handled by the API.
func (s *Server) serveRest(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/metrics" {
- var internal bool
+ var internal, geo bool
if s := s.MetricsSecret; s != "" {
if r.URL.Query().Get("secret") == s {
internal = true
}
}
+ geo = r.URL.Query().Has("geo")
var ms []func(io.Writer)
if internal {
@@ -776,6 +777,10 @@ func (s *Server) serveRest(w http.ResponseWriter, r *http.Request) {
ms = append(ms, s.API0.WritePrometheus)
}
ms = append(ms, s.API0.ServerList.WritePrometheus)
+ if internal && geo {
+ ms = append(ms, s.API0.WritePrometheusGeo)
+ ms = append(ms, s.API0.ServerList.WritePrometheusGeo)
+ }
var b bytes.Buffer
for i, m := range ms {