Skip to content

Commit 4867295

Browse files
committed
extended /probe path metrics
Signed-off-by: Ildar Valiullin <[email protected]>
1 parent 9ae3475 commit 4867295

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

cmd/postgres_exporter/probe.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ func handleProbe(logger log.Logger) http.HandlerFunc {
7878
registry.MustRegister(probeSuccessGauge)
7979
registry.MustRegister(probeDurationGauge)
8080

81+
opts := []ExporterOpt{
82+
DisableDefaultMetrics(*disableDefaultMetrics),
83+
DisableSettingsMetrics(*disableSettingsMetrics),
84+
AutoDiscoverDatabases(*autoDiscoverDatabases),
85+
WithUserQueriesPath(*queriesPath),
86+
WithConstantLabels(*constantLabelsList),
87+
ExcludeDatabases(*excludeDatabases),
88+
IncludeDatabases(*includeDatabases),
89+
}
90+
91+
dsns := []string{dsn}
92+
exporter := NewExporter(dsns, opts...)
93+
defer func() {
94+
exporter.servers.Close()
95+
}()
96+
registry.MustRegister(exporter)
97+
8198
// Run the probe
8299
pc, err := collector.NewProbeCollector(tl, registry, dsn)
83100
if err != nil {

config/config.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"fmt"
1818
"net/url"
1919
"os"
20-
"strings"
2120
"sync"
2221

2322
"github.com/go-kit/log"
@@ -99,7 +98,7 @@ func (ch *ConfigHandler) ReloadConfig(f string, logger log.Logger) error {
9998

10099
func (m AuthModule) ConfigureTarget(target string) (string, error) {
101100
// ip:port urls do not parse properly and that is the typical way users interact with postgres
102-
t := fmt.Sprintf("exporter://%s", target)
101+
t := fmt.Sprintf("postgresql://%s", target)
103102
u, err := url.Parse(t)
104103
if err != nil {
105104
return "", err
@@ -115,8 +114,5 @@ func (m AuthModule) ConfigureTarget(target string) (string, error) {
115114
}
116115
u.RawQuery = query.Encode()
117116

118-
parsed := u.String()
119-
trim := strings.TrimPrefix(parsed, "exporter://")
120-
121-
return trim, nil
117+
return u.String(), nil
122118
}

0 commit comments

Comments
 (0)