github.com/Financial-Times/publish-availability-monitor@v1.12.0/metrics/splunkFeeder.go (about) 1 package metrics 2 3 import ( 4 "log" 5 "os" 6 ) 7 8 // SplunkFeeder implements Destination interface to send PublishMetrics to Splunk. 9 // This is achieved by writing the metric into a file which is indexed by Splunk. 10 type SplunkFeeder struct { 11 MetricLog *log.Logger 12 } 13 14 // NewSplunkFeeder returns a SplunkFeeder which will write the PublishMetrics to the file at filePath. 15 // If the file exists, it will be appended to. 16 func NewSplunkFeeder(logPrefix string) *SplunkFeeder { 17 logger := log.New(os.Stdout, logPrefix, log.Ldate|log.Ltime|log.Lmicroseconds|log.LUTC) 18 return &SplunkFeeder{logger} 19 } 20 21 // Send logs pm into a file. 22 func (sf SplunkFeeder) Send(pm PublishMetric) { 23 sf.MetricLog.Printf("UUID=%v readEnv=%v transaction_id=%v publishDate=%v publishOk=%v duration=%v endpoint=%v ", 24 pm.UUID, pm.Platform, pm.TID, pm.PublishDate.UnixNano(), pm.PublishOK, pm.PublishInterval.UpperBound, pm.Config.Alias) 25 }