Elasticapm_integeration.py, did not see the place where we can point APM server and port no

Hi ,
Good evening,
from the previous post, want to update
https://discuss.elastic.co/t/apm-to-make-it-work-with-python/199165/2

and following the blog
https://www.elastic.co/blog/creating-custom-framework-integrations-with-the-elastic-apm-python-agent#

I am using the code at
https://github.com/beniwohli/pyramid-elasticapm-demo/tree/master/app

I run the task.py file and it executes, and trying to understand how " [elasticapm_integeration.py" works, I am running the 'task.py" and observing the behavior

After searching I didnot find any location or parameters which shows where the apm server and port can be pointed to

I am using the master version of pyramid-elasticapm-demo

Thanks
Joseph John

Hi @Joseph_John

You can supply the server URL (and any other configuration) when instantiating the ElasticAPM client:

elasticapm.Client(server_url="http://example.com:8200")

Alternatively, you can use environment variables, e.g. ELASTIC_APM_SERVER_URL.

All configuration options and their names are listed in our documentation.

Hope this helps!

1 Like

He Beni,
thanks for the reply and advice, I added the server links

in my case aom-server is in my host and I gave the "http://localhost:8200" , telnet to port 8200 shows the port opened and from kibana apm-server status check shows running

When I run the
$VENV/bin/python3 tasks.py

I am getting the following messages

intake/v2/events
ERROR:elasticapm.transport:Failed to submit message: 'HTTP 404: 404 - File or directory not found. Traceback (most recent call last):

Also this message

ERROR:elasticapm.transport:dropping flushed data due to transport failure back-off

^CTraceback (most recent call last):
File "tasks.py", line 111, in
server.serve_forever()
File "/usr/lib/python3.7/socketserver.py", line 232, in serve_forever
ready = selector.select(poll_interval)
File "/usr/lib/python3.7/selectors.py", line 415, in select
fd_event_list = self._selector.poll(timeout)

Guidance and advice requested
thanks
Joseph John

Hi All,
I have small update
When I have my apm-server running on the same machine as where I run the
$VENV/bin/python3 tasks.py
with
self.client = elasticapm.Client(service_name="My Application")
it works and I am getting results in the apm
Only When I adding server_url I am getting issues with the connectivity and the above thread eror comes

Thinking how to give the server url properly,
thanks

Hi All,
like to update, I have not done any progress
the
self.client = elasticapm.Client(framework_name="Pyramid",server_url='http://192.168.10.114:8200',service_name="JosephLaptop")

the above setup do not give the agent status on the APM server , but when I do

self.client = elasticapm.Client(framework_name="Pyramid",service_name="JosephLaptop")

It shows apm agent status OK in the local machine installed apm

I am figuring where I could go wrong, my skill in python is of a beginner level, I and requesting on how to trouble shoot on finding the reason, how to get the logs of the Pyramid task program

status of apm-server Ok , curl gives result

curl http://192.168.10.114:8200/

{
"build_date": "2019-10-28T18:52:50Z",
"build_sha": "1726aa000d8e1558879c9e9700966d1a2ce6d4d2",
"version": "7.4.2"
}

Guidance requested
thanks
Joseph John

Hey @Joseph_John

first of all, sorry for missing your previous replies :frowning:

It's weird that you can access the APM Server via curl, but the agent isn't able to reach it. Maybe it would help to set the log level of your Pyramid app temporarily to DEBUG. That should be possible by changing the level of logger_root in your development.ini to DEBUG (see last few paragraphs here: https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html#logging-configuration). Then look at the logs to see if anything more interesting is logged.

It would also be interesting to see the APM Server logs. You might have to start it with the -e flag to see logs on your console (https://www.elastic.co/guide/en/apm/server/current/command-line-options.html#global-flags)

1 Like

Hi Beniwohli,
Thanks
I tried with -e option
I can see the elastic search connection established
INFO pipeline/output.go:105 Connection to backoff(elasticsearch(http://192.168.10.69:9200)) established

and once I start the pyramid application, I get the "forbidden request: endpoint is disabled"
as given below

ERROR	[request]	middleware/log_middleware.go:74	forbidden request	{"request_id": "4e065ca3-d8ec-4b0d-86e2-2adae1e9f2c4", "method": "POST", "URL": "/config/v1/agents", "content_length": 37, "remote_address": "192.168.10.69", "user-agent": "elasticapm-python/3.0.0", "response_code": 403, "error": "forbidden request: endpoint is disabled"}

Thanks
Joseph John

That looks to me like the error you get if you don't have RUM enabled on the APM server. (It's disabled by default)

You'll want to set apm-server.rum.enabled: true in your apm-server.yml config file.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.