I have a data set of devices and the number of (un)instalmments of my app that are done daily.
A sample data would be:
time | device_name | daily_installs | daily_uninstall
t1 | device1 | 0 | 1
t1 | device2 | 2 | 0
t2 | device2 | 2 | 0
t2 | device3 | 12 | 0
I can group them by device_name and get the total of install that I have by month (or any other range) for example.
But the amount of device is huge, hence I would like to filter only the top 10.
How can I achieve that using InfluxDB?
DISTINCT() returns the unique values of a single field. The field values are meant to be the actual data you're interested in. Tag values are metadata: data about the data. Most functions in database systems operate on the data or the metadata, but rarely on both.
To perform an InfluxQL query, send a GET request to the /query endpoint, set the URL parameter db as the target database, and set the URL parameter q as your query. You can also use a POST request by sending the same parameters either as URL parameters or as part of the body with application/x-www-form-urlencoded .
InfluxQL is an SQL-like query language for interacting with data in InfluxDB. The following sections detail InfluxQL's SELECT statement and useful query syntax for exploring your data.
Fields are a necessary entity of building the database which are “non-indexed” hence they get scanned for all values when queried. Tags on the other hand are not a necessary but indexed entities that make the queries more performant.
Version 1.3.4
SELECT top(monthly_uninstalls,device_name,10)
FROM (SELECT count(daily_uninstall) as monthly_uninstall
FROM mymeasurement
WHERE time > now() - 4w
GROUP BY device_name)
Please note that the syntax is "top("field_name", "tag", "topN") from ...."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With