Skip to content

Commit 103e4e4

Browse files
committed
Expose prometheus metrics in path /prometheus
/metrics was already taken
1 parent 9819b2a commit 103e4e4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/com/gitblit/guice/WebModule.java

+8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
import com.gitblit.servlet.SyndicationServlet;
4545
import com.gitblit.wicket.GitblitWicketFilter;
4646
import com.google.common.base.Joiner;
47+
import com.google.inject.Scopes;
4748
import com.google.inject.servlet.ServletModule;
49+
import io.prometheus.client.exporter.MetricsServlet;
50+
import io.prometheus.client.hotspot.DefaultExports;
4851

4952
/**
5053
* Defines all the web servlets & filters.
@@ -79,6 +82,11 @@ protected void configureServlets() {
7982
serve("/robots.txt").with(RobotsTxtServlet.class);
8083
serve("/logo.png").with(LogoServlet.class);
8184

85+
// Prometheus
86+
bind(MetricsServlet.class).in(Scopes.SINGLETON);
87+
serve("/prometheus").with(MetricsServlet.class);
88+
DefaultExports.initialize();
89+
8290
/* Prevent accidental access to 'resources' such as GitBlit java classes
8391
*
8492
* In the GO setup the JAR containing the application and the WAR injected

0 commit comments

Comments
 (0)