opened
drmclean
username_0
Filter by tags appears to be broken?
issue
created
drmclean
username_0
[(u'current', None)] 


According to the docs `rs.keys()` ought to return a tuple with (serie_name, tags) but it seems to think that there are no tags despite happily querying tags from the db.
comment
closed
drmclean
username_0
issue
reopened
drmclean
username_0
True
Filter by tags appears to be broken?
issue
created
aviau
username_1
```

It should work when using "group by", I cannot break that.

What I am getting out of this is that there are no bugs in influxdb-python. To get things working like you want, all you have to do is request the right tags by using the "GROUP BY" keyword.

So, there are two types of tags:
 - top-level tags that are returned when using group-by. Filtering works with these.

 - column-level tags. Filtering does not work with these, as they are new.

However, it looks like one would want to filter by the tags that are now included in the columns. What do you think?

Once again, I think that this discussion should be on GitHub so that everyone can see, I will post this here: 
 - https://github.com/influxdb/influxdb-python/issues/251

thank you for your work David

Best regards,

--
Alexandre Viau
alexandre@alexandreviau.net
```
comment
created
drmclean
username_0
Hi Alex, 

The above makes sense although it should be noted that the "bug" is now just that the documentation is no longer accurate. In the current docs the following: 

`rs = cli.query("SELECT * from cpu")`
`cpu_influxdb_com_points = list(rs.get_points(tags={"host_name": "influxdb.com"}))`

Is suggested as working code but due to the API changes it runs without error but no longer filters correctly, something which is a bit confusing for the first-time user!

I think its possible to implement filtering by tags included in the columns but I'm not sure how to do so in a way which maintains the previously functionality on group by queries but doesn't break other parts of the library. I'll remove my pull request as it neither solves the problems correctly nor passes the build!
comment
created
aviau
username_1
I'll think about this, we should use this issue to discuss how to do that.
comment
created
3fr61n
username_2
[{u'value_str': None, u'time': u'2016-03-02T11:44:23.995058481Z', u'product-model': u'mx480', u'value': 0, u'version': u'20150617.306001_builder_stable_10', u'key': None, u'delta': 0, u'device': u'PE4-tf-mx480-3-re0', u'kpi': u're.memory.rpd-CPU', u'delta_str': None}]
comment
created
anoopkhandelwal
username_3
Hi,
I am also facing the same issue.I need to filter out data by using 3-4 tags.
Any other alternative solution/wrapper function which we can use to achieve our objective?
comment
created
anoopkhandelwal
username_3
Hi,
I wrote a wrapper function -
def filter_fun(data, key, allowed):
    return filter(lambda x: key in x and x[key] in allowed, data)

def filter_data(data, fitered_tags):
    response_list = data
    for tag_key, tag_value in fitered_tags.iteritems():
        response_list = filter_fun(response_list, tag_key, tag_value)
    return response_list

now all we need to filter is to pass the data_list into filter_data function and pass tags(dict) so that it will filter all the data and return you list of dict elements.
e.g
data_list = filter_data(data_list, fitered_tags={'key_1': value1, 'key_2': 'value2'})
Since the function get_points also filtered after getting the data i.e. it is not executed on the query level,so performance wise it is same as get_points function.
Let me know,if we can make it more correct.
comment
created
Chentongxuedefanhua
username_4
this bug has been resolved now?
comment
closed
xginn8
username_5
issue
created
xginn8
username_5
This bug should be fixed in the latest release -- if not, we can revisit.
comment