Skip to content

Commit

Permalink
fix: prevent hidden queries from being used as supplementary queries (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
svennergr authored Jan 22, 2025
1 parent 1303006 commit 2769077
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/opensearchDatasource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,19 @@ describe('OpenSearchDatasource', function (this: any) {
timeField: '@timestamp',
});
});
it('does not return logs volume query for hidden log query', () => {
expect(
ds.getSupplementaryQuery(
{ type: SupplementaryQueryType.LogsVolume },
{
refId: 'A',
metrics: [{ type: 'logs', id: '1' }],
query: 'foo="bar"',
hide: true,
}
)
).toEqual(undefined);
});
});
});

Expand Down
4 changes: 4 additions & 0 deletions src/opensearchDatasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ export class OpenSearchDatasource
* @returns A supplemented ES query or undefined if unsupported.
*/
getSupplementaryQuery(options: SupplementaryQueryOptions, query: OpenSearchQuery): OpenSearchQuery | undefined {
if (query.hide) {
return undefined;
}

let isQuerySuitable = false;

switch (options.type) {
Expand Down

0 comments on commit 2769077

Please sign in to comment.