Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ If you are still using the legacy [Access scopes][access-scopes], the `https://w
| `web.systemd-socket` | No | | Use systemd socket activation listeners instead of port listeners (Linux only). |
| `web.stackdriver-telemetry-path` | No | `/metrics` | Path under which to expose Stackdriver metrics. |
| `web.telemetry-path` | No | `/metrics` | Path under which to expose Prometheus metrics |
| `web.health-check-path` | No | `/heath` | Path under which to expose health check |

### TLS and basic authentication

Expand Down
11 changes: 11 additions & 0 deletions stackdriver_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ var (
"web.stackdriver-telemetry-path", "Path under which to expose Stackdriver metrics.",
).Default("/metrics").String()

healthCheckPath = kingpin.Flag(
"web.health-check-path", "Path under which to expose health check.",
).Default("/health").String()

projectID = kingpin.Flag(
"google.project-id", "DEPRECATED - Comma seperated list of Google Project IDs. Use 'google.project-ids' instead.",
).String()
Expand Down Expand Up @@ -275,6 +279,8 @@ func main() {
kingpin.HelpFlag.Short('h')
kingpin.Parse()

http.HandleFunc(*healthCheckPath, healthCheckHandler)

logger := promslog.New(promslogConfig)
if *projectID != "" {
logger.Warn("The google.project-id flag is deprecated and will be replaced by google.project-ids.")
Expand Down Expand Up @@ -432,3 +438,8 @@ func parseMetricExtraFilters() []collectors.MetricFilter {
}
return extraFilters
}

func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
}