egress dashboard: tabs like the agents board, with totals on the first
The board was one page of would-deny panels. It now has three tabs: overview (requests, agents active, refused, credential challenges, data transferred, status over time, busiest agents and destinations), refused (the hosts each agent was refused) and would-deny (the old panels). The module-eval check pins the tab layout and both squid log layouts the queries parse.
This commit is contained in:
parent
9193f37963
commit
6b0c06800b
2 changed files with 1860 additions and 276 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -453,25 +453,43 @@ let
|
|||
&& lib.all (m: lib.hasInfix "\"${m}\"" recorded) queried;
|
||||
}
|
||||
{
|
||||
# The egress board ships, and the `extract` pattern its queries use is the
|
||||
# field layout of the `would_deny` line squid logs: a changed `logformat`
|
||||
# is a board of empty panels.
|
||||
name = "the egress dashboard ships, and reads the field layout of squid's would_deny log line";
|
||||
# The egress board ships, and its queries read the two squid log lines as
|
||||
# squid writes them: the would_deny line's field layout, and the default
|
||||
# `squid` access format the overview and refused tabs parse. A changed
|
||||
# `logformat` or `access_log` is a board of empty panels.
|
||||
name = "the egress dashboard ships, and reads the field layout of squid's log lines";
|
||||
ok =
|
||||
let
|
||||
provider = lib.head grafanaWithAuthelia.containers.swarm-grafana.config.services.grafana.provision.dashboards.settings.providers;
|
||||
shipped = lib.attrNames provider.options.path.entries;
|
||||
board = builtins.fromJSON (builtins.readFile ../host-modules/swarm-grafana/dashboards/egress.json);
|
||||
exprs = lib.concatMap (p: map (t: t.expr or "") (p.targets or [ ])) board.panels;
|
||||
pattern = "would_deny user=<agent> method=<method> host=<dest> port=<port> result=<result>";
|
||||
agentVar = lib.findFirst (v: v.name == "agent") null board.templating.list;
|
||||
exprs = map (e: (lib.head e.spec.data.spec.queries).spec.query.spec.expr) (
|
||||
lib.attrValues board.spec.elements
|
||||
);
|
||||
tabs = map (t: t.spec.title) board.spec.layout.spec.tabs;
|
||||
wouldDeny = "would_deny user=<agent> method=<method> host=<dest> port=<port> result=<result>";
|
||||
access = "(?P<result>TCP_[A-Z_]+)/(?P<status>[0-9]{3}) (?P<bytes>[0-9]+) (?P<method>[A-Z]+) (?P<url>\\\\S+) (?P<agent>\\\\S+)";
|
||||
agentVar = lib.findFirst (v: v.spec.name == "agent") null board.spec.variables;
|
||||
squid = builtins.readFile ../host-modules/hive-squid.nix;
|
||||
in
|
||||
lib.elem "egress.json" shipped
|
||||
&& lib.length (lib.filter (e: lib.hasInfix pattern e) exprs) == 5
|
||||
&&
|
||||
tabs == [
|
||||
"overview"
|
||||
"refused"
|
||||
"would-deny"
|
||||
]
|
||||
# every panel sits in a tab, and every tab item names a panel
|
||||
&&
|
||||
lib.sort (a: b: a < b) (
|
||||
lib.concatMap (t: map (i: i.spec.element.name) t.spec.layout.spec.items) board.spec.layout.spec.tabs
|
||||
) == lib.sort (a: b: a < b) (lib.attrNames board.spec.elements)
|
||||
&& lib.length (lib.filter (e: lib.hasInfix wouldDeny e) exprs) == 6
|
||||
&& lib.length (lib.filter (e: lib.hasInfix access e) exprs) == 14
|
||||
&& agentVar != null
|
||||
&& lib.hasInfix pattern agentVar.query.query
|
||||
&& lib.hasInfix "logformat would_deny would_deny user=%[un method=%rm host=%>rd port=%>rP result=" squid;
|
||||
&& lib.hasInfix access agentVar.spec.query.spec.query
|
||||
&& lib.hasInfix "logformat would_deny would_deny user=%[un method=%rm host=%>rd port=%>rP result=" squid
|
||||
&& lib.hasInfix "access_log syslog:daemon.info squid !manager" squid;
|
||||
}
|
||||
{
|
||||
# The standing check on the collector's PRIORITY mapping — whether a line
|
||||
|
|
|
|||
Loading…
Reference in a new issue