Select / Filter by Tags (API)

Hello at all…

My plan is to find a way to get all the Devices (and also gateways) and filter them by a tag. i want to use this for grafana - to select gateways and devices as variable by the tags.

for example: i have a tag “location” and i have the following devices:

device1= location=1
device2= location=1
device3= location=2

now i want a fast and easy way to get only the devices with tag “location” = 1

so far i did this with the grafana json datasource, wrote a python webservice which does GRPC Requests to the API of Chirpstack. For this, i need to get all devices (one API Request), get the device details (one API Request per Device) of each device and check if the tag is set. If so, my Python Webservice returns the device.

but as we have over 8000 devices, this takes to long.

is there a better way to do this?

i know i can also get it from the postgres database directly, with the command

SELECT name from device where tags->>‘location’ = ‘1’;

but i would prefere using the API. is there a solution for this?

1 Like

Currently there is not, but I’m open to review PRs to add this feature :slight_smile:

thanks for the response. unfortunately i can’t add a PR, as i am not able to write code :slight_smile:
anyway, i will use the way over the database with a read only user.

This topic was automatically closed after 90 days. New replies are no longer allowed.