Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date intervals in Loki queries too wide? #10

Open
zarembat opened this issue Jun 26, 2023 · 2 comments
Open

Date intervals in Loki queries too wide? #10

zarembat opened this issue Jun 26, 2023 · 2 comments
Assignees

Comments

@zarembat
Copy link

zarembat commented Jun 26, 2023

Our logs are taking quite a lot of time to load from Loki. I suppose it's caused by a very wide time range in which they are searched for in Loki:

start = ti.start_date - timedelta(days=15)
#if the task is running or queued, the task will not have end_date, in that
# case, we will use a resonable internal of 5 days

end_date = ti.end_date  or ti.start_date + timedelta(days=5)

end = end_date + timedelta(hours=1)

Why do we need to search for logs up to 15 days before task's start_date? Shouldn't it be just the start_date?

Also it would be nice to be able to parametrize the end_date for non-finished tasks (currently hard-coded to 5 days but that may be too much depending on the use case).

@snjypl snjypl self-assigned this Jul 9, 2023
@snjypl
Copy link
Owner

snjypl commented Jul 23, 2023

@zarembat everytime the task is retried the start_date will get updated to the current time. so there is no way to know the time range for the older tries. so we query for the last 15 days.

if we retry the task after say 30 days. then it won't be possible to get the logs for the older task tries.

i agree that we can make the range offset configurable.

please feel free to open a PR with the changes or i will make the changes when i get a chance.

@ckljohn
Copy link

ckljohn commented Dec 21, 2023

I found that you can change Loki setting split_queries_by_interval. The default value is 15m which means every query sends to loki splits into 15 * 24 * 4 (1440) sub queries. I changed to 24h in my environment and it helps a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants