Skip to content

Commit ea65674

Browse files
committed
Fix health check
1 parent 0db2cc8 commit ea65674

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

pkg/trino/models/settings.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ func (s *TrinoDatasourceSettings) Load(config backend.DataSourceInstanceSettings
2222
if len(opts.Headers) != 0 {
2323
return errors.New("Custom headers are not supported and must be not set")
2424
}
25-
if len(opts.CustomOptions) != 0 {
26-
return errors.New("Custom options are not supported and must be not set")
27-
}
2825
log.DefaultLogger.Info("Loading Trino data source settings")
2926
s.URL, err = url.Parse(config.URL)
3027
if err != nil {
3128
return err
3229
}
33-
if opts.BasicAuth.Password != "" {
34-
s.URL.User = url.UserPassword(opts.BasicAuth.User, opts.BasicAuth.Password)
30+
if opts.BasicAuth != nil {
31+
if opts.BasicAuth.Password != "" {
32+
s.URL.User = url.UserPassword(opts.BasicAuth.User, opts.BasicAuth.Password)
33+
} else {
34+
s.URL.User = url.User(opts.BasicAuth.User)
35+
}
3536
} else {
36-
s.URL.User = url.User(opts.BasicAuth.User)
37+
s.URL.User = url.User("grafana")
3738
}
3839
s.Opts = opts
3940
return nil

src/datasource.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ export class DataSource extends DataSourceWithBackend<TrinoQuery, TrinoDataSourc
1515
.fetch({
1616
url: '/api/ds/query',
1717
method: 'POST',
18+
requestId: 'A',
1819
data: {
1920
from: '5m',
2021
to: 'now',
2122
queries: [
2223
{
2324
refId: 'A',
25+
key: 'A',
2426
intervalMs: 1,
2527
maxDataPoints: 1,
2628
datasource: this.getRef(),
27-
rawSql: 'SELECT 1',
28-
format: 'table',
29+
rawSQL: 'SELECT 1',
30+
format: 0,
2931
},
3032
],
3133
},

src/types.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@ export const SelectableFormatOptions: Array<SelectableValue<FormatOptions>> = [
2727

2828
export const defaultQuery: Partial<TrinoQuery> = {
2929
rawSQL: `SELECT
30-
$__timeEpoch(<time_column>),
31-
<value column> as value,
32-
<series name column> as metric
30+
$__timeGroup(time_column, '1h'),
31+
value_column as value,
32+
series_column as metric
3333
FROM
34-
<catalog name>.<schema name>.<table name>
34+
catalog_name.schema_name.table_name
3535
WHERE
3636
$__timeFilter(time_column)
37+
GROUP BY
38+
1, 3
3739
ORDER BY
38-
<time_column> ASC`,
39-
format: FormatOptions.Table,
40+
1
41+
`,
42+
format: FormatOptions.TimeSeries,
4043
};
4144

4245
/**

0 commit comments

Comments
 (0)