Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/loki/source/internal/kafkatarget/parser.go
4096 views
1
package kafkatarget
2
3
import (
4
"github.com/Shopify/sarama"
5
"github.com/grafana/agent/component/common/loki"
6
"github.com/grafana/loki/pkg/logproto"
7
"github.com/prometheus/common/model"
8
"github.com/prometheus/prometheus/model/relabel"
9
)
10
11
// KafkaTargetMessageParser implements MessageParser. It doesn't modify the content of the original `message.Value`.
12
type KafkaTargetMessageParser struct{}
13
14
func (p *KafkaTargetMessageParser) Parse(message *sarama.ConsumerMessage, labels model.LabelSet, relabels []*relabel.Config, useIncomingTimestamp bool) ([]loki.Entry, error) {
15
return []loki.Entry{
16
{
17
Labels: labels,
18
Entry: logproto.Entry{
19
Timestamp: timestamp(useIncomingTimestamp, message.Timestamp),
20
Line: string(message.Value),
21
},
22
},
23
}, nil
24
}
25
26