diff --git a/README.md b/README.md index 21e59c4..9b19204 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,27 @@ The license for this project is [AGPL-3.0](LICENSE.md), and a [notice](NOTICE.md We recommand Grafana v9.5 or v10. +Quickwit 0.6 is compatible with 0.2.x versions only. + +Quickwit 0.7 is compatible with 0.3.x versions only. + + ## Installation -### Download the latest release (0.2.4) +### Download the 0.3.0 for Quickwit 0.7 + +```bash +wget https://github.com/quickwit-oss/quickwit-datasource/releases/download/v0.3.0/quickwit-quickwit-datasource-0.3.0.zip +``` + +### Unzip into the plugins directory + +```bash +mkdir -p grafana-storage/plugins +unzip quickwit-quickwit-datasource-0.3.0.zip -d grafana-storage/plugins +``` + +### Download the 0.2.4 for Quickwit 0.6 ```bash wget https://github.com/quickwit-oss/quickwit-datasource/releases/download/v0.2.4/quickwit-quickwit-datasource-0.2.4.zip diff --git a/package-lock.json b/package-lock.json index 35d11d4..add0d0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "quickwit-datasource", - "version": "0.3.0-beta.3", + "version": "0.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "quickwit-datasource", - "version": "0.3.0-beta.3", + "version": "0.3.0", "license": "AGPL-3.0", "dependencies": { "@emotion/css": "^11.1.3", diff --git a/package.json b/package.json index bff54cf..dda52a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quickwit-datasource", - "version": "0.3.0-beta.3", + "version": "0.3.0", "description": "Quickwit datasource", "scripts": { "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", diff --git a/pkg/quickwit/client/search_request.go b/pkg/quickwit/client/search_request.go index efe268a..41b83dc 100644 --- a/pkg/quickwit/client/search_request.go +++ b/pkg/quickwit/client/search_request.go @@ -81,7 +81,7 @@ const ( ) // Sort adds a "asc" | "desc" sort to the search request -func (b *SearchRequestBuilder) Sort(order SortOrder, field string, unmappedType string) *SearchRequestBuilder { +func (b *SearchRequestBuilder) Sort(order SortOrder, field string, format string) *SearchRequestBuilder { if order != SortOrderAsc && order != SortOrderDesc { return b } @@ -91,10 +91,9 @@ func (b *SearchRequestBuilder) Sort(order SortOrder, field string, unmappedType "order": string(order), } - // FIXME when quickwit supports unmapped_type - // if unmappedType != "" { - // props["unmapped_type"] = unmappedType - // } + if format != "" { + sort[field]["format"] = format + } b.sort = append(b.sort, sort) diff --git a/pkg/quickwit/client/search_request_test.go b/pkg/quickwit/client/search_request_test.go index 302e6f0..b2cf3c8 100644 --- a/pkg/quickwit/client/search_request_test.go +++ b/pkg/quickwit/client/search_request_test.go @@ -45,7 +45,7 @@ func TestSearchRequest(t *testing.T) { t.Run("When adding size, sort, filters", func(t *testing.T) { b := setup() b.Size(200) - b.Sort(SortOrderDesc, timeField, "boolean") + b.Sort(SortOrderDesc, timeField, "epoch_nanos_int") filters := b.Query().Bool().Filter() filters.AddDateRangeFilter(timeField, 1684398201000, 1684308201000) filters.AddQueryStringFilter("test", true) diff --git a/pkg/quickwit/data_query.go b/pkg/quickwit/data_query.go index 788f86a..ef7ad30 100644 --- a/pkg/quickwit/data_query.go +++ b/pkg/quickwit/data_query.go @@ -353,7 +353,7 @@ func processLogsQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defa // This is currently used only for log context query sort = es.SortOrderAsc } - b.Sort(sort, defaultTimeField, "boolean") + b.Sort(sort, defaultTimeField, "epoch_nanos_int") b.Size(stringToIntWithDefaultValue(metric.Settings.Get("limit").MustString(), defaultSize)) // TODO when hightlight is supported in quickwit // b.AddHighlight() @@ -368,7 +368,7 @@ func processLogsQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defa func processDocumentQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defaultTimeField string) { metric := q.Metrics[0] - b.Sort(es.SortOrderDesc, defaultTimeField, "boolean") + b.Sort(es.SortOrderDesc, defaultTimeField, "epoch_nanos_int") b.Sort(es.SortOrderDesc, "_doc", "") // Note: not supported in Quickwit // b.AddDocValueField(defaultTimeField) diff --git a/src/configuration/DataLink.tsx b/src/configuration/DataLink.tsx index 48431fd..9ce4017 100644 --- a/src/configuration/DataLink.tsx +++ b/src/configuration/DataLink.tsx @@ -30,7 +30,6 @@ export const DataLink = (props: Props) => { const { value, onChange, onDelete, suggestions, className } = props; const styles = useStyles2(getStyles); const [showInternalLink, setShowInternalLink] = useInternalLink(value.datasourceUid); - const [base64TraceId, setBase64TraceId] = useState(true) const labelWidth = 24 const handleChange = (field: keyof typeof value) => (event: React.ChangeEvent) => { @@ -40,11 +39,6 @@ export const DataLink = (props: Props) => { }); }; - const handleBase64TraceId = (base64TraceId: boolean, config: DataLinkConfig) => { - setBase64TraceId(base64TraceId) - config = {...config, base64TraceId: base64TraceId }; - } - return (
@@ -73,15 +67,6 @@ export const DataLink = (props: Props) => { />
-
- - handleBase64TraceId(!base64TraceId, value)} - /> - -
-
diff --git a/src/datasource.ts b/src/datasource.ts index eaf4c1a..1199bdf 100644 --- a/src/datasource.ts +++ b/src/datasource.ts @@ -4,7 +4,6 @@ import { catchError, mergeMap, map } from 'rxjs/operators'; import { AbstractQuery, - ArrayVector, CoreApp, DataFrame, DataLink, @@ -18,7 +17,6 @@ import { DataSourceWithQueryImportSupport, DataSourceWithSupplementaryQueriesSupport, dateTime, - Field, FieldColorModeId, FieldType, getDefaultTimeRange, @@ -850,47 +848,10 @@ function luceneEscape(value: string) { return value.replace(/([\!\*\+\-\=<>\s\&\|\(\)\[\]\{\}\^\~\?\:\\/"])/g, '\\$1'); } -function base64ToHex(base64String: string) { - const binaryString = window.atob(base64String); - return Array.from(binaryString).map(char => { - const byte = char.charCodeAt(0); - return ('0' + byte.toString(16)).slice(-2); - }).join(''); -} - export function enhanceDataFrameWithDataLinks(dataFrame: DataFrame, dataLinks: DataLinkConfig[]) { if (!dataLinks.length) { return; } - let fields_to_fix_condition = (field: Field) => { - return dataLinks.filter((dataLink) => dataLink.field === field.name && dataLink.base64TraceId).length === 1; - }; - const fields_to_keep = dataFrame.fields.filter((field) => { - return !fields_to_fix_condition(field) - }); - let new_fields = dataFrame - .fields - .filter(fields_to_fix_condition) - .map((field) => { - let values = field.values.toArray().map((value) => { - try { - return base64ToHex(value); - } catch (e) { - console.warn("cannot convert value from base64 to hex", e); - return value; - }; - }); - return { - ...field, - values: new ArrayVector(values), - } - }); - - if (new_fields.length === 0) { - return; - } - - dataFrame.fields = [new_fields[0], ...fields_to_keep]; for (const field of dataFrame.fields) { const linksToApply = dataLinks.filter((dataLink) => dataLink.field === field.name);