Page MenuHomePhabricator

[jobs-api] Allow customizing time to request Loki logs for
Open, HighPublicFeature

Description

The Loki API requires a timeframe to request logs for. The current implementation hardcodes that timeframe as the last 1 hour, but that should be customizable by user, either as a relative time (last X hours?) or as absolute start/end times.

Related Objects

Event Timeline

From my usage of logs it would be useful (on the basis of a time window being explicitly required):

  1. --since N accepting something like [15m, 2h, 1d] (with a reasonable default, the current 1hour seems fine to keep)
  2. --since accepting an explicit date time e.g. `--since "2025-08-05 10:00:00" (format should be easy to type, with the timezone always UTC the same as the nodes)
  3. --until in the same context as 2.

Additional thoughts:

  • It would be nice if the API returned a warning if the time window falls outside of the configured retention time (if this is queryable via the loki api).
  • I think it would be reasonable for the API to deal with explicit dates, requiring since with an optional until and the CLI handles the conversion of human friendly strings [15m, 2h, 1d] to an absolute date.
  • In the context of a one-off job, the logical --since time is the job start time (this is not exposed via the jobs api directly, but can be parsed out of the long status). It would be reasonable to leave this up to the consumer for implementation.
dcaro raised the priority of this task from Medium to High.Sep 4 2025, 4:36 PM

This issue blocks the migration of my tools away from file logs. One hour is very low.