Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

# Optional Step 5: Commit the .so files back to the repository
- name: Commit and Push Generated .so Files
if: success() && github.ref != 'refs/heads/master' # Skip committing to the master branch
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
11 changes: 8 additions & 3 deletions output/out_lm.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type LogicmonitorOutput struct {
client *LogicmonitorClient
logIngestor *logs.LMLogIngest
id string
resourceType string
}

var (
Expand Down Expand Up @@ -145,7 +146,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
break
}

log, err := serializeRecord(ts, C.GoString(tag), record, id)
log, err := serializeRecord(ts, C.GoString(tag), record, id, outputs[id].resourceType)
if err != nil {
continue
}
Expand Down Expand Up @@ -219,6 +220,7 @@ func initConfigParams(ctx unsafe.Pointer) error {
if versionId == "" {
versionId = "1.0.0"
}
resourceType := output.FLBPluginConfigKey(ctx, "resourceType")

client := NewClient(lmCompanyName, accessID, accessKey, bearerToken, useBearerTokenforAuth, resourceMapping, includeMetadata, logSource, versionId, logger)
logIngestor := NewLogIngester(client)
Expand All @@ -227,12 +229,13 @@ func initConfigParams(ctx unsafe.Pointer) error {
client: client,
logIngestor: logIngestor,
id: outputId,
resourceType: resourceType,
}

return nil
}

func serializeRecord(ts interface{}, tag string, record map[interface{}]interface{}, outputId string) ([]byte, error) {
func serializeRecord(ts interface{}, tag string, record map[interface{}]interface{}, outputId string, resourceType string) ([]byte, error) {
body := parseJSON(record)
var err error

Expand All @@ -247,7 +250,9 @@ func serializeRecord(ts interface{}, tag string, record map[interface{}]interfac

body["timestamp"] = formatTimestamp(ts)
body["fluentbit_tag"] = tag
body["_resource.type"] = "Fluentbit"
if resourceType != "" {
body["_resource.type"] = resourceType
}

serialized, err := jsoniter.Marshal(body)
if err != nil {
Expand Down
Binary file modified plugins/out_lm-linux-arm64.so
Binary file not shown.
Binary file modified plugins/out_lm-linux.so
Binary file not shown.
Binary file modified plugins/out_lm-windows.so
Binary file not shown.
Binary file modified plugins/out_lm.so
Binary file not shown.