2023-06-20 05:55:12 +00:00
|
|
|
package vlinsert
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vlinsert/elasticsearch"
|
2023-06-21 13:31:28 +00:00
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vlinsert/jsonline"
|
2023-06-20 05:55:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Init initializes vlinsert
|
|
|
|
func Init() {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop stops vlinsert
|
|
|
|
func Stop() {
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestHandler handles insert requests for VictoriaLogs
|
|
|
|
func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|
|
|
path := r.URL.Path
|
|
|
|
if !strings.HasPrefix(path, "/insert/") {
|
2023-06-22 02:52:48 +00:00
|
|
|
// Skip requests, which do not start with /insert/, since these aren't our requests.
|
2023-06-20 05:55:12 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
path = strings.TrimPrefix(path, "/insert")
|
|
|
|
path = strings.ReplaceAll(path, "//", "/")
|
|
|
|
|
2023-06-22 02:39:22 +00:00
|
|
|
if path == "/jsonline" {
|
|
|
|
return jsonline.RequestHandler(w, r)
|
|
|
|
}
|
2023-06-20 05:55:12 +00:00
|
|
|
switch {
|
|
|
|
case strings.HasPrefix(path, "/elasticsearch/"):
|
|
|
|
path = strings.TrimPrefix(path, "/elasticsearch")
|
|
|
|
return elasticsearch.RequestHandler(path, w, r)
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|