question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gunicorn + flask,kibana show no data

See original GitHub issue

Describe the bug: …

To Reproduce

  1. … gunicorn worker-class gevent
  2. …flask
  3. …elastic-apm 6.4.0

Environment (please complete the following information)

  • OS: [e.g. Linux]Linux
  • Python version: 3.6.8
  • Framework and version [e.g. Django 2.1]:
  • APM Server version:7.3.1
  • Agent version:

Additional context my flask flask_extensions.py code:

from flask import Flask
from elasticapm.contrib.flask import ElasticAPM

from config import config


flask_app = Flask(__name__)
flask_app.config.from_object(config)
flask_app.config['ELASTIC_APM'] = {
        'SERVICE_NAME': 'flask',
        'SECRET_TOKEN': 'xxx',
        'SERVER_URL': 'http://localhost:8200',
    }

apm = ElasticAPM()
apm.init_app(flask_app)

app.py content.

from flask_extensions import flask_app


if __name__ == '__main__':
    flask_app.run(host='0.0.0.0', port=8000, debug=False)

example a: run shell python app.py, after that, kibana can show some data.

example b: run shell

gunicorn --access-logfile - --error-logfile - \
   --workers 32 \
   --timeout 300 \
   --threads 2  \
   --bind 0.0.0.0:8000 \
   --worker-class gevent \
   --worker-connections 2000 \
   app:flask_app \
   2>&1 | tee ./backend_log.log

after that ,request the same url ,but can see nothing on kibana. i have tried change to pre_load = False or preload_app = False, but no effect.

Add any other context about the problem here.

  • Agent config options

    Click to expand
    replace this line with your agent config options
    remember to mask any sensitive fields like tokens
    
  • requirements.txt:

    Click to expand
    replace this line with your `requirements.txt`
    

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
beniwohlicommented, Jan 19, 2022

@Alsheh ah, good to know. We document this requirement (e.g. https://www.elastic.co/guide/en/apm/agent/python/current/flask-support.html#flask-installation), so I don’t think there’s much more we can do here.

0reactions
beniwohlicommented, Jan 26, 2022

I’m closing this, as I wasn’t able to reproduce any issues specific to gunicorn/flask.

Read more comments on GitHub >

github_iconTop Results From Across the Web

APM not showing data in Kibana when running app through ...
Create a basic flask app and begin and end a transaction in an API. Run it as gunicorn wsgi:app gunicorn_file.py. Hit the Flask...
Read more >
gunicorn - unknown log output to console - Stack Overflow
I have set these two loggers in my config file and they work well, but there is still an unexpected log record printed...
Read more >
Logging From Flask Application To ElasticSearch Via Logstash
In this blog post, I will explain how to send logs from Flask application to Elasticsearch via Logstash. As a bonus, I will...
Read more >
Monitoring Python Applications with Elastic APM
A guide to monitoring Flask, FastAPI and Python Applications with Elastic APM and Kibana.
Read more >
Get Application Performance Metrics on Python Flask With ...
This is just simple request paths to demonstrate the metrics via APM (Application Performance Monitoring) on Kibana. Install Flask and APM Agent.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found