Skip to content

Commit b56d712

Browse files
committed
Issue #12: implement DataSourceWithLogsContextSupport interface
1 parent 5978dc6 commit b56d712

File tree

8 files changed

+187
-117
lines changed

8 files changed

+187
-117
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@ You need:
1414

1515
### Building
1616

17+
### All the stack
18+
19+
```shell
20+
./build_and_start.sh
21+
```
22+
1723
#### Frontend
1824

1925
```bash
20-
$ yarn install
21-
$ yarn build
26+
$ npm install
27+
$ npm run build
2228
```
2329

24-
When developing the front, use `yarn dev`.
30+
When developing the front, use `npm run dev`.
2531

2632
#### Backend
2733

@@ -49,7 +55,6 @@ $ npm run test
4955
$ go test -v ./pkg/...
5056
```
5157

52-
5358
## Release
5459

5560
TODO

build_and_start.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
npm install
4+
npm run build
5+
mage -v
6+
docker-compose up --build --force-recreate

docker-compose.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ services:
1212
volumes:
1313
- ./:/var/lib/grafana/plugins/grafana-quickwit-datasource
1414
- ./provisioning:/etc/grafana/provisioning
15-
# - ./grafana/storage:/var/lib/grafana
16-
# - ./grafana/grafana.ini:/etc/grafana/grafana.ini
15+
- gquickwit:/var/lib/grafana
1716
extra_hosts:
1817
- "host.docker.internal:host-gateway"
18+
19+
volumes:
20+
gquickwit:

package-lock.json

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

pkg/quickwit/client/search_request.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ func (b *SearchRequestBuilder) Sort(order SortOrder, field string, unmappedType
101101
return b
102102
}
103103

104-
func (b *SearchRequestBuilder) AddSearchAfter(value interface{}) *SearchRequestBuilder {
104+
func (b *SearchRequestBuilder) AddSearchAfter(value any) *SearchRequestBuilder {
105105
if b.customProps["search_after"] == nil {
106-
b.customProps["search_after"] = []interface{}{value}
106+
b.customProps["search_after"] = []any{value}
107107
} else {
108-
b.customProps["search_after"] = append(b.customProps["search_after"].([]interface{}), value)
108+
b.customProps["search_after"] = append(b.customProps["search_after"].([]any), value)
109109
}
110110

111111
return b

pkg/quickwit/data_query.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,13 @@ func processLogsQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defa
340340
b.Size(stringToIntWithDefaultValue(metric.Settings.Get("limit").MustString(), defaultSize))
341341
// TODO when hightlight is supported in quickwit
342342
// b.AddHighlight()
343+
344+
// This is currently used only for log context query to get
345+
// log lines before and after the selected log line
346+
searchAfter := metric.Settings.Get("searchAfter").MustArray()
347+
for _, value := range searchAfter {
348+
b.AddSearchAfter(value)
349+
}
343350
}
344351

345352
func processDocumentQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defaultTimeField string) {

src/IntervalMap.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { DurationUnit } from '@grafana/data';
2+
import { Interval } from './types';
3+
4+
type IntervalMap = Record<
5+
Interval,
6+
{
7+
startOf: DurationUnit;
8+
amount: DurationUnit;
9+
}
10+
>;
11+
12+
export const intervalMap: IntervalMap = {
13+
Hourly: { startOf: 'hour', amount: 'hours' },
14+
Daily: { startOf: 'day', amount: 'days' },
15+
Weekly: { startOf: 'isoWeek', amount: 'weeks' },
16+
Monthly: { startOf: 'month', amount: 'months' },
17+
Yearly: { startOf: 'year', amount: 'years' },
18+
};

0 commit comments

Comments
 (0)