Skip to content

Commit 7dde86c

Browse files
committed
feat(besu): add configurable json logging
1 parent 3ad607e commit 7dde86c

7 files changed

Lines changed: 64 additions & 3 deletions

File tree

charts/network/charts/network-nodes/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v2
22
name: network-nodes
33
description: A Helm chart for Kubernetes
44
type: application
5-
version: 0.1.0
6-
appVersion: "0.1.0"
5+
version: 0.1.1
6+
appVersion: "0.1.1"
77
maintainers:
88
- name: SettleMint
99
email: support@settlemint.com

charts/network/charts/network-nodes/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# network-nodes
22

3-
![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)
3+
![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)
44

55
A Helm chart for Kubernetes
66

@@ -30,6 +30,7 @@ A Helm chart for Kubernetes
3030
| config.http.maxActiveConnections | int | `2000` | Maximum concurrent HTTP JSON-RPC connections. |
3131
| config.http.maxBatchSize | int | `512` | Maximum number of batched JSON-RPC calls per request. |
3232
| config.http.maxRequestContentLength | int | `524288000` | Maximum HTTP request body size in bytes. |
33+
| config.logFormat | string | `"plain"` | Log output format. Supports "plain" (default) or "json". |
3334
| config.logging | string | `"INFO"` | Log verbosity level for Besu components. |
3435
| config.metrics.categories | list | `["BLOCKCHAIN","ETHEREUM","EXECUTORS","JVM","NETWORK","PEERS","PROCESS","PRUNER","RPC","SYNCHRONIZER","TRANSACTION_POOL"]` | Metrics categories exposed to Prometheus. |
3536
| config.metrics.enabled | bool | `true` | Enable the Prometheus metrics endpoint. |

charts/network/charts/network-nodes/templates/_helpers.tpl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ If release name contains chart name it will be used as a full name.
2121
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
2222
{{- end }}
2323
{{- end }}
24+
2425
{{- end }}
2526

2627
{{/*
@@ -60,3 +61,25 @@ Create the name of the service account to use
6061
{{- default "default" .Values.serviceAccount.name }}
6162
{{- end }}
6263
{{- end }}
64+
65+
{{/*
66+
Render optional Log4j environment variables when structured logging is enabled.
67+
*/}}
68+
{{- define "nodes.log4jEnv" -}}
69+
{{- if eq (default "plain" .Values.config.logFormat) "json" }}
70+
- name: LOG4J_CONFIGURATION_FILE
71+
value: /etc/besu/log-config.xml
72+
{{- end }}
73+
{{- end }}
74+
75+
{{/*
76+
Render optional volume mounts for the Log4j configuration file.
77+
*/}}
78+
{{- define "nodes.log4jVolumeMount" -}}
79+
{{- if eq (default "plain" .Values.config.logFormat) "json" }}
80+
- name: besu-config
81+
mountPath: /etc/besu/log-config.xml
82+
subPath: log-config.xml
83+
readOnly: true
84+
{{- end }}
85+
{{- end }}

charts/network/charts/network-nodes/templates/configmap.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ metadata:
88
{{- $persistenceEnabled := default false (get $persistence "enabled") }}
99
{{- $mountPath := default "" (get $persistence "mountPath") }}
1010
{{- $privateKeyFilename := default "privateKey" .Values.config.privateKeyFilename }}
11+
{{- $logFormat := default "plain" .Values.config.logFormat }}
1112
data:
1213
config.toml: |-
1314
data-path="/data"
@@ -61,3 +62,21 @@ data:
6162
metrics-host={{ .Values.config.metrics.host | quote }}
6263
metrics-port={{ .Values.service.ports.metrics | int }}
6364
metrics-category={{ .Values.config.metrics.categories | toJson }}
65+
{{- if eq $logFormat "json" }}
66+
log-config.xml: |-
67+
<?xml version="1.0" encoding="UTF-8"?>
68+
<Configuration status="INFO" monitorInterval="5">
69+
<Appenders>
70+
<Console name="Console" target="SYSTEM_OUT">
71+
<JsonLayout compact="false" eventEol="true" properties="true" stacktrace="true">
72+
<KeyValuePair key="container" value="${hostName}" />
73+
</JsonLayout>
74+
</Console>
75+
</Appenders>
76+
<Loggers>
77+
<Root level="{{ .Values.config.logging }}">
78+
<AppenderRef ref="Console" />
79+
</Root>
80+
</Loggers>
81+
</Configuration>
82+
{{- end }}

charts/network/charts/network-nodes/templates/statefulset-rpc.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ spec:
7777
valueFrom:
7878
fieldRef:
7979
fieldPath: status.podIP
80+
{{- $log4jEnv := include "nodes.log4jEnv" . }}
81+
{{- if $log4jEnv }}
82+
{{ $log4jEnv | nindent 12 }}
83+
{{- end }}
8084
{{- with .Values.securityContext }}
8185
securityContext:
8286
{{- toYaml . | nindent 12 }}
@@ -133,6 +137,10 @@ spec:
133137
mountPath: /etc/besu/config.toml
134138
subPath: config.toml
135139
readOnly: true
140+
{{- $log4jMount := include "nodes.log4jVolumeMount" . }}
141+
{{- if $log4jMount }}
142+
{{ $log4jMount | nindent 12 }}
143+
{{- end }}
136144
- name: besu-genesis
137145
mountPath: /etc/besu/genesis.json
138146
subPath: genesis.json

charts/network/charts/network-nodes/templates/statefulset-validator.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ spec:
7676
valueFrom:
7777
fieldRef:
7878
fieldPath: status.podIP
79+
{{- $log4jEnv := include "nodes.log4jEnv" . }}
80+
{{- if $log4jEnv }}
81+
{{ $log4jEnv | nindent 12 }}
82+
{{- end }}
7983
{{- with .Values.securityContext }}
8084
securityContext:
8185
{{- toYaml . | nindent 12 }}
@@ -132,6 +136,10 @@ spec:
132136
mountPath: /etc/besu/config.toml
133137
subPath: config.toml
134138
readOnly: true
139+
{{- $log4jMount := include "nodes.log4jVolumeMount" . }}
140+
{{- if $log4jMount }}
141+
{{ $log4jMount | nindent 12 }}
142+
{{- end }}
135143
- name: besu-genesis
136144
mountPath: /etc/besu/genesis.json
137145
subPath: genesis.json

charts/network/charts/network-nodes/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ service:
8787
config:
8888
# -- (string) Log verbosity level for Besu components.
8989
logging: INFO
90+
# -- (string) Log output format. Supports "plain" (default) or "json".
91+
logFormat: plain
9092
# -- (string) Ledger storage backend (FOREST or BONSAI).
9193
dataStorageFormat: FOREST
9294
# -- (string) Filename containing each node's private key within mounted secrets.

0 commit comments

Comments
 (0)