Returning the value as the first field in an influxdb query?

Is it possible to return just a value, and not a time from influxdb?

I know influxdb is a Time Series Database, so it includes the time regardless, but the tool I’m using requires the first field displayed from the query to be a value, and not a time.

I’ve also tried switching the order of the arguments and time is still the first argument returned in the query.

select value,time FROM smart_threshold WHERE host =~ /proxmox/ AND instance = ‘sda’ AND type_instance=‘reallocated-sector-count’ limit 1

Result:

name: smart_threshold
time value


1512183206033040777 36

Would it be possible to return:

name: smart_threshold
value time


36 1512183206033040777

or just:

name: smart_threshold
value

36

instead?

I looked a little further into this, and you can’t actually assign a value to the threshold using a template variable.

@7yl4r proposes a solution of sorts, but I’m too new to Grafana to use it; I guess this isn’t the solution to the problem.

Hmm. I think that comment is definitely not what you are looking for.

Maybe you can pass CLI options from grafana somehow (I really don’t know)? If possible you could specify the format of the server response. You might be able to achieve that by adjusting configuration on the influx server too.

Is the “tool” you are using built to work with influxdb?

Or… taking a step back because this is looking like it may be an XY problem… what are you trying to do that requires this behavior?

I’m trying to obtain the threshold value from a hard drive’s S.M.A.R.T. attribute automatically. It does get sent by the client (collectd) to influx (and it does arrive, I can find it, query it, inside of influx). It’s kind of stupid though, because the threshold value doesn’t change to my knowlege; it should always be what the drive is reporting, and thus be a constant.

The results always come back like this (even if I don’t specify that I want the time field, or place it in a different position in my psuedo-sql-query):

time               somesmartattr_threshold
-------              -----------
XXXXXXXX   200

Inside of grafana, I can do a query to influx, to get the value of the threshold, but; grafana only picks up the time (the first field in the query, which is always the first field in the query according to influx),

So I can’t send the value returned to the threshold, and instead I have to set it manually, making the templates sort of useless.

However, it’s not just an influx problem; grafana I found out doesn’t allow you to set the threshold values within it either. I guess some of these technologies are a bit bleeding-edge.