Skip to content

Commit 82502b7

Browse files
authored
Merge pull request #39 from inovex/metrics
add metrics handler
2 parents 38e9ed5 + 22171c6 commit 82502b7

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

cmd/webhook/main.go

+14-7
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ import (
88

99
"external-dns-openstack-webhook/internal/designate/provider"
1010

11+
"github.com/prometheus/client_golang/prometheus/promhttp"
12+
1113
"sigs.k8s.io/external-dns/endpoint"
1214
"sigs.k8s.io/external-dns/provider/webhook/api"
1315
)
1416

17+
const (
18+
webhookServerAddr = "127.0.0.1:8888"
19+
statusServerAddr = "0.0.0.0:8080"
20+
)
21+
1522
func main() {
1623
log.SetLevel(log.DebugLevel)
1724

@@ -29,31 +36,31 @@ func main() {
2936
w.WriteHeader(http.StatusInternalServerError)
3037
}
3138
})
39+
m.HandleFunc("/metrics", promhttp.Handler().ServeHTTP)
3240

3341
go func() {
34-
log.Debug("Starting status server on :8080")
42+
log.Debugf("Starting status server on %s", statusServerAddr)
3543
s := &http.Server{
36-
Addr: "0.0.0.0:8080",
44+
Addr: statusServerAddr,
3745
Handler: m,
3846
}
3947

40-
l, err := net.Listen("tcp", "0.0.0.0:8080")
48+
l, err := net.Listen("tcp", statusServerAddr)
4149
if err != nil {
4250
log.Fatal(err)
4351
}
4452
err = s.Serve(l)
4553
if err != nil {
46-
log.Fatalf("health listener stopped : %s", err)
54+
log.Fatalf("status listener stopped : %s", err)
4755
}
4856
}()
4957

50-
5158
epf := endpoint.NewDomainFilter([]string{})
5259
dp, err := provider.NewDesignateProvider(epf, false)
5360
if err != nil {
5461
log.Fatalf("NewDesignateProvider: %v", err)
5562
}
5663

57-
log.Printf("Starting server")
58-
api.StartHTTPApi(dp, startedChan, 0, 0, "127.0.0.1:8888")
64+
log.Debugf("Starting webhook server on %s", webhookServerAddr)
65+
api.StartHTTPApi(dp, startedChan, 0, 0, webhookServerAddr)
5966
}

go.mod

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ require (
77
sigs.k8s.io/external-dns v0.15.1
88
)
99

10-
require github.com/gophercloud/gophercloud/v2 v2.6.0
10+
require (
11+
github.com/gophercloud/gophercloud/v2 v2.6.0
12+
github.com/prometheus/client_golang v1.20.5
13+
)
1114

1215
require (
1316
github.com/aws/aws-sdk-go-v2/service/route53 v1.46.3 // indirect
@@ -20,11 +23,11 @@ require (
2023
github.com/google/go-cmp v0.6.0 // indirect
2124
github.com/google/gofuzz v1.2.0 // indirect
2225
github.com/json-iterator/go v1.1.12 // indirect
26+
github.com/klauspost/compress v1.17.9 // indirect
2327
github.com/kr/text v0.2.0 // indirect
2428
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2529
github.com/modern-go/reflect2 v1.0.2 // indirect
2630
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
27-
github.com/prometheus/client_golang v1.20.5 // indirect
2831
github.com/prometheus/client_model v0.6.1 // indirect
2932
github.com/prometheus/common v0.55.0 // indirect
3033
github.com/prometheus/procfs v0.15.1 // indirect

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
3535
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
3636
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
3737
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
38+
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
39+
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
3840
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
3941
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
4042
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=

0 commit comments

Comments
 (0)