Skip to content

Commit

Permalink
add prometheus exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Apr 13, 2023
1 parent 531f140 commit b5e5845
Show file tree
Hide file tree
Showing 8 changed files with 1,086 additions and 9 deletions.
4 changes: 3 additions & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ var serveCmd = &cobra.Command{

if config.Webserver.Enable {
log.Infof("starting webserver on %s", config.Webserver.Bind)
srv := webserver.New(config.Webserver.Bind, config.Webserver.Webroot)
srv := webserver.New(config.Webserver, nodes)
go webserver.Start(srv)
defer srv.Close()
} else if prom := config.Webserver.Prometheus; prom != nil && prom.Enable {
log.Error("to enable prometheus exporter, please enable webserver ")
}

if config.Respondd.Enable {
Expand Down
10 changes: 10 additions & 0 deletions config_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ enable = false
bind = "127.0.0.1:8080"
webroot = "/var/www/html/meshviewer"

[webserver.prometheus]
# need webserver
enable = false
disable_labels = [
# "hostname",
# "owner",
# "location",
]



[nodes]
# Cache file
Expand Down
11 changes: 10 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,29 @@ require (
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.7.1
github.com/tidwall/gjson v1.14.0
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
golang.org/x/sys v0.0.0-20220712014510-0a85c31ab51e
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.19.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/fgrosse/graphigo.v2 v2.0.0-20151220153422-55a0a92a7030 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
413 changes: 413 additions & 0 deletions go.sum

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions webserver/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package webserver

type Config struct {
Enable bool `toml:"enable"`
Bind string `toml:"bind"`
Webroot string `toml:"webroot"`
Enable bool `toml:"enable"`
Bind string `toml:"bind"`
Webroot string `toml:"webroot"`
Prometheus *Prometheus `toml:"prometheus"`
}
Loading

0 comments on commit b5e5845

Please sign in to comment.