Our Company
Hamilton Robson is a technology company, specialising in audio visual and software development.
We create unforgettable experiences and solutions for ultramodern spaces.
aggregateWindow
function was extremely limited, there is no mention of how to perform conditional statements or arithmetic operations on the values.from(bucket: "sensorData")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "exampleSensorData" and (r["_field"] == "temperature" or r["_field"] == "humidity"))
|> aggregateWindow(every: duration(v:(uint(v: v.timeRangeStop) - uint(v: v.timeRangeStart))/uint(v: 50)), fn:last)
|> yield(name: "mean")
You could also implement conditional statements, example:
|> aggregateWindow(every: if int(v: v.timeRangeStop) - int(v: v.timeRangeStart) < 60 * 60 * 1000000000 then 1m else 10m, fn: last, createEmpty: false)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
timeRangeStart
and timeRangeStop
are dynamic variables provided by Grafana itself.|> aggregateWindow(every: duration(v:(uint(v: v.timeRangeStop) - uint(v: v.timeRangeStart))/uint(v: 50)), fn:last)
every:
determines the size of each window based on the duration from the time range.50
as we wanted to scale down the points more, this can be modified to your liking.fn:last
is used to ensure we are selecting the last value within each window.|> yield(name: "mean")
Want to find out how the subject of this blog could help your business?
Our blended team of experts go over and above with our services to our customers, no matter what the challenge. Get in touch to find out how we can work together.
Hamilton Robson is a technology company, specialising in audio visual and software development.
We create unforgettable experiences and solutions for ultramodern spaces.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |