diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f56a5f..a02e4b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v1.6.0 + +- Support true passthrough of LogEvent + + **NOTE**: `LogData.Message` field must be base64 encoded! + ## v1.5.2 - Feature: support LogEvent passthrough (@rostbel) diff --git a/go.mod b/go.mod index 5e8b7b5..88c8e13 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/m4rw3r/uuid v1.0.1 github.com/opentracing/opentracing-go v1.2.0 github.com/openzipkin/zipkin-go v0.3.0 - github.com/philips-software/go-hsdp-api v0.48.2 + github.com/philips-software/go-hsdp-api v0.49.1 github.com/sirupsen/logrus v1.8.1 github.com/spf13/viper v1.9.0 github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 diff --git a/go.sum b/go.sum index 5c099ac..ceea810 100644 --- a/go.sum +++ b/go.sum @@ -689,8 +689,8 @@ github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= -github.com/philips-software/go-hsdp-api v0.48.2 h1:V+mfOylG/qnxEx6tWHVpKeKzx5aq3lK0ZVJYfy1QX7Y= -github.com/philips-software/go-hsdp-api v0.48.2/go.mod h1:+/oOyI8Equm7/YcUHJ+PO3HO4U92JcAAoOs5DYRRkIc= +github.com/philips-software/go-hsdp-api v0.49.1 h1:4pOnNIVkL9/wnduPszJCI52FWYk6p6+bQMWVusmTC7M= +github.com/philips-software/go-hsdp-api v0.49.1/go.mod h1:+/oOyI8Equm7/YcUHJ+PO3HO4U92JcAAoOs5DYRRkIc= github.com/philips-software/go-hsdp-signer v1.4.0 h1:yg7UILhmI4xJhr/tQiAiQwJL0EZFvLuMqpH2GZ9ygY4= github.com/philips-software/go-hsdp-signer v1.4.0/go.mod h1:/QehZ/+Aks2t1TFpjhF/7ZSB8PJIIJHzLc03rOqwLw0= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= diff --git a/queue/deliverer.go b/queue/deliverer.go index 466945d..a4d37b4 100644 --- a/queue/deliverer.go +++ b/queue/deliverer.go @@ -2,6 +2,7 @@ package queue import ( "context" + "encoding/base64" "encoding/json" "errors" "fmt" @@ -359,6 +360,10 @@ func wrapResource(originatingUser string, msg syslog.Message) logging.Resource { lm.LogData.Message = *m } + lm.ResourceType = "LogEvent" + // Base64 encode + lm.LogData.Message = base64.StdEncoding.EncodeToString([]byte(lm.LogData.Message)) + return lm } diff --git a/queue/deliverer_test.go b/queue/deliverer_test.go index 81be00f..728199b 100644 --- a/queue/deliverer_test.go +++ b/queue/deliverer_test.go @@ -49,7 +49,7 @@ func TestDeliveryToResource(t *testing.T) { assert.NotNil(t, err) } -func TestProcessMessagePassthrough(t *testing.T) { +func TestProcessMessagePassthroughs(t *testing.T) { var rawMessage = `{"serviceName":"5c737703-fef3-49ed-9efe-51ba3a68c3e7","transactionId":"07bdcdd6-b398-48e2-99f9-6ed6209c84f2","applicationName":"5c737703-fef3-49ed-9efe-51ba3a68c3e7","applicationInstance":"%5BAPP/PROC/WEB/0%5D","resourceType":"LogEvent","severity":"informational","logTime":"2021-11-01T11:45:22.462Z","applicationVersion":"v1.2.2-deadbeaf","originatingUser":"logproxy-wrapped","logData":{"message":"Hello world"},"eventId":"1","component":"logproxy","id":"d6c0adef-54c0-4452-ad71-65b01eb1becd","category":"ApplicationLog","custom":{"tenantId":"265a6faa-c3be-4b5a-b827-f8a8bc569064","timestampUtc":"2021-11-01T11:45:22.430Z","userId":"foo@bar.com","durationMs":"3000"},"serverName":"client-xxx.dev.userpreferenceservice"}` var payload = `<14>1 2018-09-07T15:39:21.132433+00:00 suite-phs.staging.msa-eustaging appname [APP/PROC/WEB/0] - - ` + rawMessage @@ -130,7 +130,7 @@ func TestProcessMessage(t *testing.T) { assert.Equal(t, "2018-09-07T15:39:18.517Z", resource.LogTime) assert.Equal(t, appName, resource.ApplicationName) assert.Equal(t, hostName, resource.ServerName) - assert.Equal(t, "Starting health monitoring of container", resource.LogData.Message) + assert.Equal(t, "U3RhcnRpbmcgaGVhbHRoIG1vbml0b3Jpbmcgb2YgY29udGFpbmVy", resource.LogData.Message) } func TestResourceWorker(t *testing.T) {