Skip to content

Commit

Permalink
Issue #12: implement DataSourceWithLogsContextSupport interface
Browse files Browse the repository at this point in the history
  • Loading branch information
idrissneumann committed Nov 22, 2023
1 parent 5978dc6 commit b56d712
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 117 deletions.
13 changes: 9 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ You need:

### Building

### All the stack

```shell
./build_and_start.sh
```

#### Frontend

```bash
$ yarn install
$ yarn build
$ npm install
$ npm run build
```

When developing the front, use `yarn dev`.
When developing the front, use `npm run dev`.

#### Backend

Expand Down Expand Up @@ -49,7 +55,6 @@ $ npm run test
$ go test -v ./pkg/...
```


## Release

TODO
6 changes: 6 additions & 0 deletions build_and_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

npm install
npm run build
mage -v
docker-compose up --build --force-recreate
6 changes: 4 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ services:
volumes:
- ./:/var/lib/grafana/plugins/grafana-quickwit-datasource
- ./provisioning:/etc/grafana/provisioning
# - ./grafana/storage:/var/lib/grafana
# - ./grafana/grafana.ini:/etc/grafana/grafana.ini
- gquickwit:/var/lib/grafana
extra_hosts:
- "host.docker.internal:host-gateway"

volumes:
gquickwit:
124 changes: 22 additions & 102 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/quickwit/client/search_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ func (b *SearchRequestBuilder) Sort(order SortOrder, field string, unmappedType
return b
}

func (b *SearchRequestBuilder) AddSearchAfter(value interface{}) *SearchRequestBuilder {
func (b *SearchRequestBuilder) AddSearchAfter(value any) *SearchRequestBuilder {
if b.customProps["search_after"] == nil {
b.customProps["search_after"] = []interface{}{value}
b.customProps["search_after"] = []any{value}
} else {
b.customProps["search_after"] = append(b.customProps["search_after"].([]interface{}), value)
b.customProps["search_after"] = append(b.customProps["search_after"].([]any), value)
}

return b
Expand Down
7 changes: 7 additions & 0 deletions pkg/quickwit/data_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@ func processLogsQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defa
b.Size(stringToIntWithDefaultValue(metric.Settings.Get("limit").MustString(), defaultSize))
// TODO when hightlight is supported in quickwit
// b.AddHighlight()

// This is currently used only for log context query to get
// log lines before and after the selected log line
searchAfter := metric.Settings.Get("searchAfter").MustArray()
for _, value := range searchAfter {
b.AddSearchAfter(value)
}
}

func processDocumentQuery(q *Query, b *es.SearchRequestBuilder, from, to int64, defaultTimeField string) {
Expand Down
18 changes: 18 additions & 0 deletions src/IntervalMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { DurationUnit } from '@grafana/data';
import { Interval } from './types';

type IntervalMap = Record<
Interval,
{
startOf: DurationUnit;
amount: DurationUnit;
}
>;

export const intervalMap: IntervalMap = {
Hourly: { startOf: 'hour', amount: 'hours' },
Daily: { startOf: 'day', amount: 'days' },
Weekly: { startOf: 'isoWeek', amount: 'weeks' },
Monthly: { startOf: 'month', amount: 'months' },
Yearly: { startOf: 'year', amount: 'years' },
};
Loading

0 comments on commit b56d712

Please sign in to comment.