|
|
@ -252,15 +252,46 @@ func (sr *scrutinyRepository) GetSummary(ctx context.Context) (map[string]*model
|
|
|
|
// Get parser flux query result
|
|
|
|
// Get parser flux query result
|
|
|
|
//appConfig.GetString("web.influxdb.bucket")
|
|
|
|
//appConfig.GetString("web.influxdb.bucket")
|
|
|
|
queryStr := fmt.Sprintf(`
|
|
|
|
queryStr := fmt.Sprintf(`
|
|
|
|
import "influxdata/influxdb/schema"
|
|
|
|
import "influxdata/influxdb/schema"
|
|
|
|
from(bucket: "%s")
|
|
|
|
bucketBaseName = "%s"
|
|
|
|
|> range(start: -1y, stop: now())
|
|
|
|
|
|
|
|
|> filter(fn: (r) => r["_measurement"] == "smart" )
|
|
|
|
dailyData = from(bucket: bucketBaseName)
|
|
|
|
|> filter(fn: (r) => r["_field"] == "temp" or r["_field"] == "power_on_hours" or r["_field"] == "date")
|
|
|
|
|> range(start: -10y, stop: now())
|
|
|
|
|> last()
|
|
|
|
|> filter(fn: (r) => r["_measurement"] == "smart" )
|
|
|
|
|> schema.fieldsAsCols()
|
|
|
|
|> filter(fn: (r) => r["_field"] == "temp" or r["_field"] == "power_on_hours" or r["_field"] == "date")
|
|
|
|
|> group(columns: ["device_wwn"])
|
|
|
|
|> last()
|
|
|
|
|> yield(name: "last")
|
|
|
|
|> schema.fieldsAsCols()
|
|
|
|
|
|
|
|
|> group(columns: ["device_wwn"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
weeklyData = from(bucket: bucketBaseName + "_weekly")
|
|
|
|
|
|
|
|
|> range(start: -10y, stop: now())
|
|
|
|
|
|
|
|
|> filter(fn: (r) => r["_measurement"] == "smart" )
|
|
|
|
|
|
|
|
|> filter(fn: (r) => r["_field"] == "temp" or r["_field"] == "power_on_hours" or r["_field"] == "date")
|
|
|
|
|
|
|
|
|> last()
|
|
|
|
|
|
|
|
|> schema.fieldsAsCols()
|
|
|
|
|
|
|
|
|> group(columns: ["device_wwn"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monthlyData = from(bucket: bucketBaseName + "_monthly")
|
|
|
|
|
|
|
|
|> range(start: -10y, stop: now())
|
|
|
|
|
|
|
|
|> filter(fn: (r) => r["_measurement"] == "smart" )
|
|
|
|
|
|
|
|
|> filter(fn: (r) => r["_field"] == "temp" or r["_field"] == "power_on_hours" or r["_field"] == "date")
|
|
|
|
|
|
|
|
|> last()
|
|
|
|
|
|
|
|
|> schema.fieldsAsCols()
|
|
|
|
|
|
|
|
|> group(columns: ["device_wwn"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yearlyData = from(bucket: bucketBaseName + "_yearly")
|
|
|
|
|
|
|
|
|> range(start: -10y, stop: now())
|
|
|
|
|
|
|
|
|> filter(fn: (r) => r["_measurement"] == "smart" )
|
|
|
|
|
|
|
|
|> filter(fn: (r) => r["_field"] == "temp" or r["_field"] == "power_on_hours" or r["_field"] == "date")
|
|
|
|
|
|
|
|
|> last()
|
|
|
|
|
|
|
|
|> schema.fieldsAsCols()
|
|
|
|
|
|
|
|
|> group(columns: ["device_wwn"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
union(tables: [dailyData, weeklyData, monthlyData, yearlyData])
|
|
|
|
|
|
|
|
|> sort(columns: ["_time"], desc: false)
|
|
|
|
|
|
|
|
|> group(columns: ["device_wwn"])
|
|
|
|
|
|
|
|
|> last(column: "device_wwn")
|
|
|
|
|
|
|
|
|> yield(name: "last")
|
|
|
|
`,
|
|
|
|
`,
|
|
|
|
sr.appConfig.GetString("web.influxdb.bucket"),
|
|
|
|
sr.appConfig.GetString("web.influxdb.bucket"),
|
|
|
|
)
|
|
|
|
)
|
|
|
|