252 lines
6.1 KiB
Nix
252 lines
6.1 KiB
Nix
{ pkgs, lib }:
|
|
let
|
|
inherit (import ./helpers.nix { inherit pkgs lib; }) prom mkDashboard;
|
|
in
|
|
mkDashboard {
|
|
name = "containers.json";
|
|
title = "Containers";
|
|
uid = "containers";
|
|
from = "now-3h";
|
|
panels = [
|
|
{
|
|
title = "Container States";
|
|
type = "piechart";
|
|
gridPos = {
|
|
h = 8;
|
|
w = 8;
|
|
};
|
|
datasource = prom;
|
|
options = {
|
|
pieType = "donut";
|
|
legend = {
|
|
displayMode = "table";
|
|
placement = "right";
|
|
values = [
|
|
"value"
|
|
"percent"
|
|
];
|
|
};
|
|
tooltip.mode = "single";
|
|
};
|
|
fieldConfig.overrides = [
|
|
{
|
|
matcher = {
|
|
id = "byName";
|
|
options = "active";
|
|
};
|
|
properties = [
|
|
{
|
|
id = "color";
|
|
value = {
|
|
mode = "fixed";
|
|
fixedColor = "green";
|
|
};
|
|
}
|
|
];
|
|
}
|
|
{
|
|
matcher = {
|
|
id = "byName";
|
|
options = "failed";
|
|
};
|
|
properties = [
|
|
{
|
|
id = "color";
|
|
value = {
|
|
mode = "fixed";
|
|
fixedColor = "red";
|
|
};
|
|
}
|
|
];
|
|
}
|
|
{
|
|
matcher = {
|
|
id = "byName";
|
|
options = "inactive";
|
|
};
|
|
properties = [
|
|
{
|
|
id = "color";
|
|
value = {
|
|
mode = "fixed";
|
|
fixedColor = "blue";
|
|
};
|
|
}
|
|
];
|
|
}
|
|
{
|
|
matcher = {
|
|
id = "byName";
|
|
options = "activating";
|
|
};
|
|
properties = [
|
|
{
|
|
id = "color";
|
|
value = {
|
|
mode = "fixed";
|
|
fixedColor = "yellow";
|
|
};
|
|
}
|
|
];
|
|
}
|
|
{
|
|
matcher = {
|
|
id = "byName";
|
|
options = "unknown";
|
|
};
|
|
properties = [
|
|
{
|
|
id = "color";
|
|
value = {
|
|
mode = "fixed";
|
|
fixedColor = "gray";
|
|
};
|
|
}
|
|
];
|
|
}
|
|
];
|
|
targets = [
|
|
{
|
|
datasource = prom;
|
|
expr = ''count by (state) ((label_replace(node_systemd_unit_state{name=~"container@.*"} == 1, "container", "$1", "name", "container@(.+)\\.service")) or on(container) label_replace(container_defined, "state", "unknown", "container", ".+"))'';
|
|
instant = true;
|
|
legendFormat = "{{state}}";
|
|
}
|
|
];
|
|
}
|
|
{
|
|
title = "Container States";
|
|
type = "table";
|
|
gridPos = {
|
|
h = 16;
|
|
w = 24;
|
|
};
|
|
datasource = prom;
|
|
options.footer.show = false;
|
|
fieldConfig = {
|
|
defaults = { };
|
|
overrides = [
|
|
{
|
|
matcher = {
|
|
id = "byName";
|
|
options = "State";
|
|
};
|
|
properties = [
|
|
{
|
|
id = "custom.displayMode";
|
|
value = "color-text";
|
|
}
|
|
{
|
|
id = "mappings";
|
|
value = [
|
|
{
|
|
type = "value";
|
|
options.active = {
|
|
text = "active";
|
|
color = "green";
|
|
index = 0;
|
|
};
|
|
}
|
|
{
|
|
type = "value";
|
|
options.failed = {
|
|
text = "failed";
|
|
color = "red";
|
|
index = 1;
|
|
};
|
|
}
|
|
{
|
|
type = "value";
|
|
options.activating = {
|
|
text = "activating";
|
|
color = "yellow";
|
|
index = 2;
|
|
};
|
|
}
|
|
{
|
|
type = "value";
|
|
options.inactive = {
|
|
text = "inactive";
|
|
color = "blue";
|
|
index = 3;
|
|
};
|
|
}
|
|
{
|
|
type = "value";
|
|
options.unknown = {
|
|
text = "unknown";
|
|
color = "gray";
|
|
index = 4;
|
|
};
|
|
}
|
|
];
|
|
}
|
|
];
|
|
}
|
|
];
|
|
};
|
|
targets = [
|
|
{
|
|
datasource = prom;
|
|
expr = ''
|
|
(label_replace(node_systemd_unit_state{name=~"container@.*"} == 1, "container", "$1", "name", "container@(.+)\\.service"))
|
|
or on(container)
|
|
label_replace(container_defined, "state", "unknown", "container", ".+")
|
|
'';
|
|
instant = true;
|
|
format = "table";
|
|
legendFormat = "__auto";
|
|
}
|
|
];
|
|
transformations = [
|
|
{
|
|
id = "organize";
|
|
options = {
|
|
excludeByName = {
|
|
Time = true;
|
|
Value = true;
|
|
"__name__" = true;
|
|
instance = true;
|
|
job = true;
|
|
name = true;
|
|
};
|
|
renameByName = {
|
|
container = "Container";
|
|
state = "State";
|
|
};
|
|
};
|
|
}
|
|
];
|
|
}
|
|
{
|
|
title = "Container State (1 = running, 0 = stopped/failed)";
|
|
type = "timeseries";
|
|
gridPos = {
|
|
h = 8;
|
|
w = 24;
|
|
};
|
|
datasource = prom;
|
|
fieldConfig.defaults = {
|
|
custom.lineWidth = 2;
|
|
color.mode = "palette-classic";
|
|
min = 0;
|
|
max = 1;
|
|
};
|
|
options = {
|
|
tooltip.mode = "multi";
|
|
legend = {
|
|
displayMode = "table";
|
|
placement = "bottom";
|
|
};
|
|
};
|
|
targets = [
|
|
{
|
|
datasource = prom;
|
|
expr = ''label_replace(node_systemd_unit_state{name=~"container@.*",state="active"}, "container", "$1", "name", "container@(.+).service")'';
|
|
legendFormat = "{{container}}";
|
|
}
|
|
];
|
|
}
|
|
];
|
|
}
|