Filtering by Tag

I’m unable to successfully filter devices by tag.

The following returns an empty dictionary;

atag = nr.inventory.filter(F(tags__name=“a_tag”))

This is an example of the ‘tags’ attribute from a device;

[{‘id’: 4, ‘url’: ‘’, ‘name’: ‘a_tag’, ‘slug’: ‘a_tag’, ‘color’: ‘ffe4e1’}]

It seems like filtering on tags works differently than platform, device_type, or site. What am I missing here?

1 Like

Bump for this…

Curious if anyone else has been able to successfully return a list of devices that share a tag.

The data returned from items() for tags is a list, which is populated by a dictionary for each tag and it’s attributes. For every other type of data that I’ve tried to parse, a dictionary is used to store the data.

I understand why this is the case for multiple tags, but I don’t know how the filter function supports this.

('tags', []), ('custom_fields', {}),('config_context', {})

I might try duplicating my “tag” strategy in custom fields if I can’t sort this out.