Skip to content

Commit f49b750

Browse files
committed
Fixes #11232 - Add option for panel and global filters to annotations for TSVB (#11260)
* Fixes #11232 - Add option for panel and global filters * Changing logic to use ignore instead of include
1 parent ab42b27 commit f49b750

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/core_plugins/metrics/public/components/annotations_editor.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import ColorPicker from './color_picker';
66
import FieldSelect from './aggs/field_select';
77
import uuid from 'node-uuid';
88
import IconSelect from './icon_select';
9+
import YesNo from './yes_no';
910

1011
function newAnnotation() {
1112
return {
1213
id: uuid.v1(),
1314
color: '#F00',
1415
index_pattern: '*',
1516
time_field: '@timestamp',
16-
icon: 'fa-tag'
17+
icon: 'fa-tag',
18+
ignore_global_filters: 1,
19+
ignore_panel_filters: 1
1720
};
1821
}
1922

@@ -82,6 +85,22 @@ class AnnotationsEditor extends Component {
8285
onChange={this.handleChange(model, 'query_string')}
8386
value={model.query_string} />
8487
</div>
88+
<div className="vis_editor__row-item-small">
89+
<div className="vis_editor__label">Ignore Global Filters</div>
90+
<YesNo
91+
value={model.ignore_global_filters}
92+
name="ignore_global_filters"
93+
onChange={handleChange}/>
94+
95+
</div>
96+
<div className="vis_editor__row-item-small">
97+
<div className="vis_editor__label">Ignore Panel Filters</div>
98+
<YesNo
99+
value={model.ignore_panel_filters}
100+
name="ignore_panel_filters"
101+
onChange={handleChange}/>
102+
103+
</div>
85104
</div>
86105
<div className="vis_editor__row">
87106
<div className="vis_editor__row-item">

src/core_plugins/metrics/public/less/editor.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@
416416
margin-bottom: 4px;
417417
}
418418
}
419+
.vis_editor__row-item-small {
420+
.vis_editor__row-item;
421+
flex-grow: 0;
422+
}
419423
}
420424

421425
.vis_editor__icon_select-option {

src/core_plugins/metrics/server/lib/vis_data/request_processors/annotations/query.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ export default function query(req, panel, annotation) {
3535
});
3636
}
3737

38+
const globalFilters = req.payload.filters;
39+
if (!annotation.ignore_global_filters) {
40+
doc.query.bool.must = doc.query.bool.must.concat(globalFilters);
41+
}
42+
43+
if (!annotation.ignore_panel_filters && panel.filter) {
44+
doc.query.bool.must.push({
45+
query_string: {
46+
query: panel.filter,
47+
analyze_wildcard: true
48+
}
49+
});
50+
}
51+
3852
if (annotation.fields) {
3953
const fields = annotation.fields.split(/[,\s]+/) || [];
4054
fields.forEach(field => {

0 commit comments

Comments
 (0)