loki adjust
This commit is contained in:
@@ -58,14 +58,13 @@ func (w *LokiWriter) Write(p []byte) (n int, err error) {
|
|||||||
// Add label that have been added to the event
|
// Add label that have been added to the event
|
||||||
// A bit unsafe since we don't know what could be stored in the event
|
// A bit unsafe since we don't know what could be stored in the event
|
||||||
// but we can't access this object once passed to the multilevel writter
|
// but we can't access this object once passed to the multilevel writter
|
||||||
|
|
||||||
for k,v := range(event){
|
for k, v := range event {
|
||||||
if k != "level" && k != "time" && k != "message"{
|
if k != "level" && k != "time" && k != "message" {
|
||||||
labels[k] = v.(string)
|
labels[k] = fmt.Sprintf("%v", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Format the timestamp in nanoseconds
|
// Format the timestamp in nanoseconds
|
||||||
timestamp := fmt.Sprintf("%d000000", time.Now().UnixNano()/int64(time.Millisecond))
|
timestamp := fmt.Sprintf("%d000000", time.Now().UnixNano()/int64(time.Millisecond))
|
||||||
|
|
||||||
@@ -87,7 +86,7 @@ func (w *LokiWriter) Write(p []byte) (n int, err error) {
|
|||||||
|
|
||||||
//fmt.Printf("Sending payload to Loki: %s\n", string(payloadBytes))
|
//fmt.Printf("Sending payload to Loki: %s\n", string(payloadBytes))
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", w.url + "/loki/api/v1/push", bytes.NewReader(payloadBytes))
|
req, err := http.NewRequest("POST", w.url+"/loki/api/v1/push", bytes.NewReader(payloadBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("failed to create HTTP request: %w", err)
|
return 0, fmt.Errorf("failed to create HTTP request: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user