douyinmian8151 2018-11-01 22:22
浏览 51

流利的消息包

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[] ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类
    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思