Prometheus and Spring Boot Health Checks

When trying to set up alerting for Spring Boot services with Prometheus, I discovered the synthetic “up” time series which is great for checking whether the monitoring system can reach my service instances. While this is a great thing, I also wanted to alert on the health status of my instances, as reported by /actuator/health. Unfortunately, there is nothing in Spring Boot’s /actuator/prometheus endpoint that I could use.

Continue reading

Posted in java | Tagged | 9 Comments

DNS Over HTTPS

With much of the web switching to HTTPS and at least some people becoming more concerned about privacy, DNS has recently come into the spotlight because it provides an ISP with the ability to monitor which websites a user visits. Multiple mitigations have been proposed – Android for example is going to support DNS Over TLS, which tunnels good old DNS payload over TLS. And now there is a working group at the IETF developing DNS Over HTTPS (DoH), which layers DNS on top of HTTP/2.

Continue reading

Posted in misc | Tagged , , | 2 Comments

A Quick Introduction to sed(1)

The sed(1) stream editor is one of the most powerful tools from the classic Unix tool box. It is a close cousin to the ed(1) command line editor and a descendant of the ex(1) editor, the command line mode of vi(1). In this article I’ll show a few idioms that I frequently use in practice.

Continue reading

Posted in shell, tools | Tagged , , | Leave a comment

Spring Boot: Logging Failed Logins

In many applications it’s important to react to failed logins and other security-critical events, for example to log the failed login attempt to a file or to display a captcha after repeated failures. Spring-based applications come with a simple mechanism to access this kind of information using Application Events.

Continue reading

Posted in java | Tagged , | 11 Comments

The Curse of Convenience Methods

In the old days, many Java APIs were fairly low level and pretty generic. You often had to explicitly select a concrete implementation, provide lots of parameters, and generally needed to know how things worked. This has changed in recent years – modern APIs provide lots of convenience functionality that raises the level of abstraction and increases productivity. I like this as much as anybody else, but unfortunately it can also lead to subtle bugs.

Continue reading

Posted in best practices, java | Tagged , , | Leave a comment

Empty InputStream with Spring MVC

The other day, I was trying to build a simple batch upload interface for a Java web application running Spring Boot with Spring MVC on Apache Tomcat. But when I tried reading the InputStream in my controller, it was always empty. Fortunately, this turned out to be quite easy to fix.

Continue reading

Posted in java | Tagged , , | Leave a comment

Checking Whether a Process Exists

On Linux/Unix systems, there’s occasionally the need to check whether a process is running. Some people use it for simple status checks or when building their own lifecycle scripts for startup and shutdown. I don’t think it’s a particularly good practice these days because all of this can be achieved with tools like systemd, supervisord, JavaServiceWrapper, or even Docker. But if you can’t use these for some reason, read on.

Continue reading

Posted in linux | Tagged , | Leave a comment

Detecting Security Upgrades on Ubuntu

In my article on unattended upgrades I described how to set up an Ubuntu system to install security upgrades automatically. This is convenient for small setups, but in an enterprise environment you typically want to perform some QA before applying the change. A better solution is to have your monitoring system generate an alert if security upgrades are available. In this article,  we’re going to build an Icinga plugin to hook into your monitoring/alerting system.

Continue reading

Posted in linux | Tagged , , , | Leave a comment