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

Error parsing logs: "ZeroDivisionError: float division by zero" #65

Closed
zequeira opened this issue Jul 15, 2022 · 4 comments
Closed

Error parsing logs: "ZeroDivisionError: float division by zero" #65

zequeira opened this issue Jul 15, 2022 · 4 comments
Assignees

Comments

@zequeira
Copy link

zequeira commented Jul 15, 2022

Hi,
I'm using Drain3 to parse some logs and sometimes I get the following error:

Traceback (most recent call last):
File "C:+\envs+\lib\site-packages\IPython\core\interactiveshell.py", line 3369, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 13, in <cell line: 11>
result = template_miner.add_log_message(msg)
File "C:+\envs+\lib\site-packages\drain3\template_miner.py", line 146, in add_log_message
self.profiler.report(self.config.profiling_report_sec)
File "C:+\envs+\lib\site-packages\drain3\simple_profiler.py", line 112, in report
text = os.linesep.join(lines)
File "C:+\envs+\lib\site-packages\drain3\simple_profiler.py", line 111, in
lines = map(lambda it: it.to_string(enclosing_time_sec, include_batch_rates), sorted_sections)
File "C:+\envs+\lib\site-packages\drain3\simple_profiler.py", line 135, in to_string
samples_per_sec = f"{self.sample_count / self.total_time_sec: 15,.2f}"
ZeroDivisionError: float division by zero

any help would be appreciated.

@zequeira zequeira changed the title ZeroDivisionError: float division by zero Error parsing logs: "ZeroDivisionError: float division by zero" Jul 15, 2022
@Superskyyy
Copy link
Collaborator

I guess the code didn't start and enclose the last section, which I think is probably this

template_miner.profiler.start_section('print_tree')
template_miner.drain.print_tree()
template_miner.profiler.end_section('print_tree')

template_miner.profiler.report(period_sec=0)

So the profiler took the wrong section total which is already done profiling.

Can you confirm please? @davidohana

@davidohana
Copy link
Collaborator

davidohana commented Jul 17, 2022

@zequeira This seems like a bug in the profiler, when trying to measure the time of a very short operation, the total time is 0. Fixed in latest version 0.9.11 (hopefully), please check.
BTW you can always disable profiling in the configuration of Drain3, I think that the default should be disabled.

@davidohana
Copy link
Collaborator

@Superskyyy I don't see any profiling of print_tree in the codebase, can you specify the exact lines?

@davidohana davidohana self-assigned this Jul 17, 2022
@Superskyyy
Copy link
Collaborator

This is fixed and closing.

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