TICKscript numeric values are either floats or integers. The count
operation always returns an integer. As a result the eval is doing integer
division. Use `float()` to convert the value to floats and do the correct
division operation.
|eval(lambda: float("success.count") / float("total.count"))
On Sunday, November 13, 2016 at 10:50:41 PM UTC-7, [email protected] wrote:
>
> I have a join that I'm trying to calculate the pass rate.
>
> I'm counting from the same table. My problem is that the value that it
> calculate is always 1. If I run the queries separately the value should be
> some decimal place number like .31
>
> script
> ---------------------------------------------------------
> var myperiod=60m
> var mytime=60m
> var myevery=1m
>
> var success = batch
> |query('''SELECT count(elapsedTime) FROM "metrics"."autogen"."tasks"
> where "status" = 'FINISHED' ''')
> .period(myperiod)
> .every(myevery)
> .groupBy(time(mytime), *)
> .fill(0)
>
> var total = batch
> |query('''SELECT count(elapsedTime) FROM "metrics"."autogen"."tasks"
> where ("status"='FINISHED' or "status"='ERROR' ) ''')
> .period(myperiod)
> .every(myevery)
> .groupBy(time(mytime), *)
> .fill(0)
>
>
> // Join success and total
> success
> |join(total)
> .as('success', 'total')
> .tolerance(1m)
> //Calculate percentage
> |where (lambda: "total.count" > 0)
> |eval(lambda: "success.count" / ("total.count"))
> // Give the resulting field a name
> .as('value')
> |influxDBOut()
> .database('metrics')
> .measurement('backupSuccessPercent')
>
>
> ---------------------------------------------------------
>
>
--
Remember to include the version number!
---
You received this message because you are subscribed to the Google Groups
"InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit
https://groups.google.com/d/msgid/influxdb/2aafa56f-3415-4998-a9c0-5c1812d5cba7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.