Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2019-03-07 10:54:40 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-03-07 10:54:40 +0300
commit8720977482321a4c1fb7b7f7014499701ae5a287 (patch)
treee11b5af2259e167f74a8b885ff2eabb08516b03f
parent35a0d3ebf0fd0418218875a34c54beb5b4e01b34 (diff)
parent5a0d0dd8a020c73d7fe8bab59fe297e543eaef4a (diff)
Merge branch 'zj-praefect-prometheus' into 'master'
Enable Prometheus for praefect See merge request gitlab-org/gitaly!1108
-rw-r--r--changelogs/unreleased/zj-praefect-prometheus.yml5
-rw-r--r--cmd/praefect/main.go12
-rw-r--r--config.praefect.toml.example2
-rw-r--r--internal/praefect/config/config.go7
4 files changed, 23 insertions, 3 deletions
diff --git a/changelogs/unreleased/zj-praefect-prometheus.yml b/changelogs/unreleased/zj-praefect-prometheus.yml
new file mode 100644
index 000000000..dbc02885b
--- /dev/null
+++ b/changelogs/unreleased/zj-praefect-prometheus.yml
@@ -0,0 +1,5 @@
+---
+title: Add prometheus listener to Praefect
+merge_request: 1108
+author:
+type: added
diff --git a/cmd/praefect/main.go b/cmd/praefect/main.go
index 23e5aa89e..a6d99e080 100644
--- a/cmd/praefect/main.go
+++ b/cmd/praefect/main.go
@@ -6,11 +6,13 @@ import (
"flag"
"fmt"
"net"
+ "net/http"
"os"
"os/signal"
"syscall"
"time"
+ "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/internal/praefect"
"gitlab.com/gitlab-org/gitaly/internal/praefect/config"
@@ -60,6 +62,16 @@ func configure() (config.Config, error) {
logger = conf.ConfigureLogger()
tracing.Initialize(tracing.WithServiceName("praefect"))
+ if conf.PrometheusListenAddr != "" {
+ logger.WithField("address", conf.PrometheusListenAddr).Info("Starting prometheus listener")
+ promMux := http.NewServeMux()
+ promMux.Handle("/metrics", promhttp.Handler())
+
+ go func() {
+ http.ListenAndServe(conf.PrometheusListenAddr, promMux)
+ }()
+ }
+
return conf, nil
}
diff --git a/config.praefect.toml.example b/config.praefect.toml.example
index f21880772..9f041a3f3 100644
--- a/config.praefect.toml.example
+++ b/config.praefect.toml.example
@@ -3,6 +3,8 @@
# # TCP address to listen on
listen_addr = "127.0.0.1:2305"
# socket_path = "/home/git/gitlab/tmp/sockets/private/praefect.socket"
+#
+prometheus_listen_addr = "127.0.0.1:10101"
# # You can optionally configure Praefect to output JSON-formatted log messages to stdout
# [logging]
diff --git a/internal/praefect/config/config.go b/internal/praefect/config/config.go
index 7c58ef277..0aecae847 100644
--- a/internal/praefect/config/config.go
+++ b/internal/praefect/config/config.go
@@ -10,9 +10,10 @@ import (
// Config is a container for everything found in the TOML config file
type Config struct {
- ListenAddr string `toml:"listen_addr" split_words:"true"`
- GitalyServers []*GitalyServer `toml:"gitaly_server", split_words:"true"`
- Logging config.Logging `toml:"logging"`
+ ListenAddr string `toml:"listen_addr" split_words:"true"`
+ GitalyServers []*GitalyServer `toml:"gitaly_server", split_words:"true"`
+ Logging config.Logging `toml:"logging"`
+ PrometheusListenAddr string `toml:"prometheus_listen_addr", split_words:"true"`
}
// GitalyServer allows configuring the servers that RPCs are proxied to