Skip to content

Commit

Permalink
Add ingress label to exported metrics (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Jul 17, 2017
1 parent 6a900c9 commit 035f90e
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 96 deletions.
11 changes: 4 additions & 7 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions pkg/cmds/exporter.go
Expand Up @@ -5,7 +5,6 @@ import (
"net/http"
_ "net/http/pprof"

hpe "github.com/appscode/haproxy_exporter/exporter"
"github.com/appscode/log"
"github.com/appscode/pat"
acs "github.com/appscode/voyager/client/clientset"
Expand Down Expand Up @@ -55,10 +54,6 @@ func export() {
extClient = acs.NewForConfigOrDie(config)

log.Infoln("Starting Voyager exporter...")
selectedServerMetrics, err = hpe.FilterServerMetrics(haProxyServerMetricFields)
if err != nil {
log.Fatal(err)
}
m := pat.New()
m.Get("/metrics", promhttp.Handler())
pattern := fmt.Sprintf("/%s/v1beta1/namespaces/%s/ingresses/%s/metrics", PathParamAPIGroup, PathParamNamespace, PathParamName)
Expand Down
6 changes: 2 additions & 4 deletions pkg/cmds/exporter_handler.go
Expand Up @@ -26,8 +26,6 @@ const (
)

var (
selectedServerMetrics map[int]*prometheus.GaugeVec

registerers = cmap.New() // URL.path => *prometheus.Registry
)

Expand Down Expand Up @@ -92,7 +90,7 @@ func ExportMetrics(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
exporter, err := hpe.NewExporter(scrapeURL, selectedServerMetrics, haProxyTimeout)
exporter, err := hpe.NewExporter(scrapeURL, name, haProxyServerMetricFields, haProxyTimeout)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down Expand Up @@ -127,7 +125,7 @@ func ExportMetrics(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
exporter, err := hpe.NewExporter(scrapeURL, selectedServerMetrics, haProxyTimeout)
exporter, err := hpe.NewExporter(scrapeURL, name, haProxyServerMetricFields, haProxyTimeout)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down
4 changes: 0 additions & 4 deletions pkg/cmds/run.go
Expand Up @@ -110,10 +110,6 @@ func run() {
w.PurgeOffshootsWithDeprecatedLabels()
go w.Run()

selectedServerMetrics, err = hpe.FilterServerMetrics(haProxyServerMetricFields)
if err != nil {
log.Fatal(err)
}
m := pat.New()
m.Get("/metrics", promhttp.Handler())
pattern := fmt.Sprintf("/%s/v1beta1/namespaces/%s/ingresses/%s/metrics", PathParamAPIGroup, PathParamNamespace, PathParamName)
Expand Down
187 changes: 117 additions & 70 deletions vendor/github.com/appscode/haproxy_exporter/exporter/haproxy_exporter.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/github.com/spf13/cobra/command.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vendor/gopkg.in/yaml.v2/emitterc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/gopkg.in/yaml.v2/yamlh.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 035f90e

Please sign in to comment.