diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0736cce..d94c43d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: | diff --git a/output/out_lm.go b/output/out_lm.go index 2510eb0..e9ae073 100644 --- a/output/out_lm.go +++ b/output/out_lm.go @@ -33,6 +33,7 @@ type LogicmonitorOutput struct { client *LogicmonitorClient logIngestor *logs.LMLogIngest id string + resourceType string } var ( @@ -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 } @@ -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) @@ -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 @@ -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 { diff --git a/plugins/out_lm-linux-arm64.so b/plugins/out_lm-linux-arm64.so index b147f28..106be53 100644 Binary files a/plugins/out_lm-linux-arm64.so and b/plugins/out_lm-linux-arm64.so differ diff --git a/plugins/out_lm-linux.so b/plugins/out_lm-linux.so index 7ef3a71..f59ca47 100644 Binary files a/plugins/out_lm-linux.so and b/plugins/out_lm-linux.so differ diff --git a/plugins/out_lm-windows.so b/plugins/out_lm-windows.so index 7ef627f..f77ecde 100644 Binary files a/plugins/out_lm-windows.so and b/plugins/out_lm-windows.so differ diff --git a/plugins/out_lm.so b/plugins/out_lm.so index 1f4b402..a08e984 100644 Binary files a/plugins/out_lm.so and b/plugins/out_lm.so differ