[TSVB] Series Filter (#14696)

- Add filter to timeseries config
- Add filter to global series
- Add test for series filter
This commit is contained in:
Chris Cowan 2017-11-02 11:09:03 -07:00 committed by GitHub
parent a5f0f03f54
commit 53748044b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 0 deletions

View file

@ -60,6 +60,18 @@ export const SeriesConfig = props => {
disabled={!model.override_index_pattern}
/>
</div>
<div className="vis_editor__series_config-row">
<label className="vis_editor__label" htmlFor={htmlId('series_filter')}>
Filter
</label>
<input
id={htmlId('series_filter')}
className="vis_editor__input-grows"
type="text"
onChange={handleTextChange('filter')}
value={model.filter}
/>
</div>
</div>
</div>
);

View file

@ -277,6 +277,18 @@ function TimeseriesConfig(props) {
with-interval={true}
/>
</div>
<div className="vis_editor__series_config-row">
<label className="vis_editor__label" htmlFor={htmlId('series_filter')}>
Filter
</label>
<input
id={htmlId('series_filter')}
className="vis_editor__input-grows"
type="text"
onChange={handleTextChange('filter')}
value={model.filter}
/>
</div>
</div>
</div>
);

View file

@ -124,6 +124,35 @@ describe('query(req, panel, series)', () => {
});
});
it('returns doc with series filter', () => {
series.filter = 'host:web-server';
const next = doc => doc;
const doc = query(req, panel, series)(next)({});
expect(doc).to.eql({
size: 0,
query: {
bool: {
must: [
{
range: {
timestamp: {
gte: 1483228800000,
lte: 1483232400000,
format: 'epoch_millis'
}
}
},
{
query_string: {
query: series.filter,
analyze_wildcard: true
}
}
]
}
}
});
});
it('returns doc with panel filter and global', () => {
req.payload.filters = [
{

View file

@ -37,6 +37,15 @@ export default function query(req, panel, series) {
});
}
if (series.filter) {
doc.query.bool.must.push({
query_string: {
query: series.filter,
analyze_wildcard: true
}
});
}
return next(doc);
};