Logging with OpenTelemetry
From version 2.6 the server can send every line of its log as an OpenTelemetry log record to a collector: Grafana Loki (version 3, native OTLP endpoint), an OpenTelemetry Collector or Grafana Alloy. The console and the log files (log_dir) stay as they are. Logs of several servers and other LumiScan software can then be searched in one place.
The server sends OTLP over HTTP with JSON. Sending never holds the server up: the records wait in a queue and go out in batches. If the collector cannot be reached, the server keeps running, keeps the records and tries again.
Switching it on
Add a section telemetry to the configuration and restart the server:
"telemetry": {
"endpoint": "http://monitoring01:3100/otlp",
"environment": "production"
},
The server posts the records to <endpoint>/v1/logs. Typical endpoints:
-
Loki 3:
http://<loki-server>:3100/otlp -
OpenTelemetry Collector or Grafana Alloy (OTLP/HTTP receiver):
http://<collector>:4318
At the start the log names the address and the identity of this start, for example:
OpenTelemetry: log records go to http://monitoring01:3100/otlp/v1/logs (service.name lumiscan-annotation-server, service.instance.id 3f2c9e1a-...)
Without a telemetry section (and without the environment variables below) nothing is sent.
Keys
| Key | Meaning |
|---|---|
|
|
|
Base address of the collector, |
|
Optional: the complete address of the logs endpoint, used as it is (instead of |
|
Optional: further HTTP headers, for example |
|
Optional: a file with headers that hold secrets (for example |
|
|
|
Optional: |
|
Optional: further resource attributes, for example |
|
The lowest level sent: |
|
Time limit for one request, in milliseconds. Default 10000. |
|
Records per request at most. Default 512. |
|
A batch goes out at the latest after this time, in milliseconds. Default 2000. |
|
Records kept while the collector cannot be reached. Default 20000; further records are not sent (the log file has them). |
|
Optional: CA certificates (PEM) for an |
|
|
|
What happens to user names, computer addresses and e-mail addresses in the records: |
Environment variables
The server also reads the standard variables of the OpenTelemetry SDKs. They win over the configuration file, so an endpoint can be set without changing the file. If only the variables are set, sending is on.
| Variable | Meaning |
|---|---|
|
Like |
|
Like |
|
Headers as |
|
Like |
|
Like |
|
Only |
|
Like |
|
Resource attributes as |
|
Nothing is sent, whatever the file says. |
For a service, set the variables where the service starts: on Linux an Environment= line in the systemd unit, on Windows as system environment variables. Then restart the service.
What a log record contains
The field names follow the OpenTelemetry log data model and semantic conventions (schema 1.34.0), as the LumiScan log aggregation prescribes them for all LumiScan software.
| OpenTelemetry field | Name in JSON lines | Value |
|---|---|---|
Timestamp |
|
When the line was written. |
SeverityNumber |
|
|
SeverityText |
|
|
Body |
|
The message, as in the log file (with personal data handled as |
InstrumentationScope |
|
|
EventName |
|
The audit event, see Audit events; also sent as the attribute |
Resource attributes (the same in every record of a server start):
| Attribute | Value |
|---|---|
|
|
|
The server version, for example |
|
|
|
A new random ID at every start: separates the runs of one server. |
|
The computer’s host name. |
|
The machine ID of the operating system (Linux |
|
|
|
|
|
|
Log attributes:
| Attribute | Value |
|---|---|
|
The thread that wrote the line. |
|
The audit event, see Audit events. |
|
On the line |
|
Where in the program the line was written, when the server knows it. |
Audit events
| Event | When |
|---|---|
|
The server listens and takes requests ( |
|
The server has stopped ( |
|
The licence is available: at the start, and when it comes back. |
|
The licence is not available: at the start, and when it goes away. |
|
A user signed in (local account, LDAP or single sign-on). |
|
A sign-in failed. |
Searching the log in Grafana (Loki)
Loki turns the dots of attribute names into underscores. Examples in LogQL:
{service_name="lumiscan-annotation-server"}
{service_name="lumiscan-annotation-server"} | severity_text="ERROR"
{service_name="lumiscan-annotation-server"} | event_name="lumiscan.session.refused"
{service_name="lumiscan-annotation-server", host_name="annotation01"} | service_instance_id="3f2c9e1a-..."
{service_name="lumiscan-annotation-server"} |= "user-3f9a1c2b7d"
The last line finds the lines of one user in pseudonymized records; --pseudonym gives the pseudonym (see Personal data in the log).
Loki 3 keeps the attributes as structured metadata (schema v13, allow_structured_metadata). Keep the index labels coarse, as the log aggregation asks: by default Loki also makes service.instance.id a label, which starts a new stream at every restart. In the Loki configuration:
limits_config:
allow_structured_metadata: true
otlp_config:
resource_attributes:
ignore_defaults: true
attributes_config:
- action: index_label
attributes: [service.name, service.namespace, service.version, host.name, deployment.environment.name]
When the collector cannot be reached
-
The server keeps running. Records wait in the queue (up to
queue_max) and are sent again after 1 s, 2 s, 4 s … up to 1 minute between tries. -
The console and the log file say so at once and then at most every 10 minutes (
OpenTelemetry: cannot deliver log records to …), and again when the records arrive (… reach … again). -
A request the collector refuses (for example HTTP 400) is not repeated; the log file says so.
-
When the server stops, it sends what is still queued for up to 5 seconds.
-
The log file always has every line.
Data protection
By default the records carry pseudonyms instead of user names, computer addresses and e-mail addresses (personal_data, see Personal data in the log), as the LumiScan log aggregation asks for logs that leave the server. With keep they contain the same text as the log file. Give access to the collector only to those who may read the server log. Passwords, tokens, images and annotation contents never appear in the log.