Skip to content

Commit

Permalink
Merge pull request #560 from frezes/feat/develop
Browse files Browse the repository at this point in the history
add /api/v1/write endpoint in whizard-agent-proxy and it will be rewritten to gateway /api/v1/receive endpoint
  • Loading branch information
benjaminhuo authored Jul 24, 2024
2 parents 4038f4d + a70a321 commit 344f2c1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/monitoring-agent-proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const (
series = "/api/v1/series"
labels = "/api/v1/labels"
labelValues = "/api/v1/label/*path"
receive = "/api/v1/receive"
receive = "/api/v1/receive" // thanos receive endpoint
write = "/api/v1/write" // prometheus remote write endpoint
rules = "/api/v1/rules"
alerts = "/api/v1/alerts"
)
Expand Down Expand Up @@ -67,6 +68,7 @@ func NewServer(logger log.Logger, opt *Options) *Server {
// s.router.Get(alerts, s.wrap(alerts))

s.router.Post(receive, s.wrap())
s.router.Post(write, s.wrap())

return s
}
Expand All @@ -78,6 +80,10 @@ func (s *Server) Router() *route.Router {
func (s *Server) wrap() http.HandlerFunc {

return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
// rewrite /api/v1/write to /api/v1/receive
if req.URL.Path == write {
req.URL.Path = receive
}

if s.options.Tenant != "" {
// add the prefix /:tenant_id from path
Expand Down

0 comments on commit 344f2c1

Please sign in to comment.