diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go index 0c8581e8f6..4a57376b26 100644 --- a/pkg/query-service/app/clickhouseReader/reader.go +++ b/pkg/query-service/app/clickhouseReader/reader.go @@ -2884,7 +2884,7 @@ func (r *ClickHouseReader) GetLogs(ctx context.Context, params *model.LogsFilter } func (r *ClickHouseReader) TailLogs(ctx context.Context, client *model.LogsTailClient) { - response := &[]model.GetLogsResponse{} + fields, apiErr := r.GetLogFields(ctx) if apiErr != nil { client.Error <- apiErr.Err @@ -2934,8 +2934,9 @@ func (r *ClickHouseReader) TailLogs(ctx context.Context, client *model.LogsTailC if idStart != nil { tmpQuery += fmt.Sprintf(" and id > '%s'", *idStart) } - tmpQuery = fmt.Sprintf("%s order by timestamp asc limit 1000", tmpQuery) + tmpQuery = fmt.Sprintf("%s order by timestamp asc, id asc limit 1000", tmpQuery) zap.S().Debug(tmpQuery) + response := &[]model.GetLogsResponse{} err := r.db.Select(ctx, response, tmpQuery) if err != nil { zap.S().Debug(err) diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.go index 32113d801a..d5ef57164c 100644 --- a/pkg/query-service/app/http_handler.go +++ b/pkg/query-service/app/http_handler.go @@ -1951,13 +1951,12 @@ func (aH *APIHandler) tailLogs(w http.ResponseWriter, r *http.Request) { enc := json.NewEncoder(&buf) enc.Encode(ev) fmt.Fprintf(w, "data: %v\n\n", buf.String()) - fmt.Printf("data: %v\n", buf.String()) flusher.Flush() case <-client.Done: - fmt.Println("done!") + zap.S().Debug("done!") return case <-client.Error: - fmt.Println("error occured!") + zap.S().Debug("error occured!") return } } diff --git a/pkg/query-service/app/server.go b/pkg/query-service/app/server.go index b735f1b657..77ab3fc9b9 100644 --- a/pkg/query-service/app/server.go +++ b/pkg/query-service/app/server.go @@ -166,8 +166,8 @@ func (s *Server) createPublicServer(api *APIHandler) (*http.Server, error) { c := cors.New(cors.Options{ AllowedOrigins: []string{"*"}, - AllowedMethods: []string{"GET", "DELETE", "POST", "PUT"}, - AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"}, + AllowedMethods: []string{"GET", "DELETE", "POST", "PUT", "OPTIONS"}, + AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "cache-control"}, }) handler := c.Handler(r)