Posts Tagged ‘ elasticsearch ’

Improving the MakeAPI healthcheck

For OSD600 we have to choose a bug from the list and try and make significant progress towards fixing it. I prefer working on server side issues so I selected Bug 864942. The bug involves modifying the existing MakeAPI /healthcheck endpoint so that it does Basic Authentication (now Hawk Authentication) and then also checks the health of the linked ElasticSeach (ES) and MongoDB (DB) components. The bug also requires that if ?healthcheck?elb=true is requested it will return the existing 200 status code with no authentication required.

I decided to start off small because I’m new to nodejs and the webmaker project so I started with checking a property in the query string. I looked up the ExpressJS documentation and specifically the section on req.query. It turns out it is very easy to look for an “elb” property, all that is required is if (req.query.elb === "true") {//do something}. One part down.

The next thing I tackled was authenticating though HawkAuth. Unfortunately this caused some difficulties because in order to have both an unauthenticated and authenticated /healthcheck endpoint I have to break one of two conventions that the existing code follows. On one side I could add a /healthcheck/elb route and then add authenticate the /healthcheck route so that it follows the existing authentication format. The problem with this solution is that the current path for elb is /healthcheck?elb=true so any monitoring applications would have to be modified to work with the new URL format (/healthcheck/elb). The other possible solution is to perform the authentication in the /healthcheck endpoint method. The problem with this though is that all of the existing authentication is done in one file, server.js. It also means that I have to make quite a few extra changes so that I can include middleware.js. I decided to go with the second option because I feel that breaking the URL convention would be more potentially damaging to the other applications in the Webmaker ecosystem. I am interested to see if my approach will pass review because it’s definitely different from the previous functionality.

The first two parts were relatively simple to implement and they didn’t take a whole lot of thought. The second half of the bug though is a lot more difficult and is proving much more vexing.

I first tried to tackle the MongoDB stats. I talked with jp, the devops guys for the Webmaker project, in the #webmaker channel and he showed me the existing web-apps, Opsview Core and New Relic, that they use to keep tabs on the states of the various nodes. For MongoDB they keep track of various processes, load, and swap. This poses an issue for my bug though because the only way to get the aforementioned data is by having an agent running on each server that reports back to a web application, in my case nodejs, and that isn’t really a feasible solution in my situation. The other thing to consider is that the data is already being tracked separately from the MakeAPI nodes so why bother adding duplicate information to the /healthcheck call when it’s not needed. So getting the DB stats was put on the back burner.

The last part is the Elasticsearch stats. When I was looking through the monitoring apps I noticed that ES monitoring wasn’t anywhere to be found. I asked jp about it and he seemed surprised that it was missing as well. This brought up some questions of, “Well is ES monitoring even needed?” and it seems like at the moment it isn’t. I could always add it in, but if it’s not going to be used why bother.

After early success I had hit a roadblock. I asked Dave Humphrey about what to do because now I seemingly was stuck with a bug that didn’t need to be done after all. He suggested that I get in touch with Jon Buckley and ask him what his thoughts were. I contacted him the next morning and he seemed stumped as well. He said that he needed to talk to jp himself and left it at that.

At this point I’m not really sure what to do, but I guess I’ll just wait it out.