Nick Fisher's tech blog

PostgreSQL

How to Expose Meaningful Prometheus Metrics In a Spring Boot 2.x Application

The source code for this post can be found on Github.

Prometheus is a metrics aggregator with its own presumed format. The basic idea is to have the application gather a set of custom metrics, then periodically collect (or “scrape”) the metrics and send them off to a prometheus server. This server will store the data in its database, and you can thus view the evolution of your application’s metrics over time.

How to Migrate An Embedded PostgreSQL Database Using Flyway in Spring Boot

The source code for this post can be found on GitHub.

Flyway is a database migration tool. Migrating a database generally means that you are making a change to the way the database currently structures its data. It could also mean you are adding stuff like custom stored procedures or indexes to help speed up queries. Either way, migrating databases is easily the most difficult part of any deployment strategy–Flyway makes this process as painless as possible because it will, by default, only run migration scripts that haven’t yet run.

How to run a SQL Script Against a Postgres Database Using Ansible

The source code for this post can be found on GitHub.

Managing a live database, and in particular dealing with database migrations without allowing for any downtime in your application, is typically the most challenging part of any automated deployment strategy. Services can be spun up and down with impunity because their state at the beginning and at the end are exactly the same, but databases store data–their state is always changing.

How to Set Up a Local Unsecured Postgres Virtual Machine (for testing)

The sample code for this post can be found on GitHub.

While we can always install PostgreSQL on our host machine, it’s a much cleaner solution to create something like a local virtual machine with Vagrant or a container using Docker. That way, any changes we make to the database and then forget about are not around as soon as we destroy either the container or the virtual machine. It is one more way to tighten that feedback loop we need as developers.