Skip to content

Commit

Permalink
Merge pull request #527 from sipcapture/labels_loki
Browse files Browse the repository at this point in the history
Labels loki
  • Loading branch information
adubovikov committed Jun 29, 2023
2 parents 994d7ad + 2485b0d commit 419aa21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package config

const Version = "heplify-server 1.59.3"
const Version = "heplify-server 1.59.4"

var Setting HeplifyServer

Expand All @@ -19,6 +19,7 @@ type HeplifyServer struct {
LokiTimer int `default:"4"`
LokiBuffer int `default:"100000"`
LokiHEPFilter []int `default:"1,5,100"`
LokiIPPortLabels bool `default:"false"`
ForceHEPPayload []int `default:""`
PromAddr string `default:":9096"`
PromTargetIP string `default:""`
Expand Down
10 changes: 9 additions & 1 deletion remotelog/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"context"
"fmt"
"io"
"os"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -128,6 +129,13 @@ func (l *Loki) start(hCh chan *decoder.HEP) {
l.entry.labels["type"] = model.LabelValue(pkt.ProtoString)
l.entry.Entry.Line = pktMeta.String()

if config.Setting.LokiIPPortLabels {
l.entry.labels["src_ip"] = model.LabelValue(pkt.SrcIP)
l.entry.labels["src_port"] = model.LabelValue(strconv.FormatUint(uint64(pkt.SrcPort), 10))
l.entry.labels["dst_ip"] = model.LabelValue(pkt.DstIP)
l.entry.labels["dst_port"] = model.LabelValue(strconv.FormatUint(uint64(pkt.DstPort), 10))
}

if batchSize+len(l.entry.Line) > l.BatchSize {
if err := l.sendBatch(batch); err != nil {
logp.Err("send size batch: %v", err)
Expand Down

0 comments on commit 419aa21

Please sign in to comment.