Skip to content

Commit

Permalink
Add loki start/end params
Browse files Browse the repository at this point in the history
  • Loading branch information
totycro committed Dec 3, 2024
1 parent 1f2b1a0 commit 7556cff
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pygeoapi_kubernetes_papermill/log_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from http import HTTPStatus
import logging
import itertools
import time

import requests

Expand Down Expand Up @@ -58,10 +59,16 @@ def get_job_logs(job_id):
return content, status, headers
else:
namespace = api_.manager.namespace

# 21 days in ns (default limit in loki is 30 days)
query_time_range = 21 * 24 * 60 * 60 * 1_000_000_000

response = requests.get(
log_query_endpoint,
params={
"query": f'{{job="{namespace}/{job_id}"}}',
"start": time.time_ns() - query_time_range,
"end": time.time_ns(),
},
)
response.raise_for_status()
Expand Down

0 comments on commit 7556cff

Please sign in to comment.