Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ $ ./pgpool2_exporter --help
* `web.listen-address`
Address on which to expose metrics and web interface. (default ":9719").

* `web.config.file`
Path to configuration file that can enable TLS or authentication. See: https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md

* `web.telemetry-path`
Path under which to expose metrics. (default "/metrics")

Expand Down Expand Up @@ -117,3 +120,14 @@ pgpool2_pool_health_check_stats_max_retry_count | 4.2+ | Number of maximum retri
pgpool2_pool_health_check_stats_max_duration | 4.2+ | Maximum health check duration in Millie seconds
pgpool2_pool_health_check_stats_min_duration | 4.2+ | Minimum health check duration in Millie seconds
pgpool2_pool_health_check_stats_average_duration | 4.2+ | Average health check duration in Millie seconds


### TLS endpoint

The exporter supports TLS via a new web configuration file.

```
./pgpool2_exporter --web.config.file=web-config.yml
```

See the [exporter-toolkit web-configuration](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md) for more details.
18 changes: 12 additions & 6 deletions cmd/pgpool2_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@ package main
import (
"fmt"
"net/http"
"os"
"net/url"
"os"
"strings"

"github.com/alecthomas/kingpin/v2"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/promlog"
"github.com/prometheus/common/promlog/flag"
"github.com/prometheus/common/version"
"gopkg.in/alecthomas/kingpin.v2"

exp "github.com/pgpool/pgpool2_exporter"
"github.com/prometheus/exporter-toolkit/web"
"github.com/prometheus/exporter-toolkit/web/kingpinflag"
)

func main() {
promlogConfig := &promlog.Config{}
toolkitFlags := kingpinflag.AddFlags(kingpin.CommandLine, ":9719")
metricsPath := kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String()
flag.AddFlags(kingpin.CommandLine, promlogConfig)
kingpin.Version(version.Print("pgpool2_exporter"))
kingpin.HelpFlag.Short('h')
Expand Down Expand Up @@ -51,14 +56,15 @@ func main() {
exp.PgpoolSemver = v

level.Info(exp.Logger).Log("msg", "Starting pgpool2_exporter", "version", version.Info(), "dsn", exp.MaskPassword(dsn))
level.Info(exp.Logger).Log("msg", "Listening on address", "address", *exp.ListenAddress)
level.Info(exp.Logger).Log("msg", "Listening on address", "address", strings.Join(*toolkitFlags.WebListenAddresses, ","))

http.Handle(*exp.MetricsPath, promhttp.Handler())
http.Handle(*metricsPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(fmt.Sprintf(exp.LandingPage, *exp.MetricsPath)))
w.Write([]byte(fmt.Sprintf(exp.LandingPage, *metricsPath)))
})

if err := http.ListenAndServe(*exp.ListenAddress, nil); err != nil {
server := &http.Server{}
if err := web.ListenAndServe(server, toolkitFlags, exp.Logger); err != nil {
level.Error(exp.Logger).Log("err", err)
os.Exit(1)
}
Expand Down
51 changes: 34 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,53 @@ go 1.17

require (
github.com/blang/semver v3.5.1+incompatible
github.com/go-kit/log v0.2.0
github.com/golang/protobuf v1.5.2 // indirect
github.com/go-kit/log v0.2.1
github.com/golang/protobuf v1.5.3 // indirect
github.com/lib/pq v1.10.2
github.com/prometheus/client_golang v1.12.0
github.com/prometheus/common v0.32.1
github.com/prometheus/procfs v0.7.3 // indirect
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/common v0.45.0
github.com/prometheus/procfs v0.11.1 // indirect
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/sys v0.15.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github/v25 v25.1.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/promu v0.13.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

require (
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/prometheus/exporter-toolkit v0.11.0
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/text v0.14.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/alecthomas/kingpin/v2 v2.4.0
)


Loading