@oneofthemany Flux will only return tag values that exist in the queried data set, so it can’t guarantee that the count of mac addresses will always be the same because there may be a different number of mac addresses depending on the queried time range. With that said, I’d recommend using schema.tagValues() to get values of the mac_address tag.
One thing to note here is that schema.tagValues does not accept a stop parameter, so the right time boundary is always now(). However, you can create your own custom function to accept the stop time. Here’s the source definition for schema.tagValues: flux/schema.flux at master · influxdata/flux · GitHub
Apologies for the late reply, as we have been running into several difficulties trying to auto generate the MAC addresses based on the values caught within the DB.
The easiest was for us to create a CSV variable and add that variable to the query.
It is just a shame that you can’t have a multiple MAC query within the drop down and assign each of those the "or function like you do in the script query builder:
Are you looking to have multiple option with the v.function drop down in the UI, as I would have thought that just appending the “or” function when more than one item is selected would be accomplishable.
@oneofthemany You could instead extract the list of MAC addresses as an array and use contains() to see if it exists in the array. Also, sidenote, since you originally created this thread, the stop parameter was added to schema.tagValues(). You just need to use InfluxDB 2.2 or newer.
If multi-select variables were available, it wouldn’t extend the query with OR statements in a filter() call. The way that the current dashboard variable implementation works is that each variable represents a simple assignment (x = y). The way a multi-select variable would works is that it would return an array of selected values (x = [y, z]). So you would still need to use contains() to check if a value is in the “selected” array.
For example, if you had a multi-select variable named mac_addresses, that variable would return an array of selected mac addresses and would be stored in the v record. To reference the array, you’d use v.mac_addresses:
I was using the tagValues() function before I saw your post and figured out the reason the stop time range wasn’t working for me, so first of all, thanks.
I need to retrieve the “_time” value for each distinct tag in my database, but I cannot find the correct solution. Can you help me?
@maguri With the nature of tags in the InfluxDB data structure, I would expect them to repeat themselves. Do you have tags that you expect to be unique and unrepeated? If so, that data may be better suited to be stored as a field.
The main purpose of this tag is to filter all measurements received with the specified tag_value in a query. I believe it is currently effective as it is.
This tag serves as a production batch ID, providing a reference ID for each job or batch.
I have been considering that perhaps what I need to do is execute a query over measurements and retrieve the first measurement for each distinct or unique tag.