I am using https://godoc.org/github.com/vmihailenco/msgpack (which is officially recommended by messagepack.org for golang) What i am trying to do is to send log data in fluent 'forward' protocol.
I use the above lib to marshal to msgp. When i unmarshall, i do see it correct (forward) format. But fluent bit forwarder is saying -
[debug] [in_fw] parser: expecting an array (type=8), skip.
Below is unmarshaled data -
["my.containerlog",[[1441588984,{"LogEntry":"ce5632054b603019bd39b7e42b64a617--u003eHello:84424454 @Thu, 01 Nov 2018 21:50:16 GMT ","LogEntrySource":"stderr","LogEntryTimeStamp":"2018-11-01T21:50:16.109831526Z","Id":"e0a74c2b98d2fe3db0e3d37b135e475b9596258d8f08a361c531ee5fdcad210b","Image":"visert/hello:err100eps","Name":"d1116cbf-d649-11e8-8a20-4a33f2066f5b/visertcontainerhelloapp-1","SourceSystem":"Containers","Computer":"aks-agentpool-12720733-0"}]]]
I am using bytearray that i marshal to msgp.
var payLoad []byte
payLoad = append(payLoad, ([]byte (fmt.Sprintf("[\"%s\",[", "my.containerlog")))...)
//getting data and populating dataItem
dataItem := DataItem{
ID: stringMap["Id"],
LogEntry: stringMap["LogEntry"],
LogEntrySource: stringMap["LogEntrySource"],
LogEntryTimeStamp: stringMap["LogEntryTimeStamp"],
SourceSystem: stringMap["SourceSystem"],
Computer: Computer,
Image: stringMap["Image"],
Name: stringMap["Name"],
}
m, err := json.Marshal(dataItem) //convert data to json
payLoad = append(payLoad, ([]byte (fmt.Sprintf("[%d,%s]", 1441588984, m)))...)
payLoad = append(payLoad,([]byte (fmt.Sprintf("]]")))...)
b, err := msgpack.Marshal(payLoad)
//when i unmarshal i get the correct forward payload
var f []byte
e := msgpack.Unmarshal(b, &f)
What could be wrong ? I am not supposed to marshal byte[] ?