← All writing

One colour, two themes: Zabbix dashboards that work in light and dark

Zabbix released version 8.0 LTS earlier this month. We still run 7.0, and this week I made our dashboards readable on both of Zabbix's themes. Before anyone plans that upgrade, here's what I learned, including one lesson that's about upgrades.

We have three Zabbix dashboards: one for a wall display in the office, one with the detail behind it for techs, and one for me. The techs use the light theme. The wall uses dark. And Zabbix stores one colour per widget setting and uses that same value on both.

What you need

  • Zabbix 7.0 and an API token that can edit dashboards
  • The background colours of both themes: the light card, the page ground and the dark card
  • A way to check contrast for every colour against every background (I put a small script for that on GitHub, linked at the end)
  • A way to deploy a custom stylesheet (I use an Ansible role)

One colour has to pass on three backgrounds

A graph line, a bar or a honeycomb fill needs 3:1 contrast against what's around it (WCAG 2.1, success criterion 1.4.11). Text needs 4.5:1. In most tools you'd pick one colour for light and another for dark. In a Zabbix widget you get one hex value, so every colour has to pass on white, on the light page ground and on the dark card at the same time.

That ruled out most of our design guide's palette. Its light-theme values failed on dark and its dark-theme values failed on white. The guide's first chart colour was 1.2:1 on the dark card, which is close to invisible. Only two of its colours reached 3:1 on all three backgrounds, so graph lines use those two and nothing else. For bars, I added a chart-only amber and red that sit between the guide's light and dark values, now written into the guide for tools like this.

Honeycomb cells have a different problem: one honeycomb has one label colour for every cell. So every fill has to be light enough to carry dark text, on either theme.

The theme overrides some of your choices

Picking good colours wasn't enough, because Zabbix makes some colour decisions by itself:

  • Honeycomb labels take their colour from the theme. On dark that's near-white, which on our light fills came out at about 1.5:1. A stylesheet forces dark labels instead (a label colour on the widget broke the grey "no data" cells).
  • Tinted value tiles keep their tint on dark but take the theme's light text. The stylesheet matches the tile's inline background colour and keeps the text dark.
  • A graph data set that matches many items gets shades Zabbix invents, from near-black to pale, and some disappear on each theme. You can't set them. Either give each item its own data set, or aggregate the set into one line.

For a "many hosts, one graph" widget, the one-line version looks like this in the data set:

"aggregate_function": 2,      // max
"aggregate_grouping": 1,      // combine all the items into one series
"data_set_label": "Highest"

A wall graph is there to show a sudden change, so the highest value is enough. One line per graph where possible, two at most.

Never colour alone

Contrast is only half of it. Status always has a word or a number as well as a colour, so a colour-blind tech or a washed-out wall screen gets the same message. Service cells use a Zabbix value map, so a cell reads "OK (2)" rather than just being green. Titles don't explain by colour ("green = running"). They say what the number means ("0 = reachable").

Change dashboards with a script

I didn't make these changes by hand in the editor. A Python script reads the live dashboards through the API, applies its rules (colour tables, titles, thresholds, layout) and writes back only what differs. It previews by default, backs everything up before applying, and can roll back. A second run finds nothing to do, so it's safe to re-run after a hand edit. Three things about the Zabbix API caught me out:

  • dashboard.update doesn't check field names. A misspelled field is saved and quietly ignored. Always look at the result in the browser.
  • It replaces every page you send. Send the whole dashboard back with each widget's ID, or widgets get recreated.
  • Widgets match items by name. Rename an item and any widget that named it shows nothing, with no error. It's happened to us twice. After a rename, search the dashboards for the old name.

The upgrade lesson

The fixes that aren't per-widget live in a marked block inside Zabbix's theme stylesheets, deployed by an Ansible role. Zabbix upgrades replace those stylesheets. So after every upgrade, the role has to run again, or the dashboards lose their look and some of their text contrast. It's in our notes as a step for the next upgrade, whenever that is.

One more trick: you can preview the dark theme without changing anyone's account by swapping the page's stylesheet link from blue-theme to dark-theme in your browser's developer tools. It shows everything the stylesheet controls, but not graph axis labels, which only look right from a real dark-theme sign-in.

Where it stands

The changes went live on November 24. I calculated the contrast for every colour pair, and the pages I checked pass on both themes. It isn't finished, though. Most of the detail pages haven't been opened on the dark theme yet, no automated accessibility scan or keyboard pass has been run on any dashboard, and the wall hasn't been checked on its real screen. Those are on my list.

Internal tools count, too. The DOJ's ADA Title II web rule covers a public school district's web content and apps, and the compliance dates were pushed back a year in April. A dashboard the techs look at all day is a good place to practise.

I put a small colour check script in my CtrlAltUpgrade repo. List your theme backgrounds and planned colours, and it flags every pair that fails.

The takeaway: if a tool gives you one colour for two themes, check it against every background it will sit on, then look at the real thing in both themes, because the tool will make some colour choices for you.