Skip to content

Commit

Permalink
Expose ring and memberlist handlers through internal server listener (g…
Browse files Browse the repository at this point in the history
  • Loading branch information
periklis authored and lxwzy committed Nov 7, 2022
1 parent 9962204 commit eae1132
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Loki

##### Enhancements
* [7436](https://github.com/grafana/loki/pull/7436) **periklis**: Expose ring and memberlist handlers through internal server listener
* [7346](https://github.com/grafana/loki/pull/7346) **mostafa**: Clarify how and where to download the Loki config file from
* [7227](https://github.com/grafana/loki/pull/7227) **Red-GV**: Add ability to configure tls minimum version and cipher suites
* [7179](https://github.com/grafana/loki/pull/7179) **vlad-diachenko**: Add ability to use Azure Service Principals credentials to authenticate to Azure Blob Storage.
Expand Down
32 changes: 31 additions & 1 deletion pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ func (t *Loki) initRing() (_ services.Service, err error) {
return
}
t.Server.HTTP.Path("/ring").Methods("GET", "POST").Handler(t.ring)

if t.Cfg.InternalServer.Enable {
t.InternalServer.HTTP.Path("/ring").Methods("GET").Handler(t.ring)
}
return t.ring, nil
}

Expand Down Expand Up @@ -344,6 +348,10 @@ func (t *Loki) initDistributor() (services.Service, error) {

t.Server.HTTP.Path("/distributor/ring").Methods("GET", "POST").Handler(t.distributor)

if t.Cfg.InternalServer.Enable {
t.InternalServer.HTTP.Path("/distributor/ring").Methods("GET").Handler(t.distributor)
}

t.Server.HTTP.Path("/api/prom/push").Methods("POST").Handler(pushHandler)
t.Server.HTTP.Path("/loki/api/v1/push").Methods("POST").Handler(pushHandler)
return t.distributor, nil
Expand Down Expand Up @@ -930,8 +938,12 @@ func (t *Loki) initRuler() (_ services.Service, err error) {

// Expose HTTP endpoints.
if t.Cfg.Ruler.EnableAPI {

t.Server.HTTP.Path("/ruler/ring").Methods("GET", "POST").Handler(t.ruler)

if t.Cfg.InternalServer.Enable {
t.InternalServer.HTTP.Path("/ruler/ring").Methods("GET").Handler(t.ruler)
}

base_ruler.RegisterRulerServer(t.Server.GRPC, t.ruler)

// Prometheus Rule API Routes
Expand Down Expand Up @@ -992,6 +1004,10 @@ func (t *Loki) initMemberlistKV() (services.Service, error) {

t.Server.HTTP.Handle("/memberlist", t.MemberlistKV)

if t.Cfg.InternalServer.Enable {
t.InternalServer.HTTP.Path("/memberlist").Methods("GET").Handler(t.MemberlistKV)
}

return t.MemberlistKV, nil
}

Expand Down Expand Up @@ -1023,6 +1039,10 @@ func (t *Loki) initCompactor() (services.Service, error) {
t.compactor.RegisterIndexCompactor(config.TSDBType, tsdb.NewIndexCompactor())
t.Server.HTTP.Path("/compactor/ring").Methods("GET", "POST").Handler(t.compactor)

if t.Cfg.InternalServer.Enable {
t.InternalServer.HTTP.Path("/compactor/ring").Methods("GET").Handler(t.compactor)
}

if t.Cfg.CompactorConfig.RetentionEnabled {
t.Server.HTTP.Path("/loki/api/v1/delete").Methods("PUT", "POST").Handler(t.addCompactorMiddleware(t.compactor.DeleteRequestsHandler.AddDeleteRequestHandler))
t.Server.HTTP.Path("/loki/api/v1/delete").Methods("GET").Handler(t.addCompactorMiddleware(t.compactor.DeleteRequestsHandler.GetAllDeleteRequestsHandler))
Expand Down Expand Up @@ -1081,6 +1101,11 @@ func (t *Loki) initIndexGatewayRing() (_ services.Service, err error) {
t.indexGatewayRingManager = rm

t.Server.HTTP.Path("/indexgateway/ring").Methods("GET", "POST").Handler(t.indexGatewayRingManager)

if t.Cfg.InternalServer.Enable {
t.InternalServer.HTTP.Path("/indexgateway/ring").Methods("GET").Handler(t.indexGatewayRingManager)
}

return t.indexGatewayRingManager, nil
}

Expand All @@ -1096,6 +1121,11 @@ func (t *Loki) initQueryScheduler() (services.Service, error) {
schedulerpb.RegisterSchedulerForFrontendServer(t.Server.GRPC, s)
schedulerpb.RegisterSchedulerForQuerierServer(t.Server.GRPC, s)
t.Server.HTTP.Path("/scheduler/ring").Methods("GET", "POST").Handler(s)

if t.Cfg.InternalServer.Enable {
t.InternalServer.HTTP.Path("/scheduler/ring").Methods("GET").Handler(s)
}

t.queryScheduler = s
return s, nil
}
Expand Down

0 comments on commit eae1132

Please sign in to comment.