Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add health check endpoint to Proxy #376

Merged
merged 2 commits into from
Mar 5, 2025
Merged
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 pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ func (p *Proxy) forwardRequest(acct *account.Account, w http.ResponseWriter, req
func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Info("Received %s request for %s", req.Method, req.URL.Path)

if req.URL.Path == "/health" {
p.handleHealthCheck(w, req)
return
}

acct, err := getAccount(req)
if err != nil {
writeJSONError(w, http.StatusForbidden, err)
Expand Down Expand Up @@ -331,6 +336,15 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {
p.forwardRequest(acct, w, req)
}

func (p *Proxy) handleHealthCheck(w http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodGet {
writeJSONError(w, http.StatusMethodNotAllowed, nil)
return
}
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
}

func (p *Proxy) handleFleetTelemetryConfig(acct *account.Account, w http.ResponseWriter, req *http.Request) {
log.Info("Processing fleet telemetry configuration...")
defer func() {
Expand Down
Loading