如何在 Flask-MonitoringDashboard 中记录自定义数据?

问题描述 投票:0回答:1

我正在使用flask_monitoringdashboard 监控我的API。可以在这里访问 API

http://localhost:5000/price/https://example.com
。 我想以某种方式记录所有请求的
https://example.com
部分并将其显示在仪表板上。

from flask import Flask, Response
import flask_monitoringdashboard as dashboard

app = Flask(__name__)
dashboard.config.init_from(file='/dashboardconfig/config.cfg')
dashboard.bind(app)

@app.route('/price/<path:url>/')
def FetchPrice(url):
    if "xyz.com" in url:
        return Response("200.5$",status=200)
    else:
        return Response("Bad Request", status=400)

这里是

config.cfg

[dashboard]
APP_VERSION=1.0
CUSTOM_LINK=dashboard
MONITOR_LEVEL=3
OUTLIER_DETECTION_CONSTANT=2.
[authentication]
USERNAME=admin
PASSWORD=admin
SECURITY_TOKEN=XXXXxxxXXXxxXXxXXxXX
[database]
DATABASE=sqlite:///flask_monitoringdashboard.db
[visualization]
TIMEZONE=America/Bogota
COLORS={'main':'[0,97,255]', 'static':'[255,153,0]'}
python api flask flask-restful
1个回答
0
投票

将答案留在这里,以防对其他人有用,肯定两年后OP不再对答案感兴趣:

您无法使用当前版本的

flask_monitoringdashboard
做您想做的事。

© www.soinside.com 2019 - 2024. All rights reserved.