0
0
Fork 0
mirror of https://github.com/alerta/alerta.git synced 2025-02-19 11:43:52 +00:00

query for tags keys and values

This commit is contained in:
Nick Satterly 2014-01-31 15:00:11 +00:00
parent 3ea09176c7
commit adcf748201
2 changed files with 8 additions and 4 deletions
alerta

View file

@ -43,7 +43,7 @@ def parse_fields(request):
if request.args.get('repeat', None):
query['repeat'] = True if request.args.get('repeat', 'true') == 'true' else False
for field in [fields for fields in request.args if fields.rstrip('!') in ATTRIBUTES]:
for field in [fields for fields in request.args if fields.rstrip('!') in ATTRIBUTES or fields.startswith('tags')]:
if field in ['id', 'repeat']:
# Don't process queries on "id" or "repeat" twice
continue

View file

@ -15,7 +15,7 @@ from alerta.common import config
from alerta.common.utils import relative_date
from alerta.common.graphite import StatsD
Version = '2.0.23'
Version = '2.0.24'
LOG = logging.getLogger(__name__)
CONF = config.CONF
@ -101,10 +101,14 @@ class QueryClient(object):
query['origin!'] = CONF.not_origin
if CONF.tags:
query['tags'] = CONF.tags
for tag in CONF.tags:
key, value = tag.split('=')
query['tags.' + key] = value
if CONF.not_tags:
query['tags!'] = CONF.not_tags
for tag in CONF.not_tags:
key, value = tag.split('=')
query['tags.' + key + '!'] = value
if CONF.text:
query['text'] = CONF.text