# Elastic apm instrumentation not working for my Flask application running in python 3.x

**URL:** <https://discuss.elastic.co/t/elastic-apm-instrumentation-not-working-for-my-flask-application-running-in-python-3-x/343693>\
**Category:** Elasticsearch\
**Created:** [September 24, 2023, 10:15pm UTC](https://discuss.elastic.co/t/elastic-apm-instrumentation-not-working-for-my-flask-application-running-in-python-3-x/343693 "2023-09-24T22:15:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankit\_kumar\_Srivasta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankit_kumar_srivasta/32/125965_2.png) [@Ankit\_kumar\_Srivasta](https://discuss.elastic.co/u/Ankit_kumar_Srivasta)\
**Post date:** [September 24, 2023, 10:15pm UTC](https://discuss.elastic.co/t/elastic-apm-instrumentation-not-working-for-my-flask-application-running-in-python-3-x/343693/1 "2023-09-24T22:15:34Z")

</div>

I am unable to find out transaction traces on kibana server after using the apm object like this.

```auto
app = Flask( __name__ )
app.secret_key = "ahugekey@netcore#2019"
app.config['ELASTIC_APM'] = {
          'SERVICE_NAME': 'onboarding',
          'SERVER_URL': 'http://14.142.143.138:8200'
}
apm = ElasticAPM(app)

```

Also i want to capture HTTP transaction labels from the code. Please help in the same.

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [September 25, 2023, 12:37pm UTC](https://discuss.elastic.co/t/elastic-apm-instrumentation-not-working-for-my-flask-application-running-in-python-3-x/343693/2 "2023-09-25T12:37:34Z")

</div>

Hi @Ankit_kumar_Srivasta,

Welcome to the community! I can think of a couple of things to check:

1. Is your Flask app running in debug mode? If so [you may need to follow the steps in the docs to set DEBUG for the agent](https://www.elastic.co/guide/en/apm/agent/python/current/flask-support.html#flask-debug-mode) as errors and traces are only sent when the app is not in debug node?
2. Otherwise, do you see any errors in your logs that look to belong to the agent? It could give an indication of another issue.

Do let us know if either of those help.

---

<div class="post-metadata">

**Author:** ![Ankit\_kumar\_Srivasta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankit_kumar_srivasta/32/125965_2.png) [@Ankit\_kumar\_Srivasta](https://discuss.elastic.co/u/Ankit_kumar_Srivasta)\
**Post date:** [September 26, 2023, 6:49am UTC](https://discuss.elastic.co/t/elastic-apm-instrumentation-not-working-for-my-flask-application-running-in-python-3-x/343693/3 "2023-09-26T06:49:13Z")

</div>

Hi, thanks @carly.richmond for the reply. The application is running like this

```auto
app.run(host= host,port=port)

```

I think by default the debug mode flag is False in python.  
Still i am facing the same error. I just want to capture labels for two particular end points in kibana using elastic apm server.  
Also i dont see any error related to APM agent in the logs.

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [September 26, 2023, 11:22am UTC](https://discuss.elastic.co/t/elastic-apm-instrumentation-not-working-for-my-flask-application-running-in-python-3-x/343693/4 "2023-09-26T11:22:04Z")

</div>

Hi @Ankit_kumar_Srivasta,

Have you tried setting the debug mode anyway to double check? I assume by no errors in the logs there are no errors in either the APM server or the application logs?

Can you confirm which versions of Flask and Python you're using and that they are in the [listed supported versions](https://www.elastic.co/guide/en/apm/agent/python/current/supported-technologies.html)?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 24, 2023, 11:22am UTC](https://discuss.elastic.co/t/elastic-apm-instrumentation-not-working-for-my-flask-application-running-in-python-3-x/343693/5 "2023-10-24T11:22:51Z")

</div>

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