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

Change /ping endpoint to /healthz #167

Merged
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ Go templates also support some basic methods for text manipulation which can be
Different URI (handlers) are available :

* `/` : main and default handler, your falco config must be configured to use it
* `/ping` : you will get a `pong` as answer, useful to test if falcosidekick is running and its port is opened (for healthcheck purpose for example)
* `/ping` : you will get a `pong` as answer, useful to test if falcosidekick is running and its port is opened (for healthcheck purpose for example). This endpoint is deprecated and it will be removed in `3.0.0`.
* `/healthz`: you will get a HTTP status code `200` response as answer, useful to test if falcosidekick is running and its port is opened (for healthcheck or purpose for example)
* `/test` : (for debug only) send a test event to all enabled outputs.
* `/debug/vars` : get statistics from daemon (in JSON format), it uses classic `expvar` package and some custom values are added
* `/metrics` : prometheus endpoint, for scraping metrics about events and `falcosidekick`
Expand Down
6 changes: 6 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ func pingHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("pong\n"))
}

// healthHandler is a simple handler to test if daemon is UP.
func healthHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
w.Write([]byte("{\"status\": \"ok\"}"))
}

// testHandler sends a test event to all enabled outputs.
func testHandler(w http.ResponseWriter, r *http.Request) {
r.Body = ioutil.NopCloser(bytes.NewReader([]byte(`{"output":"This is a test from falcosidekick","priority":"Debug","rule":"Test rule", "time":"` + time.Now().UTC().Format(time.RFC3339) + `","outputfields": {"proc.name":"falcosidekick","user.name":"falcosidekick"}}`)))
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ func init() {
func main() {
http.HandleFunc("/", mainHandler)
http.HandleFunc("/ping", pingHandler)
http.HandleFunc("/healthz", healthHandler)
http.HandleFunc("/test", testHandler)
http.Handle("/metrics", promhttp.Handler())

Expand Down