mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
01430a155c
Commit adds the following changes: * Adds support of OpenTelemetry logs for Victoria Logs with protobuf encoded messages * json encoding is not supported for the following reasons: - It brings a lot of fragile code, which works inefficiently. - json encoding is impossible to use with language SDK. * splits metrics and logs structures at lib/protoparser/opentelemetry/pb package. * adds docs with examples for opentelemetry logs. --- Related issue: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4839 Co-authored-by: AndrewChubatiuk <andrew.chubatiuk@gmail.com> Co-authored-by: f41gh7 <nik@victoriametrics.com>
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package vlinsert
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vlinsert/elasticsearch"
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vlinsert/jsonline"
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vlinsert/loki"
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vlinsert/opentelemetry"
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vlinsert/syslog"
|
|
)
|
|
|
|
// Init initializes vlinsert
|
|
func Init() {
|
|
syslog.MustInit()
|
|
}
|
|
|
|
// Stop stops vlinsert
|
|
func Stop() {
|
|
syslog.MustStop()
|
|
}
|
|
|
|
// RequestHandler handles insert requests for VictoriaLogs
|
|
func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|
path := r.URL.Path
|
|
if !strings.HasPrefix(path, "/insert/") {
|
|
// Skip requests, which do not start with /insert/, since these aren't our requests.
|
|
return false
|
|
}
|
|
path = strings.TrimPrefix(path, "/insert")
|
|
path = strings.ReplaceAll(path, "//", "/")
|
|
|
|
if path == "/jsonline" {
|
|
jsonline.RequestHandler(w, r)
|
|
return true
|
|
}
|
|
switch {
|
|
case strings.HasPrefix(path, "/elasticsearch/"):
|
|
path = strings.TrimPrefix(path, "/elasticsearch")
|
|
return elasticsearch.RequestHandler(path, w, r)
|
|
case strings.HasPrefix(path, "/loki/"):
|
|
path = strings.TrimPrefix(path, "/loki")
|
|
return loki.RequestHandler(path, w, r)
|
|
case strings.HasPrefix(path, "/opentelemetry/"):
|
|
path = strings.TrimPrefix(path, "/opentelemetry")
|
|
return opentelemetry.RequestHandler(path, w, r)
|
|
default:
|
|
return false
|
|
}
|
|
}
|