This commit is contained in:
mr
2025-06-16 09:17:03 +02:00
6 changed files with 143 additions and 28 deletions

View File

@@ -27,9 +27,12 @@ type LokiInfo struct {
// @Success 200 {workspace} models.workspace
// @router / [post]
func (o *LokiController) GetLogs() {
path := "/loki/api/v1/query_range"
var resp map[string]interface{}
json.Unmarshal(o.Ctx.Input.CopyBody(100000), &resp)
path := "/loki/api/v1/query_range"
if len(resp) > 0 {
start := fmt.Sprintf("%v", resp["start"])
if len(start) > 10 {
@@ -53,6 +56,7 @@ func (o *LokiController) GetLogs() {
return
}
path += "?query={" + strings.Join(query, ", ") + "}&start=" + start + "&end=" + end
resp, err := http.Get(config.GetConfig().LokiUrl + path) // CALL
fmt.Println(resp, path)
if err != nil {
@@ -76,6 +80,7 @@ func (o *LokiController) GetLogs() {
o.ServeJSON()
return
}
o.Ctx.ResponseWriter.WriteHeader(403)
o.Data["json"] = map[string]string{"error": "Query error"}
o.ServeJSON()