8000 cert-manager: Every certificate and issuer, not only the ones in trouble by andsens · Pull Request #17 · nixos-homelab/shared · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 68 additions & 71 deletions nix/modules/cert-manager/grafana.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,66 @@
# cert-manager's row of the Cluster dashboard: certificates by days left, those not ready, issuers not ready
# cert-manager's rows of the Services and Cluster dashboards: every certificate's days left and ready state, and on
# Cluster the issuers' ready state
{ inputs, ... }:
{ config, lib, ... }:
let
g = inputs.homelab-monitoring.lib.grafana;
ready = {
type = "value";
options = {
"0" = {
text = "Not ready";
color = "red";
};
"1" = {
text = "Ready";
color = "green";
};
};
};
daysLeft = g.bargauge {
title = "Days left";
description = "Each certificate's time to expiry; cert-manager renews at two thirds of its life";
unit = "d";
queries = [
(g.prom "sort((certmanager_certificate_expiration_timestamp_seconds - time()) / 86400)" {
instant = true;
legend = "{{exported_namespace}}/{{name}}";
})
];
thresholds = [
{
value = null;
color = "red";
}
{
value = 7;
color = "orange";
}
{
value = 21;
color = "green";
}
];
};
certificatesReady = g.stat {
title = "Ready";
queries = [
(g.prom ''certmanager_certificate_ready_status{condition="True"}'' {
instant = true;
legend = "{{exported_namespace}}/{{name}}";
})
];
mappings = [ ready ];
options = {
textMode = "value_and_name";
colorMode = "background";
};
};
in
{
imports = [ inputs.homelab-monitoring.nixosModules.grafana ];
options.homelab.cert-manager.grafana.enable = lib.mkOption {
description = "Whether the Cluster dashboard has cert-manager's row.";
description = "Whether the Services and Cluster dashboards have cert-manager's rows.";
type = lib.types.bool;
default =
config.homelab.cert-manager.metrics.enable
Expand All @@ -24,39 +77,8 @@ in
order = 300;
row = g.row { title = "Certificates"; } (
g.autoGrid { columns = 2; } [
(g.bargauge {
title = "Expiring within 30 days";
description = "cert-manager renews at two thirds of a certificate's life, so one here is overdue or about to be renewed";
unit = "d";
queries = [
(g.prom "sort((certmanager_certificate_expiration_timestamp_seconds - time()) / 86400 < 30)" {
instant = true;
legend = "{{exported_namespace}}/{{name}}";
})
];
thresholds = [
{
value = null;
color = "red";
}
{
value = 7;
color = "orange";
}
8000 {
value = 21;
color = "green";
}
];
noValue = "None";
})
(g.table {
title = "Not ready";
queries = [
(g.prom ''certmanager_certificate_ready_status{condition="True"} == 0'' { instant = true; })
];
noValue = "None";
})
daysLeft
certificatesReady
]
);
};
Expand All @@ -67,49 +89,24 @@ in
order = 300;
row = g.row { title = "Certificates"; } (
g.autoGrid { columns = 3; } [
(g.bargauge {
title = "Days left";
description = "Each certificate's time to expiry; cert-manager renews at two thirds of its life";
unit = "d";
queries = [
(g.prom "sort((certmanager_certificate_expiration_timestamp_seconds - time()) / 86400)" {
instant = true;
legend = "{{exported_namespace}}/{{name}}";
})
];
thresholds = [
{
value = null;
color = "red";
}
{
value = 7;
color = "orange";
}
{
value = 21;
color = "green";
}
];
})
(g.table {
title = "Not ready";
queries = [
(g.prom ''certmanager_certificate_ready_status{condition="True"} == 0'' { instant = true; })
];
noValue = "None";
})
(g.table {
title = "Issuers not ready";
daysLeft
certificatesReady
(g.stat {
title = "Issuers";
queries = [
(g.prom
''certmanager_clusterissuer_ready_status{condition="True"} == 0 or certmanager_issuer_ready_status{condition="True"} == 0''
''certmanager_clusterissuer_ready_status{condition="True"} or certmanager_issuer_ready_status{condition="True"}''
{
instant = true;
legend = "{{name}}";
}
)
];
noValue = "None";
mappings = [ ready ];
options = {
textMode = "value_and_name";
colorMode = "background";
};
})
]
);
Expand Down
Loading
0