fix: only write metrics if there is a useragent
This commit is contained in:
parent
757d47fc41
commit
7c5c1d6406
@ -39,6 +39,7 @@ func parseFunc(t *tail.Tail) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(l.Request.Headers.UserAgent) != 0 {
|
||||||
metrics.GetOrCreateCounter(
|
metrics.GetOrCreateCounter(
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
`%s_http_request_total{host="%s", proto="%s", method="%s", status="%d", user_agent="%s"}`,
|
`%s_http_request_total{host="%s", proto="%s", method="%s", status="%d", user_agent="%s"}`,
|
||||||
@ -61,5 +62,8 @@ func parseFunc(t *tail.Tail) {
|
|||||||
l.Status,
|
l.Status,
|
||||||
),
|
),
|
||||||
).Update(l.Duration)
|
).Update(l.Duration)
|
||||||
|
} else {
|
||||||
|
slog.Warn("got empty user agent", "headers", l.Request.Headers)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user