Repository navigation
fix(install): drop grafana datasource debug lines from the journal - #360
Merged
Merged
Conversation
--with-observability left Grafana and InfluxDB on every interface: neither listen address was set, so both kept the vendor default, and Grafana serves its dashboards to anonymous viewers. Nothing off the device needs InfluxDB, since the runtime and Grafana reach it at http://127.0.0.1:8086. InfluxDB now always binds 127.0.0.1:8086. A new systemd drop-in, /etc/systemd/system/influxdb.service.d/anolis.conf, sets INFLUXD_HTTP_BIND_ADDRESS. influxdb is restarted on every observability run instead of `enable --now`, because a running influxd keeps the bind it started with. The separate-host compose stack is unchanged. Grafana binds 127.0.0.1 by default through GF_SERVER_HTTP_ADDR in its existing drop-in. The new flag --with-grafana-network opens Grafana, and only Grafana, to the network by setting 0.0.0.0, which Grafana's documentation gives as the equivalent of its empty default. The default summary prints `ssh -L 3000:127.0.0.1:3000 <user>@<host>` (the user is $SUDO_USER when set) and http://localhost:3000. With the flag it prints the network address as before. The drop-in is rewritten on every run, so a re-run without the flag after one with it binds loopback again, and the summary says Grafana is no longer on the network. Uninstall removes the InfluxDB drop-in with Grafana's. docs/security.md gains an Observability section: a table of both ports with bind, authentication (including anonymous Viewer on Grafana) and who needs each, the tunnel, and a line saying the install configures no host firewall. The --with-grafana-network row in docs/deploy/install-sh.md links to it. observability_test.bats gains nine cases: the flag parses; Grafana's drop-in binds 127.0.0.1 by default and 0.0.0.0 with the flag; InfluxDB's drop-in binds 127.0.0.1:8086 either way; a drop-in written with the flag is recognised as network-bound and one without it is not; the InfluxDB drop-in is written before influxdb is restarted, never only `enable --now`; the default summary prints the tunnel and no network address; the flag's summary prints the address and no tunnel; a re-run without the flag reports the return to loopback. Eight fail before the change. The flag's summary case passes before it too, because it pins the existing output. The InfluxDB drop-in writer is stubbed with the other host-touching calls in the existing phase_observability cases. bats tests/shell/: 186 of 186 pass, none skipped. shellcheck tools/install.sh is clean, and markdownlint-cli2 reports 0 issues on both docs. Not run on a device. The bind addresses and the restart want a rig check: after a default install, `ss -ltnp` shows 3000 and 8086 on 127.0.0.1 only; after one with --with-grafana-network, 3000 on 0.0.0.0 and 8086 still on 127.0.0.1. Closes #351
GF_LOG_LEVEL=warn (#333) did not stop an open dashboard flooding the journal. On a rig the flood was ~3000 lines per 10 min of `{"@Level":"debug",...}` JSON from the loggers tsdb.influxdb and tsdb.influx_flux, and Grafana's own log was already at warn. Why Grafana's log settings cannot reach these lines, from the Grafana v13.1.1 source: - pkg/tsdb/influxdb/influxdb.go and flux/flux.go take their loggers in package-level vars: `backend.NewLoggerWith("logger", "tsdb.influxdb")` and `"tsdb.influx_flux"`. - pkg/services/pluginsintegration/coreplugin/coreplugins.go replaces backend.NewLoggerWith with a Grafana-backed logger in its init(). That package imports influxdb, and Go initialises an imported package's vars before the importer's init() runs, so both vars keep the SDK's default. - In grafana-plugin-sdk-go, backend/log.go's default NewLoggerWith is log.New().With(...), and backend/log/log.go's New() is NewWithLevel(Debug): an hclog logger at debug, JSONFormat true, writing to stderr. - Grafana's own log (pkg/infra/log/log.go) writes console mode to stdout. The [log] level and filters settings (Grafana's configuration docs: "filters: Optional settings to set different levels for specific loggers") apply only to that logger, so GF_LOG_FILTERS cannot stop these lines either. Nor can [log] mode = file, which moves only Grafana's own log. So the filter goes in systemd. The Grafana drop-in now sets `LogFilterPatterns=~.@Level.:.debug.`. systemd.exec(5): "If the first character of the pattern is "~", log entries matching the pattern should be discarded ... Added in version 253." That drops the debug JSON lines only. Grafana's own log on stdout, and error or warn lines and Go panics on stderr, still reach the journal; StandardError=null would have discarded those too. The pattern uses `.` where the JSON has quotes, so unit-file unquoting cannot change it. systemd older than 253 ignores the key, and install.sh then warns that the journal will fill while a dashboard is open. The drop-in comment now names the datasource loggers instead of "Grafana logs requests at level=info". observability_test.bats gains three cases: the drop-in's pattern matches the measured debug line and neither an error line nor a Grafana request line, and contains no quote or backslash; the comment no longer blames request logging and names tsdb.influxdb; systemd 252 gets the warning and 257 does not. All three fail before the change. bats tests/shell/: 189 of 189 pass, none skipped. shellcheck tools/install.sh is clean. systemd-analyze verify cannot run in the build environment, so systemd's parse of the pattern is unverified until a rig run. This builds on the loopback-bind change (#351), which edits the same drop-in. Untested on a device. The check on the rig: with a dashboard open on 5 s auto-refresh, count every journal line from grafana-server over 10 min, before and after this install, with `journalctl -u grafana-server --since T --until T+10min -o cat` piped to `wc -l`, and record `systemctl --version`. The 0.1.44 baseline was 2976 lines, 2975 of them debug JSON. Closes #349
A re-run whose observability step failed still reported Grafana on loopback, with the tunnel, while it was on the network. The drop-in is written at the end of _obs_provision_grafana and grafana-server is restarted after it. If _obs_setup_influx or _obs_provision_grafana failed, phase_observability returned early, but the summary, gated only on WITH_OBSERVABILITY, printed the requested bind as if applied. _OBS_GRAFANA_BIND_APPLIED is now set only after grafana-server restarts with the new drop-in. Until then the summary prints "Grafana bind unchanged: the observability step did not finish" instead of an address or a tunnel. Also: - On x86_64 the tunnel line named localhost, which is useless from another machine. It now prints a <host> placeholder there. - --with-grafana-network without --with-observability warns that it has no effect. - The uninstall check for a provisioned stack is now _obs_provisioned, so a test can drive the uninstall path without the host's /etc. - docs/security.md: the InfluxDB admin token is also written to /etc/anolis/observability.env as INFLUXDB_ADMIN_TOKEN. Going back to loopback needs a later install with --with-observability, and a failed one leaves the bind as it was. Five new bats cases: failed provisioning gives "bind unchanged" and no tunnel; a successful run reports the bind it applied; x86_64 prints <host>, not localhost; the flag alone warns; uninstall removes the InfluxDB drop-in with Grafana's (rm, systemctl and the rest stubbed). Four fail before the change. The successful-run case passed before too, because it pins the existing output. Each was broken on its own (setting the flag before provisioning, never setting it, dropping the placeholder, the warning, or the influx drop-in from rm), and each mutation failed only its target. The three existing summary cases set the applied flag explicitly. bats tests/shell/: 191 of 191 pass, none skipped. shellcheck is clean, and markdownlint-cli2 reports 0 issues on security.md. Refs #351
Brings in the review fixes on the loopback-bind branch (#351): the summary reports the Grafana bind only once it is applied, plus the x86_64 tunnel host, the lone-flag warning and the uninstall seam. The one conflict was both branches appending cases to the end of tests/shell/observability_test.bats; both sets are kept. After the merge the tree differs from feat/observability-loopback-bind only by this branch's #349 change (install.sh and its three bats cases). bats tests/shell/: 194 of 194 pass, none skipped; shellcheck is clean. Refs #349
CameronBrooks11
enabled auto-merge (squash)
October 15, 2026 16:44
CameronBrooks11
added a commit
that referenced
this pull request
Oct 16, 2026
Bumps `project(VERSION)` and `vcpkg.json` to 0.1.45 and rolls the CHANGELOG. Ships, among others: - `safety.on_startup`, default `safe_state`: the declared safe state runs once at every runtime start (#392, closes #362); - Grafana and InfluxDB bound to loopback under `--with-observability`, with `--with-grafana-network` to open Grafana to the LAN (#359, closes #351); - `install.sh` refuses a downgrade unless `--allow-downgrade` (#382, closes #366); - the zero rung no longer sends a guessed boolean (#367), e-stop `safe_state_achieved` (#368), dispatchable coverage counts (#369), and startup warnings for fault-hook gaps (#370) and disarmed watchdogs (#371); - `health.excluded_signals` (#377), signal unit and description in capabilities (#365); - a half-open probe of an open provider circuit every 60 s, a restart that stops the old process first, and a restart clock that starts after it stops (#376, #391); - automation status: `idle` outside AUTO, and `failed` cleared by a load or a new AUTO run (#373, #386); - `install.sh`: provider liveness in the health phase (#355, #383), `manifest.json` restored on `--rollback` (#354), Grafana restarted on every observability run (#343), the datasource debug lines filtered from the journal (#360), and the uninstall prefix guard (#342); - no ERROR lines for reads that fail during shutdown (#381). The CHANGELOG opens 0.1.45 with upgrade notes: Grafana is on loopback by default, `safety.on_startup` drives outputs at boot by default, and downgrades need `--allow-downgrade`. The 0.1.44 note about restarting grafana-server by hand is not repeated, since #343 restarts it on every run. The OpenAPI changes are additive: `SignalSpec.unit` and `.description`, `EstopResponse.safe_state_achieved`, `ParameterDefinition.source` and the runtime status `startup_safe_state`. No provider-protocol change. anolis-workbench vendors the OpenAPI file and needs a repin to this release. Every commit in `git log v0.1.44..main` is in the CHANGELOG except CI, test-only and docs-lint commits (#380, #384, #389). After merge, tag `v0.1.45`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(install): drop grafana datasource debug lines from the journal
GF_LOG_LEVEL=warn (#333) did not stop an open dashboard flooding the
journal. On a rig the flood was ~3000 lines per 10 min of
{"@level":"debug",...}JSON from the loggers tsdb.influxdb andtsdb.influx_flux, and Grafana's own log was already at warn.
Why Grafana's log settings cannot reach these lines, from the Grafana
v13.1.1 source:
in package-level vars:
backend.NewLoggerWith("logger", "tsdb.influxdb")and"tsdb.influx_flux".backend.NewLoggerWith with a Grafana-backed logger in its init().
That package imports influxdb, and Go initialises an imported
package's vars before the importer's init() runs, so both vars keep
the SDK's default.
log.New().With(...), and backend/log/log.go's New() is
NewWithLevel(Debug): an hclog logger at debug, JSONFormat true,
writing to stderr.
stdout. The [log] level and filters settings (Grafana's
configuration docs: "filters: Optional settings to set different
levels for specific loggers") apply only to that logger, so
GF_LOG_FILTERS cannot stop these lines either. Nor can
[log] mode = file, which moves only Grafana's own log.
So the filter goes in systemd. The Grafana drop-in now sets
LogFilterPatterns=~.@level.:.debug.. systemd.exec(5): "If the firstcharacter of the pattern is "~", log entries matching the pattern
should be discarded ... Added in version 253." That drops the debug
JSON lines only. Grafana's own log on stdout, and error or warn lines
and Go panics on stderr, still reach the journal; StandardError=null
would have discarded those too. The pattern uses
.where the JSONhas quotes, so unit-file unquoting cannot change it. systemd older
than 253 ignores the key, and install.sh then warns that the journal
will fill while a dashboard is open. The drop-in comment now names
the datasource loggers instead of "Grafana logs requests at
level=info".
observability_test.bats gains three cases: the drop-in's pattern
matches the measured debug line and neither an error line nor a
Grafana request line, and contains no quote or backslash; the comment
no longer blames request logging and names tsdb.influxdb; systemd 252
gets the warning and 257 does not. All three fail before the change.
bats tests/shell/: 194 of 194 pass, none skipped. shellcheck
tools/install.sh is clean. systemd-analyze verify cannot run in the
build environment, so systemd's parse of the pattern is unverified
until a rig run.
This builds on the loopback-bind change (#351), which edits the same
drop-in.
Untested on a device. The check on the rig: with a dashboard open on
5 s auto-refresh, count every journal line from grafana-server over
10 min, before and after this install, with
journalctl -u grafana-server --since T --until T+10min -o catpiped to
wc -l, and recordsystemctl --version. The 0.1.44baseline was 2976 lines, 2975 of them debug JSON.
Closes #349