Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
136b189
Add custom time format to JSON and TEXT logging
AlexFenlon Aug 19, 2025
4a62d07
clean up unix formats
AlexFenlon Aug 19, 2025
4078573
Merge branch 'main' into feat/log-time-format
AlexFenlon Aug 19, 2025
773a3a0
Merge branch 'main' into feat/log-time-format
AlexFenlon Aug 19, 2025
9b93713
chore(deps): bump the python group across 1 directory with 2 updates …
dependabot[bot] Aug 20, 2025
2349205
Fix broken hyperlink to F5 Container Registry Download doc in README.…
ogipierogi Aug 20, 2025
53b5043
Ensure all links resolve correctly in README.md (#8171)
pdabelf5 Aug 20, 2025
5fa633e
add helm gh action (#8175)
vepatel Aug 21, 2025
1b1ce1e
[pre-commit.ci] pre-commit autoupdate (#8156)
pre-commit-ci[bot] Aug 21, 2025
9567041
Fix Helm tests failing with latest version (#8179)
AlexFenlon Aug 21, 2025
37dcb95
Remove existence check from templates before range (#8181)
javorszky Aug 22, 2025
36f1e7f
chore(deps): bump the go group with 3 updates (#8183)
dependabot[bot] Aug 22, 2025
a27a0f1
chore(deps): bump the actions group across 1 directory with 2 updates…
dependabot[bot] Aug 25, 2025
42acf0d
Docker image update 24ce9eb1 (#8173)
github-actions[bot] Aug 25, 2025
4573fdb
chore(deps): bump the go group with 3 updates (#8186)
dependabot[bot] Aug 26, 2025
071aebb
add globalConfigurationCustomName parameter (#8142)
mohamadaldawamnah Aug 27, 2025
88828dd
Update CI workflow_call boolean inputs (#8197)
pdabelf5 Aug 28, 2025
6a6ecca
Add support for FIPS 140-3 compliance (#8195)
AlexFenlon Aug 28, 2025
2b4fe20
chore(deps): bump kindest/node from v1.33.2 to v1.33.4 in /tests in t…
dependabot[bot] Aug 28, 2025
c0ea80e
remove http cache for jwks (#8198)
vepatel Aug 28, 2025
731a2ad
Docker image update 5784bad7 (#8188)
github-actions[bot] Aug 28, 2025
09bd7a9
chore(deps): bump actions/dependency-review-action from 4.7.2 to 4.7.…
dependabot[bot] Aug 28, 2025
0ee5562
chore(deps): bump the python group with 2 updates (#8187)
dependabot[bot] Aug 28, 2025
0e43467
chore(deps): bump the go group with 2 updates (#8200)
dependabot[bot] Aug 28, 2025
966b70b
Update proxy endpoint for published builds (#8194)
pdabelf5 Sep 1, 2025
4a01a67
Update NGINX Agent to 3.3 (#8208)
AlexFenlon Sep 1, 2025
ada8720
Add Safe Proxy Buffer Configuration Adjustments (#8133)
AlexFenlon Sep 9, 2025
72db468
chore(deps): bump the python group with 2 updates (#8210)
dependabot[bot] Sep 2, 2025
a4211c7
chore(deps): bump the actions group across 1 directory with 2 updates…
dependabot[bot] Sep 2, 2025
c1ca0cf
Adds sha256 hash to quay.io/skopeo import (#8196)
javorszky Sep 2, 2025
085a874
remove shared cache config from helm (#8211)
vepatel Sep 2, 2025
5377907
Fix gofumpt empty string errors (#8221)
AlexFenlon Sep 4, 2025
6870b6e
update golang to 1.25 (#8220)
vepatel Sep 4, 2025
4383407
chore(deps): bump the actions group with 7 updates (#8227)
dependabot[bot] Sep 5, 2025
1f45271
update prometheus metrics with N+ license expiry (#8229)
vepatel Sep 5, 2025
5b5a41d
Docker image update 92ac582e (#8228)
github-actions[bot] Sep 5, 2025
43f96d5
chore(deps): bump the go group across 1 directory with 5 updates (#8…
pdabelf5 Sep 5, 2025
c030128
Update README.md to include a pointer to the NGINX Community Forum (#…
dwmcallister Sep 5, 2025
bbee9f5
Correct yaml indentation for daemon-set readiness probe (#8233)
pdabelf5 Sep 5, 2025
7c59fd4
Fix Proxy Buffer Config Adjustments (#8226)
AlexFenlon Sep 5, 2025
679d3d3
chore(deps): bump the actions group with 2 updates (#8238)
dependabot[bot] Sep 8, 2025
d3dcfe2
StatefulSet support (#8159)
haywoodsh Sep 8, 2025
a246acd
Docker image update d2837402 (#8239)
github-actions[bot] Sep 8, 2025
25a9bc9
chore(deps): bump nginx/dependencies/nginx-ubi from `12b2f67` to `786…
dependabot[bot] Sep 8, 2025
9ab29da
chore(deps): bump the docker-tests group in /tests with 2 updates (#8…
dependabot[bot] Sep 8, 2025
404e079
Version Bump for 5.3.0 (#8241)
github-actions[bot] Sep 8, 2025
8e617cd
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/log…
AlexFenlon Sep 9, 2025
4aff4e5
address comments
AlexFenlon Sep 9, 2025
d4a7440
Merge branch 'main' into feat/log-time-format
AlexFenlon Sep 9, 2025
f4df927
fix snaps
AlexFenlon Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/nginx-ingress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ controller:
## The log level of the Ingress Controller. Options include: trace, debug, info, warning, error, fatal
logLevel: info

## Sets the log format of Ingress Controller. Options include: glog, json, text
## Sets the log format of Ingress Controller. Options include: glog, json, json-unix, json-unix-ms, text, text-unix, text-unix-ms
logFormat: glog

## Enables auto adjusting some of the NGINX directives to help with safe configuration and prevent NGINX misconfigurations.
Expand Down
2 changes: 1 addition & 1 deletion cmd/nginx-ingress/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func validateLogLevel(logLevel string) error {
// validateLogFormat makes sure a given logFormat is one of the allowed values
func validateLogFormat(logFormat string) error {
switch strings.ToLower(logFormat) {
case "glog", "json", "text":
case "glog", "json", "text", "json-unix", "json-unix-ms", "text-unix", "text-unix-ms":
return nil
}
return fmt.Errorf("invalid log format: %v", logFormat)
Expand Down
26 changes: 24 additions & 2 deletions cmd/nginx-ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1204,16 +1204,38 @@ func initLogger(logFormat string, level slog.Level, out io.Writer) context.Conte
a.Value = slog.AnyValue(src)
}
}
// Handle custom timestamp formatting
if a.Key == slog.TimeKey {
if t, ok := a.Value.Any().(time.Time); ok {
switch logFormat {
case "json-unix", "text-unix":
// Unix timestamp in seconds
return slog.Attr{
Key: slog.TimeKey,
Value: slog.Int64Value(t.Unix()),
}
case "json-unix-ms", "text-unix-ms":
// Unix timestamp with milliseconds
return slog.Attr{
Key: slog.TimeKey,
Value: slog.Int64Value(t.UnixMilli()),
}
default:
// Default timestamp format (keep original time key and format eg. RFC3339)
return a
}
}
}
return a
},
}

switch {
case logFormat == "glog":
h = nic_glog.New(out, &nic_glog.Options{Level: programLevel})
case logFormat == "json":
case strings.HasPrefix(logFormat, "json"):
h = slog.NewJSONHandler(out, opts)
case logFormat == "text":
case strings.HasPrefix(logFormat, "text"):
h = slog.NewTextHandler(out, opts)
default:
h = nic_glog.New(out, &nic_glog.Options{Level: programLevel})
Expand Down
55 changes: 55 additions & 0 deletions cmd/nginx-ingress/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,61 @@ func TestLogFormats(t *testing.T) {
}
}

func TestLogTimeFormats(t *testing.T) {
testCases := []struct {
name string
logFormat string
wantre string
}{
// JSON format tests
{
name: "json default time format",
logFormat: "json",
wantre: `^{"time":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+.*","level":"INFO","source":\{"file":"[^"]+\.go","line":\d+\},"msg":".*}`,
},
{
name: "json unix time format",
logFormat: "json-unix",
wantre: `^{"time":\d{10},"level":"INFO","source":\{"file":"[^"]+\.go","line":\d+\},"msg":".*}`,
},
{
name: "json unix-ms time format",
logFormat: "json-unix-ms",
wantre: `^{"time":\d{13},"level":"INFO","source":\{"file":"[^"]+\.go","line":\d+\},"msg":".*}`,
},
// TEXT format tests
{
name: "text default time format",
logFormat: "text",
wantre: `^time=\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+.*level=\w+\ssource=[^:]+\.go:\d+\smsg=\w+`,
},
{
name: "text unix time format",
logFormat: "text-unix",
wantre: `^time=\d{10}\slevel=\w+\ssource=[^:]+\.go:\d+\smsg=\w+`,
},
{
name: "text unix-ms time format",
logFormat: "text-unix-ms",
wantre: `^time=\d{13}\slevel=\w+\ssource=[^:]+\.go:\d+\smsg=\w+`,
},
}
t.Parallel()
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
var buf bytes.Buffer
ctx := initLogger(tc.logFormat, levels.LevelInfo, &buf)
l := nl.LoggerFromContext(ctx)
l.Log(ctx, levels.LevelInfo, "test")
got := buf.String()
re := regexp.MustCompile(tc.wantre)
if !re.MatchString(got) {
t.Errorf("\ngot:\n%q\nwant regex:\n%q", got, tc.wantre)
}
})
}
}

func TestK8sVersionValidation(t *testing.T) {
testCases := []struct {
name string
Expand Down
Loading