@@ -370,18 +370,24 @@ func buildTelemetryServer(registry prometheus.Gatherer) *http.ServeMux {
370
370
371
371
// Add metricsPath
372
372
mux .Handle (metricsPath , promhttp .HandlerFor (registry , promhttp.HandlerOpts {ErrorLog : promLogger {}}))
373
+
373
374
// Add index
374
- mux .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
375
- w .Write ([]byte (`<html>
376
- <head><title>Kube-State-Metrics Metrics Server</title></head>
377
- <body>
378
- <h1>Kube-State-Metrics Metrics</h1>
379
- <ul>
380
- <li><a href='` + metricsPath + `'>metrics</a></li>
381
- </ul>
382
- </body>
383
- </html>` ))
384
- })
375
+ landingConfig := web.LandingConfig {
376
+ Name : "kube-state-metrics" ,
377
+ Description : "Self-metrics for kube-state-metrics" ,
378
+ Version : version .Info (),
379
+ Links : []web.LandingLinks {
380
+ {
381
+ Address : metricsPath ,
382
+ Text : "Metrics" ,
383
+ },
384
+ },
385
+ }
386
+ landingPage , err := web .NewLandingPage (landingConfig )
387
+ if err != nil {
388
+ klog .ErrorS (err , "failed to create landing page" )
389
+ }
390
+ mux .Handle ("/" , landingPage )
385
391
return mux
386
392
}
387
393
@@ -402,19 +408,28 @@ func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prome
402
408
w .WriteHeader (http .StatusOK )
403
409
w .Write ([]byte (http .StatusText (http .StatusOK )))
404
410
})
411
+
405
412
// Add index
406
- mux .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
407
- w .Write ([]byte (`<html>
408
- <head><title>Kube Metrics Server</title></head>
409
- <body>
410
- <h1>Kube Metrics</h1>
411
- <ul>
412
- <li><a href='` + metricsPath + `'>metrics</a></li>
413
- <li><a href='` + healthzPath + `'>healthz</a></li>
414
- </ul>
415
- </body>
416
- </html>` ))
417
- })
413
+ landingConfig := web.LandingConfig {
414
+ Name : "kube-state-metrics" ,
415
+ Description : "Metrics for Kubernetes' state" ,
416
+ Version : version .Info (),
417
+ Links : []web.LandingLinks {
418
+ {
419
+ Address : metricsPath ,
420
+ Text : "Metrics" ,
421
+ },
422
+ {
423
+ Address : healthzPath ,
424
+ Text : "Healthz" ,
425
+ },
426
+ },
427
+ }
428
+ landingPage , err := web .NewLandingPage (landingConfig )
429
+ if err != nil {
430
+ klog .ErrorS (err , "failed to create landing page" )
431
+ }
432
+ mux .Handle ("/" , landingPage )
418
433
return mux
419
434
}
420
435
0 commit comments