fluent / fluent/fluent-operator

bug: fluentbit lua filter code fails to generate valid lua code

Open
#1,692 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
682
Forks
328
Avg merge
2d 23h
Merged PRs (30d)
13

Description

### Describe the issue

I'm attempting to use the lua filter plugin but am seeing this error:

```
error] [luajit] error loading buffer: [string "fluentbit.lua"]:1: 'end' expected near ''
```

### To Reproduce

```
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterFilter
metadata:
name: my-filter
labels:
fluentbit.fluent.io/enabled: "true"
spec:
match: "*"
filters:
- lua:
code: |
function cb_print(tag, timestamp, record)
-- Add cluster and environment metadata
record["cluster_name"] = os.getenv("CLUSTER_NAME") or "unknown"
record["environment"] = os.getenv("CLUSTER_ENV") or "unknown"
record["node_name"] = os.getenv("NODE_NAME") or "unknown"

-- Add time fields for partitioning
local t = os.date("*t", timestamp)
record["year"] = string.format("%04d", t.year)
record["month"] = string.format("%02d", t.month)
record["day"] = string.format("%02d", t.day)
record["hour"] = string.format("%02d", t.hour)
record["minute"] = string.format("%02d", t.min)

return 1, timestamp, record
end
call: "cb_print"
```

### Expected behavior

That it'll result in valid lua code that fluentbit can use

### Your Environment

```markdown
- Fluent Operator version: 3.4.2
- Container Runtime: ghcr.io/fluent/fluent-operator/fluent-bit:v3.2.10
- Operating system:
- Kernel version:
```

### How did you install fluent operator?

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.