Skip to content

Commit

Permalink
simplify prometheus setup using cm3
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelcmtd committed Mar 27, 2023
1 parent b83eb3c commit 09636b6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/chrissxMedia/redirector
go 1.16

require (
github.com/chrissxMedia/cm3.go v0.0.0-20230327023026-5b09b3e68183
github.com/chrissxMedia/cm3.go v0.1.0
github.com/prometheus/client_golang v1.14.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cb
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chrissxMedia/cm3.go v0.0.0-20230327023026-5b09b3e68183 h1:DRQfmnf1lS/K5wn+wrbTtSLJhyt6B9Pmcs4dQRD/1Ys=
github.com/chrissxMedia/cm3.go v0.0.0-20230327023026-5b09b3e68183/go.mod h1:f7SWla9HMSV27sT1HLXvwp52PvQTZOeNpWhJiI22Apk=
github.com/chrissxMedia/cm3.go v0.1.0 h1:5lJswWWmy5EL6ErK4IoA62elnVfj+DmEXwmb/3hsXgo=
github.com/chrissxMedia/cm3.go v0.1.0/go.mod h1:Ic5ruwg6hNm+tOgUO7eJwrDXT1HJcV7FsIWnfuEt5SE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down
5 changes: 1 addition & 4 deletions redirector.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/chrissxMedia/cm3.go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

//go:embed response.min.html
Expand All @@ -26,9 +25,7 @@ func main() {
Help: "Number of HTTP requests that contain the Host header.",
}, []string{})

prometheus.MustRegister(totalReqs)
prometheus.MustRegister(hostReqs)
http.Handle("/metrics", promhttp.Handler())
cm3.HandleMetrics(totalReqs, hostReqs)

cm3.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
totalReqs.WithLabelValues().Inc()
Expand Down

0 comments on commit 09636b6

Please sign in to comment.