> To capture data for a specific duration, can you provide the URL query 
that takes time parameters, such as start and finish times. 

No I can't, because there is no feature for that - as the API documentation 
makes clear.

> Snapshot creates a snapshot of* all current data *into 
snapshots/<datetime>-<rand> under the TSDB's data directory

The snapshot for today includes all the earlier data, of course. So I 
presume you could take a snapshot then just delete all the blocks outside 
the time period of interest - but I've never tested it. You should be able 
to find the time ranges from the meta.json files:

root@prometheus:/var/lib/prometheus/data# cat 
01HS1YQS341WWGFYZSN0N8GPR1/meta.json
{
"ulid": "01HS1YQS341WWGFYZSN0N8GPR1",
"minTime": 1709942400000,
"maxTime": 1710525600000,
...

Because these blocks are rolled up, they may cover a fairly wide time 
interval. For example, the above block covers 583200000 milliseconds, which 
is 6.75 days.

# date --date @1709942400
Sat Mar  9 00:00:00 GMT 2024
# date --date @1710525600
Fri Mar 15 18:00:00 GMT 2024

However, you should note that you won't save much disk space by trimming 
snapshots in this way (if that's what you're trying to do). That's because 
the snapshots are hardlinks to shared, immutable files. The snapshots will 
only take extra space once the main tsdb has started to expire blocks, and 
the snapshot contains blocks older than that.

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/d2e4b4ac-3852-4bfb-bbb2-d1ca61773578n%40googlegroups.com.

Reply via email to