Skip to content

Commit

Permalink
Merge pull request #542 from tsearle/add_cid_to_rtcp
Browse files Browse the repository at this point in the history
add cid to rtcp
  • Loading branch information
adubovikov committed Feb 12, 2024
2 parents 00229d1 + b44a8d9 commit 292479c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ You have 3 options to get **heplify-server** up and running:
* Docker [compose](https://github.com/sipcapture/heplify-server/tree/master/docker/hom5-hep-prom-graf)
* Compile from sources:

Install luajit dev libary
Install gcc and luajit dev libary

`apt-get install libluajit-5.1-dev`
`apt-get install build-essential libluajit-5.1-dev`

or

Expand Down
23 changes: 22 additions & 1 deletion remotelog/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -106,7 +107,26 @@ func (l *Loki) start(hCh chan *decoder.HEP) {
lastPktTime = curPktTime

pktMeta.Reset()
pktMeta.WriteString(pkt.Payload)

if pkt.ProtoString == "rtcp" {
var document map[string]interface{}
err := json.Unmarshal([]byte(pkt.Payload), &document)
if err != nil {
logp.Err("Unable to decode rtcp json: %v", err)
pktMeta.WriteString(pkt.Payload)
} else {
document["cid"] = pkt.CID
documentJson, err := json.Marshal(document)
if err != nil {
logp.Err("Unable to re-generate rtcp json: %v", err)
pktMeta.WriteString(pkt.Payload)
} else {
pktMeta.Write(documentJson)
}
}
} else {
pktMeta.WriteString(pkt.Payload)
}
l.entry = entry{model.LabelSet{}, logproto.Entry{Timestamp: curPktTime}}

switch {
Expand All @@ -121,6 +141,7 @@ func (l *Loki) start(hCh chan *decoder.HEP) {
protocol = "sip"
}
l.entry.labels["protocol"] = model.LabelValue(protocol)

}

l.entry.labels["job"] = jobName
Expand Down

0 comments on commit 292479c

Please sign in to comment.