1
votes

I am quite new to Elastic APM, Kibana, Elasticsearch and APM in general and did not come across any information pointing towards my needs. I set up the elastic-apm[flask] module and followed the tutorial. In the Kibana dashboard I get information like response times and server name, but the fields for client.ip etc. are empty. I would like to track the IP addresses (more exactly where my website visitors come from).

So, how do I get the user's IP address into the client.ip field in Elastic APM? I don't want to issue an app.logger.debug statement everytime a route is being requested.

1
Well, it turns out, the field does actually already exist (at least if not issuing from the same localhost). It is called "http.request.env.REMOTE_ADDR". The core question about sending info determined at request time remains, however.fameman

1 Answers

1
votes

you have to modify your elastic APM python agent code. In general, you can add labels to your span example

elasticapm.label(key1=value1, key2=value2)

also, you can add directly to span object.

You will get the ip from request object flask

request.remote_addr set this to the desired key.

more details of APIs on elastic APM python agent can be found here - https://www.elastic.co/guide/en/apm/agent/python/current/api.html

Thanks