Sonar

live · 0.3.2internal

Keeping an eye on the server that runs everything else.

What it is

Sonar is a monitoring tool I built to keep track of my server and everything running on it.

It watches system resources, checks whether my services are healthy, and keeps a history of how things have been running. It’s also what provides the information for the status page on this website.

Why I made it

My server runs pretty much everything I build, so keeping it healthy is important.

As I started adding more projects, I wanted a better way to see what was happening behind the scenes. How much of the server’s resources were being used? Were all the containers running properly? Was anything starting to have problems?

I wanted one place where I could check on all of it.

Then I started thinking about the people using my projects.

If I already had all that information, why not make some of it available to them too?

Uptime and reliability matter when you’re deciding whether to use a service. I figured it would be nice for people to see how things were doing instead of just hoping everything was working.

That’s how Sonar became more than a personal monitoring tool.

How it works

Sonar runs alongside my other projects, collecting information about the server and the Docker containers running on it.

It tracks things like CPU, memory, disk usage, and container health. It also checks the public addresses of my services to see whether they’re actually responding, rather than just assuming everything is fine because a container is running.

That information is stored over time, so I can look back at how things were performing instead of only seeing what’s happening right now.

Sonar also keeps track of deployments, including when services were updated, which versions were involved, and whether the updates succeeded.

The system is split into a few parts. One collects information, another handles access to Docker, and an API makes the collected data available to other projects.

That API is how Mobasity.com gets the information for its status page.

I also wanted a clear separation between observing the server and controlling it. Sonar only monitors and reports what it finds. Lighthouse is responsible for deployments and making changes.

Where it’s at

Sonar has moved well beyond the planning stage.

The core monitoring system is built, with resource tracking, service health checks, historical uptime, and deployment information.

I’ve also connected the website’s status page to Sonar, so it can display the information the monitoring system collects instead of relying on example data.

I’m still improving it as I go. Recent work has focused on tracking which versions of my projects are running and making sure deployments are recorded accurately, including updates to Sonar itself.

There’s plenty more I could add, but the foundation I originally wanted is now in place.

Changelog

0.3.2latest1 new · 2 fixes

added

  • Each outside check records where its time went: looking up the address, connecting, the TLS handshake, waiting for the site and reading the answer. A degraded stretch in /v1/monitor/states gives its slowest answer split that way, so a slow site can be told from a slow network, and sonar states says which phase took longest.

fixed

  • A single answer slower than 2 seconds no longer marks a project degraded: like failures, slow answers need two in a row. One slow answer made every site flap for a minute or two.
  • Every degraded stretch names its cause. A check that turned slow at the end of one minute kept the project degraded into the next, but that minute recorded no cause.
0.3.11 new

added

  • Each point in the host history gives minute_min and minute_max for CPU and memory: the quietest and busiest one-minute average in the bucket. A chart can shade the range a minute actually reached, so a few seconds of a build no longer show as 100% on every range. min and max are unchanged. The owner’s host chart has them too.
0.3.010 new · 4 changes

added

  • A second API consumer, Vista, with its own token, and owner endpoints under monitor:read: every project’s status (the ones the status page leaves out too), each project now with its containers, restarts and checks, Spark’s conditions, state changes with what wasn’t up, host and per-service history, databases, disk use, traffic and the apps’ reports. The README lists them.
  • Spark’s own conditions, such as a full disk, heavy swap, sparkdb near its connection limit or an infrastructure project down, each with a level and since when. sonar status lists them.
  • The host’s network traffic per interface, read from the host’s network counters alone.
  • Each database’s size and connections on sparkdb, read by a new role, sonar_monitor, that sees statistics only.
  • What each project keeps on disk (its data folder, its own image layers, its containers and volumes), measured every 30 minutes and kept for 380 days.
  • Each site’s requests, 5xx answers and bytes from Cloudflare, by hour, kept for 380 days.
  • App reports: an app labelled com.mobasity.report-port serves its usage counters and feature checks, and Sonar keeps how each counter grows and when each check changes.
  • The com.mobasity.check-path label checks a site at another path, for a site behind a sign-in; com.mobasity.group: infrastructure marks a project Spark depends on.
  • Each outside check’s last error is kept with its minute, so an incident can say why.
  • CLI commands databases, disk, traffic, apps and states.

changed

  • sonar-agent needs SONAR_DATABASE_MONITOR_URL and SONAR_CLOUDFLARE_TOKEN, and sonar-api needs SHARED_SONAR_VISTA_TOKEN; each refuses to start without its keys.
  • The image runs as user 10001; only sonar-proxy, which reads the Docker socket and sizes the data folders, runs as root.
  • Built with Go 1.27.4, which fixes a crash in Go’s HTTP server.
  • An MIT license, and a README that covers setup, settings, labels, the API and app reports.
0.2.51 new

added

  • Each day in the status gives its minute counts: observed_minutes, degraded_minutes and down_minutes, so a page can show exactly how long a project was degraded or down. They are 0 on a day with nothing observed, never null.
0.2.42 changes

changed

  • lucassariol-web is left off the public status, like the database and the Cloudflare tunnel. Sonar still monitors it.
  • Logs follow Spark’s logging standard: one JSON line per record, with errors under err, so Blackbox can search and filter them. A part of Sonar that can’t start says why in its log before it exits.

all releases on GitHub

More to look at

all projects
  • Lighthouse

    live · 1.6.1internal

    I push code to GitHub, and my server takes it from there.

  • Cove

    live · 1.0.4internal

    My own little vault for the passwords, keys, and secrets my projects need.

  • CoveClient

    live · 1.0.0Go library

    One consistent way for my Go projects to communicate with Cove.