You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2
+
change_type: 'enhancement'
3
+
4
+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5
+
component: operator
6
+
7
+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8
+
note: Enabling new Logs Enconder Configuration parameters.
9
+
10
+
# One or more tracking issues related to the change
11
+
issues: [268]
12
+
13
+
# (Optional) One or more lines of additional information to render under the primary note.
14
+
# These lines will be padded with 2 spaces and then inserted directly into the document.
A tip during a troubleshooting process is always welcome. Therefore, we prepared this documentation to help you identify possible issues and improve the application's reliability.
4
+
5
+
## Customizing Logs Output
6
+
By the default the Operator's log format is console like you can see below:
7
+
```bash
8
+
2024-05-06T11:55:11+02:00 INFO setup Prometheus CRDs are installed, adding to scheme.
9
+
2024-05-06T11:55:11+02:00 INFO setup Openshift CRDs are not installed, skipping adding to scheme.
10
+
2024-05-06T11:55:11+02:00 INFO setup the env var WATCH_NAMESPACE isn't set, watching all namespaces
11
+
2024-05-06T11:55:11+02:00 INFO Webhooks are disabled, operator is running an unsupported mode {"ENABLE_WEBHOOKS": "false"}
12
+
2024-05-06T11:55:11+02:00 INFO setup starting manager
13
+
```
14
+
15
+
If it is necessary to customize the log format, so you can use one of the following parameters:
16
+
- `--zap-devel`: Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn). Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error) (default false)
17
+
- `--zap-encoder`: Zap log encoding (one of 'json' or 'console')
18
+
- `--zap-log-level` Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error', or any integer value > 0 which corresponds to custom debug levels of increasing verbosity
19
+
- `--zap-stacktrace-level` Zap Level at and above which stacktraces are captured (one of 'info', 'error', 'panic').
20
+
- `--zap-time-encoding` Zap time encoding (one of 'epoch', 'millis', 'nano', 'iso8601', 'rfc3339' or 'rfc3339nano'). Defaults to 'epoch'.
21
+
- The following parameters are effective only if the `--zap-encoder=json`:
22
+
- `zap-message-key`: The message key to be used in the customized Log Encoder
23
+
- `zap-level-key`: The level key to be used in the customized Log Encoder
24
+
- `zap-time-key`: The time key to be used in the customized Log Encoder
25
+
- `zap-level-format`: The level format to be used in the customized Log Encoder
26
+
27
+
Running the Operator with the parameters `--zap-encoder=json`, `--zap-message-key="msg"`, `zap-level-key="severity"`,`zap-time-key="timestamp"`,`zap-level-format="uppercase"` you should see the following output:
28
+
```bash
29
+
{"severity":"INFO","timestamp":"2024-05-07T16:23:35+02:00","logger":"setup","msg":"Prometheus CRDs are installed, adding to scheme."}
30
+
{"severity":"INFO","timestamp":"2024-05-07T16:23:35+02:00","logger":"setup","msg":"Openshift CRDs are not installed, skipping adding to scheme."}
31
+
{"severity":"INFO","timestamp":"2024-05-07T16:23:35+02:00","logger":"setup","msg":"the env var WATCH_NAMESPACE isn't set, watching all namespaces"}
32
+
{"severity":"INFO","timestamp":"2024-05-07T16:23:35+02:00","msg":"Webhooks are disabled, operator is running an unsupported mode","ENABLE_WEBHOOKS":"false"}
pflag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
@@ -163,8 +168,19 @@ func main() {
163
168
pflag.StringArrayVar(&annotationsFilter, "annotations-filter", []string{}, "Annotations to filter away from propagating onto deploys. It should be a string array containing patterns, which are literal strings optionally containing a * wildcard character. Example: --annotations-filter=.*filter.out will filter out annotations that looks like: annotation.filter.out: true")
164
169
pflag.StringVar(&tlsOpt.minVersion, "tls-min-version", "VersionTLS12", "Minimum TLS version supported. Value must match version names from https://golang.org/pkg/crypto/tls/#pkg-constants.")
165
170
pflag.StringSliceVar(&tlsOpt.cipherSuites, "tls-cipher-suites", nil, "Comma-separated list of cipher suites for the server. Values are from tls package constants (https://golang.org/pkg/crypto/tls/#pkg-constants). If omitted, the default Go cipher suites will be used")
171
+
pflag.StringVar(&encodeMessageKey, "zap-message-key", "message", "The message key to be used in the customized Log Encoder")
172
+
pflag.StringVar(&encodeLevelKey, "zap-level-key", "level", "The level key to be used in the customized Log Encoder")
173
+
pflag.StringVar(&encodeTimeKey, "zap-time-key", "timestamp", "The time key to be used in the customized Log Encoder")
174
+
pflag.StringVar(&encodeLevelFormat, "zap-level-format", "uppercase", "The level format to be used in the customized Log Encoder")
0 commit comments