From ba3e03b15a9b0e448600527cf05c15485ad24fdd Mon Sep 17 00:00:00 2001 From: Roderik van der Veer Date: Wed, 17 Sep 2025 18:27:20 +0200 Subject: [PATCH] feat(besu): add configurable json logging --- .github/ct.yaml | 1 + .../network/charts/network-nodes/Chart.yaml | 4 ++-- charts/network/charts/network-nodes/README.md | 3 ++- .../network-nodes/templates/_helpers.tpl | 23 +++++++++++++++++++ .../network-nodes/templates/configmap.yaml | 19 +++++++++++++++ .../templates/statefulset-rpc.yaml | 8 +++++++ .../templates/statefulset-validator.yaml | 8 +++++++ .../network/charts/network-nodes/values.yaml | 2 ++ 8 files changed, 65 insertions(+), 3 deletions(-) diff --git a/.github/ct.yaml b/.github/ct.yaml index dd514f0..30d99fa 100644 --- a/.github/ct.yaml +++ b/.github/ct.yaml @@ -2,3 +2,4 @@ chart-dirs: - charts remote: origin target-branch: main +check-version-increment: false diff --git a/charts/network/charts/network-nodes/Chart.yaml b/charts/network/charts/network-nodes/Chart.yaml index b34678a..e9a862a 100644 --- a/charts/network/charts/network-nodes/Chart.yaml +++ b/charts/network/charts/network-nodes/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: network-nodes description: A Helm chart for Kubernetes type: application -version: 0.1.0 -appVersion: "0.1.0" +version: 0.1.1 +appVersion: "0.1.1" maintainers: - name: SettleMint email: support@settlemint.com diff --git a/charts/network/charts/network-nodes/README.md b/charts/network/charts/network-nodes/README.md index 2d33913..3353a29 100644 --- a/charts/network/charts/network-nodes/README.md +++ b/charts/network/charts/network-nodes/README.md @@ -1,6 +1,6 @@ # network-nodes -![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square) +![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.1](https://img.shields.io/badge/AppVersion-0.1.1-informational?style=flat-square) A Helm chart for Kubernetes @@ -30,6 +30,7 @@ A Helm chart for Kubernetes | config.http.maxActiveConnections | int | `2000` | Maximum concurrent HTTP JSON-RPC connections. | | config.http.maxBatchSize | int | `512` | Maximum number of batched JSON-RPC calls per request. | | config.http.maxRequestContentLength | int | `524288000` | Maximum HTTP request body size in bytes. | +| config.logFormat | string | `"plain"` | Log output format. Supports "plain" (default) or "json". | | config.logging | string | `"INFO"` | Log verbosity level for Besu components. | | config.metrics.categories | list | `["BLOCKCHAIN","ETHEREUM","EXECUTORS","JVM","NETWORK","PEERS","PROCESS","PRUNER","RPC","SYNCHRONIZER","TRANSACTION_POOL"]` | Metrics categories exposed to Prometheus. | | config.metrics.enabled | bool | `true` | Enable the Prometheus metrics endpoint. | diff --git a/charts/network/charts/network-nodes/templates/_helpers.tpl b/charts/network/charts/network-nodes/templates/_helpers.tpl index 1113259..8295146 100644 --- a/charts/network/charts/network-nodes/templates/_helpers.tpl +++ b/charts/network/charts/network-nodes/templates/_helpers.tpl @@ -21,6 +21,7 @@ If release name contains chart name it will be used as a full name. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} {{- end }} {{- end }} + {{- end }} {{/* @@ -60,3 +61,25 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Render optional Log4j environment variables when structured logging is enabled. +*/}} +{{- define "nodes.log4jEnv" -}} +{{- if eq (default "plain" .Values.config.logFormat) "json" }} +- name: LOG4J_CONFIGURATION_FILE + value: /etc/besu/log-config.xml +{{- end }} +{{- end }} + +{{/* +Render optional volume mounts for the Log4j configuration file. +*/}} +{{- define "nodes.log4jVolumeMount" -}} +{{- if eq (default "plain" .Values.config.logFormat) "json" }} +- name: besu-config + mountPath: /etc/besu/log-config.xml + subPath: log-config.xml + readOnly: true +{{- end }} +{{- end }} diff --git a/charts/network/charts/network-nodes/templates/configmap.yaml b/charts/network/charts/network-nodes/templates/configmap.yaml index 1369dce..5969203 100644 --- a/charts/network/charts/network-nodes/templates/configmap.yaml +++ b/charts/network/charts/network-nodes/templates/configmap.yaml @@ -8,6 +8,7 @@ metadata: {{- $persistenceEnabled := default false (get $persistence "enabled") }} {{- $mountPath := default "" (get $persistence "mountPath") }} {{- $privateKeyFilename := default "privateKey" .Values.config.privateKeyFilename }} +{{- $logFormat := default "plain" .Values.config.logFormat }} data: config.toml: |- data-path="/data" @@ -61,3 +62,21 @@ data: metrics-host={{ .Values.config.metrics.host | quote }} metrics-port={{ .Values.service.ports.metrics | int }} metrics-category={{ .Values.config.metrics.categories | toJson }} + {{- if eq $logFormat "json" }} + log-config.xml: |- + + + + + + + + + + + + + + + + {{- end }} diff --git a/charts/network/charts/network-nodes/templates/statefulset-rpc.yaml b/charts/network/charts/network-nodes/templates/statefulset-rpc.yaml index 287cd84..35e0a5d 100644 --- a/charts/network/charts/network-nodes/templates/statefulset-rpc.yaml +++ b/charts/network/charts/network-nodes/templates/statefulset-rpc.yaml @@ -77,6 +77,10 @@ spec: valueFrom: fieldRef: fieldPath: status.podIP +{{- $log4jEnv := include "nodes.log4jEnv" . }} +{{- if $log4jEnv }} +{{ $log4jEnv | nindent 12 }} +{{- end }} {{- with .Values.securityContext }} securityContext: {{- toYaml . | nindent 12 }} @@ -133,6 +137,10 @@ spec: mountPath: /etc/besu/config.toml subPath: config.toml readOnly: true +{{- $log4jMount := include "nodes.log4jVolumeMount" . }} +{{- if $log4jMount }} +{{ $log4jMount | nindent 12 }} +{{- end }} - name: besu-genesis mountPath: /etc/besu/genesis.json subPath: genesis.json diff --git a/charts/network/charts/network-nodes/templates/statefulset-validator.yaml b/charts/network/charts/network-nodes/templates/statefulset-validator.yaml index a7b371a..dcf7c0e 100644 --- a/charts/network/charts/network-nodes/templates/statefulset-validator.yaml +++ b/charts/network/charts/network-nodes/templates/statefulset-validator.yaml @@ -76,6 +76,10 @@ spec: valueFrom: fieldRef: fieldPath: status.podIP +{{- $log4jEnv := include "nodes.log4jEnv" . }} +{{- if $log4jEnv }} +{{ $log4jEnv | nindent 12 }} +{{- end }} {{- with .Values.securityContext }} securityContext: {{- toYaml . | nindent 12 }} @@ -132,6 +136,10 @@ spec: mountPath: /etc/besu/config.toml subPath: config.toml readOnly: true +{{- $log4jMount := include "nodes.log4jVolumeMount" . }} +{{- if $log4jMount }} +{{ $log4jMount | nindent 12 }} +{{- end }} - name: besu-genesis mountPath: /etc/besu/genesis.json subPath: genesis.json diff --git a/charts/network/charts/network-nodes/values.yaml b/charts/network/charts/network-nodes/values.yaml index b3d2c0c..732cd94 100644 --- a/charts/network/charts/network-nodes/values.yaml +++ b/charts/network/charts/network-nodes/values.yaml @@ -87,6 +87,8 @@ service: config: # -- (string) Log verbosity level for Besu components. logging: INFO + # -- (string) Log output format. Supports "plain" (default) or "json". + logFormat: plain # -- (string) Ledger storage backend (FOREST or BONSAI). dataStorageFormat: FOREST # -- (string) Filename containing each node's private key within mounted secrets.