Skip to content

Commit 04d722d

Browse files
authored
Merge pull request #43 from quickwit-oss/fmassot/for-0.7-release
Prepare quickwit datasource for quickwit 0.7.
2 parents 6946a39 + 148d22f commit 04d722d

File tree

8 files changed

+29
-66
lines changed

8 files changed

+29
-66
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,27 @@ The license for this project is [AGPL-3.0](LICENSE.md), and a [notice](NOTICE.md
2121

2222
We recommand Grafana v9.5 or v10.
2323

24+
Quickwit 0.6 is compatible with 0.2.x versions only.
25+
26+
Quickwit 0.7 is compatible with 0.3.x versions only.
27+
28+
2429
## Installation
2530

26-
### Download the latest release (0.2.4)
31+
### Download the 0.3.0 for Quickwit 0.7
32+
33+
```bash
34+
wget https://github.com/quickwit-oss/quickwit-datasource/releases/download/v0.3.0/quickwit-quickwit-datasource-0.3.0.zip
35+
```
36+
37+
### Unzip into the plugins directory
38+
39+
```bash
40+
mkdir -p grafana-storage/plugins
41+
unzip quickwit-quickwit-datasource-0.3.0.zip -d grafana-storage/plugins
42+
```
43+
44+
### Download the 0.2.4 for Quickwit 0.6
2745

2846
```bash
2947
wget https://github.com/quickwit-oss/quickwit-datasource/releases/download/v0.2.4/quickwit-quickwit-datasource-0.2.4.zip

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "quickwit-datasource",
3-
"version": "0.3.0-beta.3",
3+
"version": "0.3.0",
44
"description": "Quickwit datasource",
55
"scripts": {
66
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",

pkg/quickwit/client/search_request.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const (
8181
)
8282

8383
// Sort adds a "asc" | "desc" sort to the search request
84-
func (b *SearchRequestBuilder) Sort(order SortOrder, field string, unmappedType string) *SearchRequestBuilder {
84+
func (b *SearchRequestBuilder) Sort(order SortOrder, field string, format string) *SearchRequestBuilder {
8585
if order != SortOrderAsc && order != SortOrderDesc {
8686
return b
8787
}
@@ -91,10 +91,9 @@ func (b *SearchRequestBuilder) Sort(order SortOrder, field string, unmappedType
9191
"order": string(order),
9292
}
9393

94-
// FIXME when quickwit supports unmapped_type
95-
// if unmappedType != "" {
96-
// props["unmapped_type"] = unmappedType
97-
// }
94+
if format != "" {
95+
sort[field]["format"] = format
96+
}
9897

9998
b.sort = append(b.sort, sort)
10099

pkg/quickwit/client/search_request_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestSearchRequest(t *testing.T) {
4545
t.Run("When adding size, sort, filters", func(t *testing.T) {
4646
b := setup()
4747
b.Size(200)
48-
b.Sort(SortOrderDesc, timeField, "boolean")
48+
b.Sort(SortOrderDesc, timeField, "epoch_nanos_int")
4949
filters := b.Query().Bool().Filter()
5050
filters.AddDateRangeFilter(timeField, 1684398201000, 1684308201000)
5151
filters.AddQueryStringFilter("test", true)

pkg/quickwit/data_query.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func processLogsQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defa
353353
// This is currently used only for log context query
354354
sort = es.SortOrderAsc
355355
}
356-
b.Sort(sort, defaultTimeField, "boolean")
356+
b.Sort(sort, defaultTimeField, "epoch_nanos_int")
357357
b.Size(stringToIntWithDefaultValue(metric.Settings.Get("limit").MustString(), defaultSize))
358358
// TODO when hightlight is supported in quickwit
359359
// b.AddHighlight()
@@ -368,7 +368,7 @@ func processLogsQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defa
368368

369369
func processDocumentQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defaultTimeField string) {
370370
metric := q.Metrics[0]
371-
b.Sort(es.SortOrderDesc, defaultTimeField, "boolean")
371+
b.Sort(es.SortOrderDesc, defaultTimeField, "epoch_nanos_int")
372372
b.Sort(es.SortOrderDesc, "_doc", "")
373373
// Note: not supported in Quickwit
374374
// b.AddDocValueField(defaultTimeField)

src/configuration/DataLink.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const DataLink = (props: Props) => {
3030
const { value, onChange, onDelete, suggestions, className } = props;
3131
const styles = useStyles2(getStyles);
3232
const [showInternalLink, setShowInternalLink] = useInternalLink(value.datasourceUid);
33-
const [base64TraceId, setBase64TraceId] = useState(true)
3433
const labelWidth = 24
3534

3635
const handleChange = (field: keyof typeof value) => (event: React.ChangeEvent<HTMLInputElement>) => {
@@ -40,11 +39,6 @@ export const DataLink = (props: Props) => {
4039
});
4140
};
4241

43-
const handleBase64TraceId = (base64TraceId: boolean, config: DataLinkConfig) => {
44-
setBase64TraceId(base64TraceId)
45-
config = {...config, base64TraceId: base64TraceId };
46-
}
47-
4842
return (
4943
<div className={className}>
5044
<div className={styles.firstRow}>
@@ -73,15 +67,6 @@ export const DataLink = (props: Props) => {
7367
/>
7468
</div>
7569

76-
<div className={styles.row}>
77-
<InlineField label="Field encoded in base64?" labelWidth={labelWidth} tooltip="Must be at true if your trace ID is encoded in base64. This is the case for the `otel-traces-v0_6` index.">
78-
<InlineSwitch
79-
value={base64TraceId}
80-
onChange={() => handleBase64TraceId(!base64TraceId, value)}
81-
/>
82-
</InlineField>
83-
</div>
84-
8570
<InlineFieldRow>
8671
<div className={styles.urlField}>
8772
<InlineLabel htmlFor="elasticsearch-datasource-internal-link" width={labelWidth}>

src/datasource.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { catchError, mergeMap, map } from 'rxjs/operators';
44

55
import {
66
AbstractQuery,
7-
ArrayVector,
87
CoreApp,
98
DataFrame,
109
DataLink,
@@ -18,7 +17,6 @@ import {
1817
DataSourceWithQueryImportSupport,
1918
DataSourceWithSupplementaryQueriesSupport,
2019
dateTime,
21-
Field,
2220
FieldColorModeId,
2321
FieldType,
2422
getDefaultTimeRange,
@@ -850,47 +848,10 @@ function luceneEscape(value: string) {
850848
return value.replace(/([\!\*\+\-\=<>\s\&\|\(\)\[\]\{\}\^\~\?\:\\/"])/g, '\\$1');
851849
}
852850

853-
function base64ToHex(base64String: string) {
854-
const binaryString = window.atob(base64String);
855-
return Array.from(binaryString).map(char => {
856-
const byte = char.charCodeAt(0);
857-
return ('0' + byte.toString(16)).slice(-2);
858-
}).join('');
859-
}
860-
861851
export function enhanceDataFrameWithDataLinks(dataFrame: DataFrame, dataLinks: DataLinkConfig[]) {
862852
if (!dataLinks.length) {
863853
return;
864854
}
865-
let fields_to_fix_condition = (field: Field) => {
866-
return dataLinks.filter((dataLink) => dataLink.field === field.name && dataLink.base64TraceId).length === 1;
867-
};
868-
const fields_to_keep = dataFrame.fields.filter((field) => {
869-
return !fields_to_fix_condition(field)
870-
});
871-
let new_fields = dataFrame
872-
.fields
873-
.filter(fields_to_fix_condition)
874-
.map((field) => {
875-
let values = field.values.toArray().map((value) => {
876-
try {
877-
return base64ToHex(value);
878-
} catch (e) {
879-
console.warn("cannot convert value from base64 to hex", e);
880-
return value;
881-
};
882-
});
883-
return {
884-
...field,
885-
values: new ArrayVector(values),
886-
}
887-
});
888-
889-
if (new_fields.length === 0) {
890-
return;
891-
}
892-
893-
dataFrame.fields = [new_fields[0], ...fields_to_keep];
894855

895856
for (const field of dataFrame.fields) {
896857
const linksToApply = dataLinks.filter((dataLink) => dataLink.field === field.name);

0 commit comments

Comments
 (0)