@@ -112,6 +112,8 @@ func (l *Loki) start(hCh chan *decoder.HEP) {
112112
113113 pktMeta .Reset ()
114114
115+ l .entry = entry {model.LabelSet {}, logproto.Entry {Timestamp : curPktTime }}
116+
115117 if pkt .ProtoString == "rtcp" {
116118 var document map [string ]interface {}
117119 err := json .Unmarshal ([]byte (pkt .Payload ), & document )
@@ -121,6 +123,9 @@ func (l *Loki) start(hCh chan *decoder.HEP) {
121123 } else {
122124 document ["cid" ] = pkt .CID
123125 documentJson , err := json .Marshal (document )
126+ if config .Setting .LokiCallIDLabels {
127+ l .entry .labels ["call_id" ] = model .LabelValue (pkt .CID )
128+ }
124129 if err != nil {
125130 logp .Err ("Unable to re-generate rtcp json: %v" , err )
126131 pktMeta .WriteString (pkt .Payload )
@@ -131,7 +136,6 @@ func (l *Loki) start(hCh chan *decoder.HEP) {
131136 } else {
132137 pktMeta .WriteString (pkt .Payload )
133138 }
134- l .entry = entry {model.LabelSet {}, logproto.Entry {Timestamp : curPktTime }}
135139
136140 switch {
137141 case pkt .SIP != nil && pkt .ProtoType == 1 :
@@ -142,8 +146,15 @@ func (l *Loki) start(hCh chan *decoder.HEP) {
142146 protocol = "tcp"
143147 } else if pkt .Protocol == 17 {
144148 protocol = "udp"
145- }
149+ }
146150 l .entry .labels ["protocol" ] = model .LabelValue (protocol )
151+ if config .Setting .LokiCallIDLabels {
152+ l .entry .labels ["call_id" ] = model .LabelValue (pkt .SIP .CallID )
153+ }
154+ if config .Setting .LokiFromToLabels {
155+ l .entry .labels ["from" ] = model .LabelValue (pkt .SIP .From .Val )
156+ l .entry .labels ["to" ] = model .LabelValue (pkt .SIP .To .Val )
157+ }
147158 case pkt .ProtoType == 100 :
148159 protocol := "udp"
149160 if strings .Contains (pkt .Payload , "Fax" ) || strings .Contains (pkt .Payload , "T38" ) {
0 commit comments