newrelic / newrelic-salesforce-exporter

New Relic integration for Salesforce logs.
Apache License 2.0
10 stars 15 forks source link

Unable to run the salesforce audit and event log flex files from AWS server #54

Open ArunprasadGugan123 opened 1 month ago

ArunprasadGugan123 commented 1 month ago

Hi Team,

While migrating we are suppose to move all the flex config which is running currently in on premise and while we are trying to migrate we face issue in running the salesforce exporter and receive the below error. The necessary ports are opened at firewall end and we can see the traffic while running the flex files. The same file while running from on premise server we do not face any issue and the data is reporting to Newrelic. Please find the sample error image and the config sample attached FYR.. As this AWS migration plays a huge impact we are on the phase of cutoff period. So, we would like to resolve this issue asap. Please feel free to schedule call anytime between 11 am IST to 11 PM IST.

Regards, Arunprasad Gugan attribute error error flex.txt

ArunprasadGugan123 commented 1 month ago

Can I get some update here for the above

Regards, Arunprasad Gugan

sdewitt-newrelic commented 1 month ago

Hi @ArunprasadGugan123 while there is a bug here (there is no instance_name on the Authenticator object, you wouldn't be going through this code path unless your authentication failed. So the main problem here is that your authentication is failing for some reason. I can't quite tell because there is another issue here.

It does not look like you are using the latest version of the code. The error in your console is pointing at line 183. However, line 183 is actually this. The stack frame before that points at line 191 but line 191 is actually this. So I can't tell whether the exception you are getting is coming from line 185 or line 187. I believe it is line 187 which indicates a general RequestException coming from the package that we use to make HTTP requests. If this is working for you in another environment using exactly the same codebase, I would suspect that there is some difference in network setup such as firewalls or perhaps proxying.

If you could please paste the full console output directly in this issue, that would help. Please don't attach files. I try to avoid that for security reasons. That said, I am not sure there will be anything useful in the logs and you may have to do some network sleuthing from the machine where you are running the integration and getting that error (curl, wget, nc, etc).

ArunprasadGugan123 commented 1 month ago

Hi @sdewitt-newrelic,

Please find the console output below :

Microsoft Windows [Version 10.0.20348.2582] (c) Microsoft Corporation. All rights reserved.

C:\Windows\system32>cd C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT

C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT>py ./src/main.py 2024-09-24 14:26:03,867 (10532/MainThread) newrelic.core.agent INFO - New Relic Python Agent (9.13.0) 2024-09-24 14:26:05,625 (10532/NR-Activate-Session/New Relic Salesforce Exporter) newrelic.core.agent_protocol INFO - Reporting to: https://rpm.newrelic.com/accounts/2485673/applications/1088239611 {"message": "Integration start. Using program arguments []", "timestamp": 1727187965625, "level": "info"} {"message": "Cache disabled", "timestamp": 1727187965667, "level": "info"} {"message": "Running instance \"sfdc-logs\"", "timestamp": 1727187965667, "level": "info"} {"message": "retrieving salesforce token at https://workday--wduat.sandbox.my.salesforce.com/services/oauth2/token", "timestamp": 1727187965667, "level": "info"} {"message": "unknown exception occurred: 'Authenticator' object has no attribute 'instance_name'", "timestamp": 1727187970751, "level": "error"} Traceback (most recent call last): File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 466, in _make_request self._validate_conn(conn) File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 1095, in _validate_conn conn.connect() File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connection.py", line 652, in connect sock_and_verified = _ssl_wrap_socket_and_match_hostname( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connection.py", line 805, in _ssl_wrap_socket_and_match_hostname ssl_sock = ssl_wrapsocket( ^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\ssl.py", line 465, in ssl_wrap_socket ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, serverhostname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\ssl.py", line 509, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 455, in wrap_socket return self.sslsocket_class._create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 1042, in _create self.do_handshake() File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 1320, in do_handshake self._sslobj.do_handshake() TimeoutError: _ssl.c:983: The handshake operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 667, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 843, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\retry.py", line 474, in increment raise reraise(type(error), error, _stacktrace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\util.py", line 39, in reraise raise value File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 789, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\newrelic\packages\wrapt\wrappers.py", line 669, in call return self._self_wrapper(self.wrapped, self._self_instance, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\newrelic\hooks\external_urllib3.py", line 26, in _nr_wrapper_makerequest return ExternalTraceWrapper(wrapped, "urllib3", url_for_apm_ui, method=method)(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\newrelic\packages\wrapt\wrappers.py", line 589, in call return self._self_wrapper(self.wrapped, instance, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\newrelic\api\external_trace.py", line 120, in literal_wrapper return wrapped(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 490, in _make_request raise new_e File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 468, in _make_request self._raise_timeout(err=e, url=url, timeout_value=conn.timeout) File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 369, in _raise_timeout raise ReadTimeoutError( urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='workday--wduat.sandbox.my.salesforce.com', port=443): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\newrelic_logging\auth.py", line 174, in authenticate_with_password resp = session.post(self.token_url, params=params, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 637, in post return self.request("POST", url, data=data, json=json, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\newrelic\packages\wrapt\wrappers.py", line 669, in call return self._self_wrapper(self.wrapped, self._self_instance, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\newrelic\api\external_trace.py", line 103, in dynamic_wrapper return wrapped(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 703, in send r = adapter.send(request, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\newrelic_logging\http_session.py", line 19, in send return super().send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 713, in send raise ReadTimeout(e, request=request) requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='workday--wduat.sandbox.my.salesforce.com', port=443): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src__main.py", line 278, in main() File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\newrelic\packages\wrapt\wrappers.py", line 598, in call return self._self_wrapper(self.wrapped, self._self_instance, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\arunprasad.gugan.adm\AppData\Local\Programs\Python\Python312\Lib\site-packages\newrelic\api\background_task.py", line 111, in wrapper return wrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src__main__.py", line 272, in main run(config, event_type_fields_mapping, numeric_fields_list) File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src__main__.py", line 213, in run run_once( File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\main__.py", line 165, in run_once ).run() ^^^^^ File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\newrelic_logging\integration.py", line 53, in run raise e File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\newrelic_logging\integration.py", line 37, in run instance.harvest(session) File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\newrelic_logging\instance.py", line 24, in harvest self.api.authenticate(session) File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\newrelic_logging\api.py", line 81, in authenticate self.authenticator.authenticate(session) File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\newrelic_logging\auth.py", line 191, in authenticate self.authenticate_with_password(session) File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\newrelic_logging\auth.py", line 183, in authenticate_with_password raise LoginException(f'authentication failed for sfdc instance {self.instance_name}') from e ^^^^^^^^^^^^^^^^^^ AttributeError: 'Authenticator' object has no attribute 'instance_name'. Did you mean: 'instance_url'? 2024-09-24 14:26:10,916 (10532/MainThread) newrelic.core.agent INFO - New Relic Python Agent Shutdown

C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT>

Regards, Arunprasad Gugan

sdewitt-newrelic commented 1 month ago

Hi @ArunprasadGugan123, appreciate the output. You can see above, that, as I mentioned, while the instance_name AttributeError is technically a bug, it is not the actualy problem. Here is the relevant output.

File "C:\Program Files\New Relic\newrelic-infra\newrelic-salesforce-exporter-2.2.0-WDUAT\src\newrelic_logging\auth.py", line 183, in authenticate_with_password
raise LoginException(f'authentication failed for sfdc instance {self.instance_name}') from e
^^^^^^^^^^^^^^^^^^

The authentication is failing to your SFDC instance. You will need to try and figure out why that is. As I mentioned, you could use tools like curl, wget, nc, etc from that machine to diagnose why you can't login to the SFDC instance. This is not a problem with the integration (other than the exception handling).