I’ve got influx entries where the record has a time (and end) but also a duration.
I’d like to plot this on a graph where I have a representation for the length of time as calculated from time (start) for duration.
Is there a function where if a record started at 13:00 for 300 seconds, that would create a 1, or other value from 13:00 to 13:05. Or is there some other way I could represent it.
I have a number of hosts where I would like to see if the process (it’s backups) are overlapping. And to do this I need to represent this record as a graph plot to see overlapping.
Hello @psyciknz,
I’ll admit I’m a little confused by this sentence:
Is there a function where if a record started at 13:00 for 300 seconds, that would create a 1, or other value from 13:00 to 13:05.
Mostly the latter half. Could you provide me with some dummy sample data and the expected outcome?
from(bucket: "example-bucket")
|> range(start: -5m)
|> filter(fn: (r) => r._measurement == "my measurement" and r._field == "duration")
|> map(
fn: (r) => ({r with
label: if r._time == 13:00 and r.duration == 300.0 then
"1"
else
"0",
}),
)
This is a pseudo example because you’d either have to a) stick actual timestamp (which only help you identify one point which isn’t very helpful or b) use the one of the methods here:
To select for particular data based on the timestamp.
Some dummy input and expected output will allow me to help you better though.
Hi, thanks for the reply so here is the data I am storing:
> select * from backup_usage where backuptags = 'Documents' and time > now() - 1d
name: backup_usage
time backuptags end host short_id timetaken
---- ---------- --- ---- -------- ---------
1664146860123013000 Documents 2022-09-26T12:46:13.000000+1300 Data 4edc0a2a 2712
1664168460116608000 Documents 2022-09-26T18:15:33.000000+1300 Data 931bdd30 872
1664190060118520000 Documents 2022-09-27T00:19:13.000000+1300 Data 3e52b5ca 1092
1664211660112786000 Documents 2022-09-27T06:15:38.000000+1300 Data cc62eab5 877
These show backups on one host (names Data) where they start at Time and run for a length of time (timetaken). You can also see it by the End column which is a string.
Ideally I would like to be able to show (in grafana) one of these backups as a time series eg: