如何在不修改代码的情况下监控烧瓶应用程序?

时间:2017-01-10 18:28:43

标签: python flask prometheus

我一直在制作一个小系统来监控烧瓶应用程序和其他人(postgres数据库,linux服务器等)与prometheus。一切进展顺利,但我想在不修改代码的情况下监控我的烧瓶应用程序。

例如,为了监控我的应用程序的方法,我做了:

# Create a metric to track time spent and requests made.
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')

@app.route('/')
@REQUEST_TIME.time()
def index():
 myUser = User.query.all()
 return render_template('add_user.html', myUser= myUser)

我使用了this python库。

此外,我使用other library来监控烧瓶应用程序:

monitor(app, port=9999)
不幸的是,两人都在修改我的代码。我想监视我的烧瓶应用程序而不修改他的代码。有可能的?

1 个答案:

答案 0 :(得分:0)

目前还不清楚你在问什么。但是,如果您只需要有关调用哪些请求以及需要多长时间的信息,您可以使用newrelic运行您的烧瓶应用程序:它们提供免费套餐(yay!)并使用它您将获得有关您的应用程序的大量见解。但要使用它,您需要使用其客户端运行您的应用程序(但不需要更改代码)。

有关您将获得的更多信息,请访问: https://newrelic.com/python/flask