jorgebastida / awslogs

AWS CloudWatch logs for Humans™
Other
4.86k stars 336 forks source link

Trace when getting a log and grepping for ERROR when AWS token expired #389

Open loquisgon opened 1 year ago

loquisgon commented 1 year ago

I am very new to wslogs, just got it this afternoon. It has been a nice tool so far, logging this because this is what the tool is asking me to do, glad to do it & thanks for the great work!

(it looks that my token has expired and that seems to be the root cause but creating the bug anyways, it might be useful)

You've found a bug! Please, raise an issue attaching the following traceback https://github.com/jorgebastida/awslogs/issues/new

Version: 0.14.0 Python: 3.8.10 (default, Mar 13 2023, 10:26:41) [GCC 9.4.0] boto3 version: 1.26.104 Platform: Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.29 Args: ['/home/gonzal_a/.local/bin/awslogs', 'get', '/msk/connect/xxx', 'xxx-17991dbd-808a-4b4d-b0a4-7ae590d9d2d5-2', '--start', '1hr ago'] Config: {'aws_access_key_id': 'SENSITIVE', 'aws_secret_access_key': 'SENSITIVE', 'aws_session_token': 'SENSITIVE', 'aws_profile': 'SENSITIVE', 'aws_region': None, 'aws_endpoint_url': None, 'log_group_name': '/msk/connect/xxx', 'log_stream_name': xxx-17991dbd-808a-4b4d-b0a4-7ae590d9d2d5-2', 'filter_pattern': None, 'watch': False, 'watch_interval': 1, 'output_group_enabled': True, 'output_stream_enabled': True, 'output_timestamp_enabled': False, 'output_ingestion_time_enabled': False, 'start': '1hr ago', 'end': None, 'color': 'auto', 'query': None, 'func': 'list_logs'}

Traceback (most recent call last): File "/home/gonzal_a/.local/lib/python3.8/site-packages/awslogs/bin.py", line 179, in main getattr(logs, options.func)() File "/home/gonzal_a/.local/lib/python3.8/site-packages/awslogs/core.py", line 109, in list_logs streams = list(self._get_streams_from_pattern(self.log_group_name, self.log_stream_name)) File "/home/gonzal_a/.local/lib/python3.8/site-packages/awslogs/core.py", line 102, in _get_streams_from_pattern for stream in self.get_streams(group): File "/home/gonzal_a/.local/lib/python3.8/site-packages/awslogs/core.py", line 261, in get_streams for page in paginator.paginate(kwargs): File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/paginate.py", line 269, in iter response = self._make_request(current_kwargs) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/paginate.py", line 357, in _make_request return self._method(current_kwargs) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/client.py", line 530, in _api_call return self._make_api_call(operation_name, kwargs) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/client.py", line 943, in _make_api_call http, parsed_response = self._make_request( File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/client.py", line 966, in _make_request return self._endpoint.make_request(operation_model, request_dict) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/endpoint.py", line 119, in make_request return self._send_request(request_dict, operation_model) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/endpoint.py", line 198, in _send_request request = self.create_request(request_dict, operation_model) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/endpoint.py", line 134, in create_request self._event_emitter.emit( File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/hooks.py", line 412, in emit return self._emitter.emit(aliased_event_name, kwargs) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/hooks.py", line 256, in emit return self._emit(event_name, kwargs) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/hooks.py", line 239, in _emit response = handler(kwargs) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/signers.py", line 105, in handler return self.sign(operation_name, request) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/signers.py", line 180, in sign auth = self.get_auth_instance(**kwargs) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/signers.py", line 284, in get_auth_instance frozen_credentials = self._credentials.get_frozen_credentials() File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/credentials.py", line 610, in get_frozen_credentials self._refresh() File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/credentials.py", line 498, in _refresh self._protected_refresh(is_mandatory=is_mandatory_refresh) File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/credentials.py", line 514, in _protected_refresh metadata = self._refresh_using() File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/credentials.py", line 661, in fetch_credentials return self._get_cached_credentials() File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/credentials.py", line 671, in _get_cached_credentials response = self._get_credentials() File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/credentials.py", line 2115, in _get_credentials token = initial_token_data.get_frozen_token().token File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/tokens.py", line 82, in get_frozen_token self._refresh() File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/tokens.py", line 95, in _refresh self._protected_refresh() File "/home/gonzal_a/.local/lib/python3.8/site-packages/botocore/tokens.py", line 122, in _protected_refresh raise TokenRetrievalError( botocore.exceptions.TokenRetrievalError: Error when retrieving token from sso: Token has expired and refresh failed