diff --git a/docker/cloudflared.yml b/docker/cloudflared.yml new file mode 100644 index 000000000..6e115bf5b --- /dev/null +++ b/docker/cloudflared.yml @@ -0,0 +1,13 @@ +version: "3.7" +services: + cloudflared: + image: cloudflare/cloudflared:latest + env_file: + - .env + restart: unless-stopped + command: + - "tunnel" + - "--no-autoupdate" + - "run" + - "--token" + - ${CLOUDFLARED_TOKEN} diff --git a/docker/opensearch.yml b/docker/opensearch.yml index 09ff9b8af..db1b73628 100644 --- a/docker/opensearch.yml +++ b/docker/opensearch.yml @@ -13,8 +13,8 @@ services: - QUESMA_logging_path=/var/quesma/logs - QUESMA_CONFIG_FILE=/config/local-dev.yaml depends_on: - clickhouse: - condition: service_healthy + clean-clickhouse: + condition: service_completed_successfully opensearch: condition: service_healthy ports: @@ -127,4 +127,11 @@ services: interval: 1s start_period: 1m timeout: 1s - # TODO: add clean, skip for now + clean-clickhouse: + build: clean-clickhouse + depends_on: + clickhouse: + condition: service_healthy + restart: "no" + volumes: + - ./mitmproxy:/var/mitmproxy diff --git a/docker/quesma/config/local-dev.yaml b/docker/quesma/config/local-dev.yaml index e9e7b4cf0..c352bc463 100644 --- a/docker/quesma/config/local-dev.yaml +++ b/docker/quesma/config/local-dev.yaml @@ -48,4 +48,10 @@ indexes: timestamp: source: "@timestamp" target: "created_at" - fullTextFields: [ "body", "title" ] \ No newline at end of file + fullTextFields: [ "body", "title" ] + opensearch_dashboards_sample_data_ecommerce: + enabled: true + opensearch_dashboards_sample_data_flights: + enabled: true + opensearch_dashboards_sample_data_logs: + enabled: true \ No newline at end of file diff --git a/quesma/model/metrics_aggregations/top_metrics.go b/quesma/model/metrics_aggregations/top_metrics.go index d3e4a92e0..0c34e5cdc 100644 --- a/quesma/model/metrics_aggregations/top_metrics.go +++ b/quesma/model/metrics_aggregations/top_metrics.go @@ -35,7 +35,7 @@ func (query TopMetrics) TranslateSqlResponseToJson(rows []model.QueryResultRow, sortVal := row.Cols[lastIndex].Value for _, col := range valuesForMetrics[level:] { colName, _ := strings.CutPrefix(col.ColName, "windowed_") - metrics[colName] = col.ExtractValue(context.TODO()) // CHANGE IT AFTER PART 2 MERGE!! ENTER REAL CONTEXT FROM THE query + metrics[colName] = col.ExtractValue(query.ctx) // CHANGE IT AFTER PART 2 MERGE!! ENTER REAL CONTEXT FROM THE query } elem := model.JsonMap{ "sort": []interface{}{sortVal}, diff --git a/quesma/model/query_result.go b/quesma/model/query_result.go index 27807b74b..f68dea1e3 100644 --- a/quesma/model/query_result.go +++ b/quesma/model/query_result.go @@ -18,7 +18,6 @@ type QueryResultCol struct { } type QueryResultRow struct { - ctx context.Context Index string Cols []QueryResultCol } @@ -110,13 +109,13 @@ func (c QueryResultCol) ExtractValue(ctx context.Context) any { return c.Value } -func (r QueryResultRow) String() string { +func (r QueryResultRow) String(ctx context.Context) string { str := strings.Builder{} str.WriteString(util.Indent(1) + "{\n") numCols := len(r.Cols) i := 0 for _, col := range r.Cols { - str.WriteString(util.Indent(2) + col.String(r.ctx)) + str.WriteString(util.Indent(2) + col.String(ctx)) if i < numCols-1 { str.WriteString(",") } diff --git a/quesma/queryparser/query_translator.go b/quesma/queryparser/query_translator.go index 89f33a381..f765c7441 100644 --- a/quesma/queryparser/query_translator.go +++ b/quesma/queryparser/query_translator.go @@ -83,7 +83,7 @@ func (cw *ClickhouseQueryTranslator) makeSearchResponseNormal(ResultSet []model. for i, row := range ResultSet { hits[i] = model.SearchHit{ Index: row.Index, - Source: []byte(row.String()), + Source: []byte(row.String(cw.Ctx)), Fields: make(map[string][]interface{}), Highlight: make(map[string][]string), }