Hello,
I am new to InfluxDB 2.0, I have collected disk used/free data from my linux and i am trying to get estimation of days left for the disk to be full.
i have created this query to get daily growth of my disk and get the max value for the last seven days:
growth = from(bucket: "virtual_machines")
|> range(start: -7d)
|> filter(fn: (r) => r["_measurement"] == "disk")
|> filter(fn: (r) => r["_field"] == "used")
|> filter(fn: (r) => r["host"] == "app_v11")
|> filter(fn: (r) => r["path"] == "/")
|> aggregateWindow(every: 1d, fn: last, createEmpty: false)
|> drop(columns: ["_measurement", "_field", "_start", "_stop", "_time", "fstype","mode","device"])
|> difference()
|> max()
|> toFloat()
|> yield(name: "grow")
then next is getting the last saved total/used/free disk using this query:
data = from(bucket: "virtual_machines")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "disk")
|> filter(fn: (r) => r["host"] == "app_v11")
|> filter(fn: (r) => r["path"] == "/")
|> filter(fn: (r) => r["_field"] == "used" or r["_field"] == "total" or r["_field"] == "free")
|> last()
|> toFloat()
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
|> drop(columns: ["_measurement", "_field", "_start", "_stop", "_time", "fstype","mode","device"])
|> group(columns: ["_measurement"], mode:"by")
|> yield(name:"data")
both result seems correct when i checked to my linux server.
but when i tried to use growth value (first table) to left join into data table, the result is empty, the query i use is:
join.left(
left: data,
right: growth,
on: (l, r) => (l.host == r.host and l.path == r.path),
as: (l, r) => ({l with growth_value: r._value}),
)
|> yield(name:"data")
result for all three query:
please help me for the correct query for this, and what is the query to calculate free and growth_value measurement to get estimation days left for disk to be full. i think it should be free / growth_value is good enough to get days left. how to translate this to flux query
Thank you!