Skip to content

Commit cd39efd

Browse files
committed
chore(fluentbit): add rfc3399 format
1 parent 59419c8 commit cd39efd

4 files changed

Lines changed: 28 additions & 24 deletions

File tree

charts/fluentbit/Chart.lock

Lines changed: 0 additions & 6 deletions
This file was deleted.
-13.4 KB
Binary file not shown.

charts/fluentbit/values.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ config:
7676
Match kubernetes.*
7777
Base_URL http://drycc-quickwit-indexer.{{ $.Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}:7280
7878
Compress true
79-
Index_Name {{ .Values.quickwit.logIndexPrefix }}${ .kubernetes.namespace_name | default "{{ .Release.Namespace }}" }
79+
Index_Name {{printf "%s{{ %s | default \"%s\" }}" .Values.quickwit.logIndexPrefix ".kubernetes.namespace_name" .Release.Namespace }}
8080
Buffer_Size 65536
8181
Json_Date_Key timestamp
82-
Json_Date_Format %Y-%m-%dT%H:%M:%S%z
82+
Json_Date_Format rfc3399
8383
## https://docs.fluentbit.io/manual/pipeline/parsers
8484
parsers: |
8585
[PARSER]
@@ -101,3 +101,6 @@ config:
101101
plugins: |
102102
[PLUGINS]
103103
Path /opt/drycc/fluent-bit/lib/out_quickwit.so
104+
105+
global:
106+
clusterDomain: "cluster.local"

plugin/out_quickwit.go

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func FLBPluginInit(ctx unsafe.Pointer) int {
6666
return buffer
6767
},
6868
}
69-
IndexNameTemplate, err = template.New("url").Funcs(sprig.FuncMap()).Delims("${", "}").Parse(IndexName)
69+
IndexNameTemplate, err = template.New("index").Funcs(sprig.FuncMap()).Parse(IndexName)
7070
if err != nil {
7171
panic(err)
7272
}
@@ -123,21 +123,28 @@ func formatTime(ts any, format string) string {
123123
default:
124124
timestamp = time.Now()
125125
}
126-
return timestamp.Format(strings.NewReplacer(
127-
"%Y", "2006",
128-
"%y", "06",
129-
"%m", "01",
130-
"%d", "02",
131-
"%H", "15",
132-
"%I", "03",
133-
"%M", "04",
134-
"%S", "05",
135-
"%p", "PM",
136-
"%L", "000",
137-
"%f", "000000",
138-
"%z", "-0700",
139-
"%Z", "MST",
140-
).Replace(format))
126+
switch format {
127+
case "rfc3399":
128+
return timestamp.Format(time.RFC3339)
129+
case "unix_timestamp":
130+
return fmt.Sprint(timestamp.Unix())
131+
default:
132+
return timestamp.Format(strings.NewReplacer(
133+
"%Y", "2006",
134+
"%y", "06",
135+
"%m", "01",
136+
"%d", "02",
137+
"%H", "15",
138+
"%I", "03",
139+
"%M", "04",
140+
"%S", "05",
141+
"%p", "PM",
142+
"%L", "000",
143+
"%f", "000000",
144+
"%z", "-0700",
145+
"%Z", "MST",
146+
).Replace(format))
147+
}
141148
}
142149

143150
func convertMap(values map[any]any) map[string]any {

0 commit comments

Comments
 (0)