{ "cells": [ { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "import re\n", "import pandas as pd\n", "\n", "# Function to extract log entries with specified pattern and check for 429 errors\n", "def extract_429_error_log_entries(file_path):\n", " with open(file_path, 'r') as file:\n", " log_entries = file.readlines()\n", " \n", " log_data = []\n", " pattern = re.compile(r'(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3}) - ERROR - tool_handler Tool call failed:')\n", " \n", " for i in range(len(log_entries)):\n", " entry = log_entries[i]\n", " match = pattern.match(entry)\n", " if match:\n", " # Check within the next 100 lines for a 429 error\n", " for j in range(i + 1, min(i + 100, len(log_entries))):\n", " if '

429

' in log_entries[j]:\n", " next_timestamp_match = re.match(r'\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3}', log_entries[j + 1]) if j + 1 < len(log_entries) else None\n", " next_timestamp = next_timestamp_match.group() if next_timestamp_match else None\n", " log_data.append({\n", " 'Timestamp': match.group(1),\n", " 'Log Entry': entry.strip(),\n", " '429 Error Entry': log_entries[j].strip(),\n", " })\n", " break\n", " \n", " return pd.DataFrame(log_data)\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# Extract the log entries matching the specified pattern and containing 429 errors\n", "file_path = 'paste_v2.txt'\n", "error_429_log_df = extract_429_error_log_entries(file_path)\n" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TimestampLog Entry429 Error Entry
02024-06-25 06:39:01,2612024-06-25 06:39:01,261 - ERROR - tool_handler...<h1>429</h1>
12024-06-25 06:39:03,9682024-06-25 06:39:03,968 - ERROR - tool_handler...<h1>429</h1>
22024-06-25 06:39:06,9042024-06-25 06:39:06,904 - ERROR - tool_handler...<h1>429</h1>
32024-06-25 07:52:06,8302024-06-25 07:52:06,830 - ERROR - tool_handler...<h1>429</h1>
42024-06-25 07:52:09,6712024-06-25 07:52:09,671 - ERROR - tool_handler...<h1>429</h1>
52024-06-25 07:52:33,2162024-06-25 07:52:33,216 - ERROR - tool_handler...<h1>429</h1>
62024-06-25 07:52:35,9522024-06-25 07:52:35,952 - ERROR - tool_handler...<h1>429</h1>
72024-06-25 07:54:39,6872024-06-25 07:54:39,687 - ERROR - tool_handler...<h1>429</h1>
82024-06-25 07:54:42,4782024-06-25 07:54:42,478 - ERROR - tool_handler...<h1>429</h1>
92024-06-25 07:57:06,5392024-06-25 07:57:06,539 - ERROR - tool_handler...<h1>429</h1>
102024-06-25 08:14:07,0602024-06-25 08:14:07,060 - ERROR - tool_handler...<h1>429</h1>
112024-06-25 08:14:10,0712024-06-25 08:14:10,071 - ERROR - tool_handler...<h1>429</h1>
122024-06-25 08:14:12,7382024-06-25 08:14:12,738 - ERROR - tool_handler...<h1>429</h1>
\n", "
" ], "text/plain": [ " Timestamp \\\n", "0 2024-06-25 06:39:01,261 \n", "1 2024-06-25 06:39:03,968 \n", "2 2024-06-25 06:39:06,904 \n", "3 2024-06-25 07:52:06,830 \n", "4 2024-06-25 07:52:09,671 \n", "5 2024-06-25 07:52:33,216 \n", "6 2024-06-25 07:52:35,952 \n", "7 2024-06-25 07:54:39,687 \n", "8 2024-06-25 07:54:42,478 \n", "9 2024-06-25 07:57:06,539 \n", "10 2024-06-25 08:14:07,060 \n", "11 2024-06-25 08:14:10,071 \n", "12 2024-06-25 08:14:12,738 \n", "\n", " Log Entry 429 Error Entry \n", "0 2024-06-25 06:39:01,261 - ERROR - tool_handler...

429

\n", "1 2024-06-25 06:39:03,968 - ERROR - tool_handler...

429

\n", "2 2024-06-25 06:39:06,904 - ERROR - tool_handler...

429

\n", "3 2024-06-25 07:52:06,830 - ERROR - tool_handler...

429

\n", "4 2024-06-25 07:52:09,671 - ERROR - tool_handler...

429

\n", "5 2024-06-25 07:52:33,216 - ERROR - tool_handler...

429

\n", "6 2024-06-25 07:52:35,952 - ERROR - tool_handler...

429

\n", "7 2024-06-25 07:54:39,687 - ERROR - tool_handler...

429

\n", "8 2024-06-25 07:54:42,478 - ERROR - tool_handler...

429

\n", "9 2024-06-25 07:57:06,539 - ERROR - tool_handler...

429

\n", "10 2024-06-25 08:14:07,060 - ERROR - tool_handler...

429

\n", "11 2024-06-25 08:14:10,071 - ERROR - tool_handler...

429

\n", "12 2024-06-25 08:14:12,738 - ERROR - tool_handler...

429

" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display(error_429_log_df)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.13" } }, "nbformat": 4, "nbformat_minor": 2 }