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/ready endpoints #116

Merged

Conversation

karlhungus
Copy link
Contributor

Problem

I wanted to have a k8s pod for running my cloud watch exporter, but no readiness/health endpoint exists

Solution

Add one. These seem a little bit silly (they both just respond if the server is running, and don't say anything about the status of the connection to AWS (I took inspiration from prometheus: https://github.com/prometheus/prometheus/blob/2bd510a63e48ac6bf4971d62199bdb1045c93f1a/web/web.go#L297-L304)

This also addresses: #32, which was closed but... @brian-brazil

@karlhungus karlhungus force-pushed the add_health_and_ready_endpoints branch 2 times, most recently from 83d98a2 to 585f43e Compare June 27, 2018 13:15
Signed-off-by: Izaak Alpert (karlhungus) <ialpert@salesforce.com>

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html");
resp.getWriter().print("OK");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't valid HTML.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, i took inspiration from the prometheus health endpoint, which I don't believe is valid html either... would:

<html>ok</html>

be sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to text/plain is simplest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess to be html valid it'd have to be:

<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>cloudwatch exporter</title>
</head>
<body>ok
</body>
</html>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, i'm not a smart man :)

@karlhungus karlhungus force-pushed the add_health_and_ready_endpoints branch from 6ba6c6a to 46bb237 Compare June 27, 2018 13:38
Signed-off-by: Izaak Alpert (karlhungus) <ialpert@salesforce.com>
Signed-off-by: Izaak Alpert (karlhungus) <ialpert@salesforce.com>
@brian-brazil brian-brazil merged commit 6803933 into prometheus:master Jun 27, 2018
@brian-brazil
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants