Skip to content

Commit 77586ff

Browse files
Merge pull request #15 from GetStream/improve-workflows
handle protocol in the urls
2 parents c888030 + 95a9a2f commit 77586ff

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/services/metrics.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"net/http"
88
"sort"
9+
"strings"
910
"time"
1011

1112
"github.com/GetStream/tikv-ui/pkg/types"
@@ -65,11 +66,14 @@ func (m *Monitor) pollStores(ctx context.Context) {
6566
log.Printf("pd metrics: no active cluster name")
6667
return
6768
}
68-
69+
storesURL := pdAddr + "/pd/api/v1/stores"
70+
if !strings.HasPrefix(pdAddr, "http") {
71+
storesURL = "http://" + pdAddr + "/pd/api/v1/stores"
72+
}
6973
req, err := http.NewRequestWithContext(
7074
ctx,
7175
http.MethodGet,
72-
"http://"+pdAddr+"/pd/api/v1/stores",
76+
storesURL,
7377
nil,
7478
)
7579
if err != nil {
@@ -137,7 +141,10 @@ func (m *Monitor) pollTiKVMetrics(ctx context.Context) {
137141
continue
138142
}
139143

140-
metricsURL := "http://" + statusAddr + "/metrics"
144+
metricsURL := statusAddr + "/metrics"
145+
if !strings.HasPrefix(statusAddr, "http") {
146+
metricsURL = "http://" + statusAddr + "/metrics"
147+
}
141148
newMetrics, err := m.fetchNodeMetrics(ctx, metricsURL, statusAddr)
142149
if err != nil {
143150
log.Printf("tikv metrics: node %s error: %v", statusAddr, err)

0 commit comments

Comments
 (0)