FastAPI display "No data to display" in Kibana #903

shijingyu323
Tue, 11 Mar 2025 08:16:31 +0000
APM

Kibana version:8.2.0

Elasticsearch version:8.2.0

APM Server version:8.2.0

APM Agent language and version: fastapi 0.83.0

After integrating the FastAPI service with APM, Kibana shows "No data to display." While CPU and memory metrics are visible on the metrics page, all other metrics are empty.
Elasticsearch, Kibana, and APM Server are self-hosted, and other services like Java and Flask are connecting successfully. The FastAPI configuration is as follows.

from elasticapm.contrib.starlette import ElasticAPM, make_apm_client
proxy_server = ReadConfigsSingleton().get_proxy_server_python_arithmetic()
app = FastAPI(title="服务接口",
              description="Json格式数据需要压缩后传输",
              version="1.0.0",
              servers=[{"url": proxy_server, "description": "代理地址"}])

apm = make_apm_client({
    'SERVICE_NAME': 'python-dev',
    'SERVER_URL': 'http://172.20.49.135:8200',
    'ENABLED': 'true',
    'DEBUG': True,
    'LOG_LEVEL': "error",
    'TRANSACTIONS_IGNORE_PATTERNS': [],
    'TRANSACTION_SAMPLE_RATE': 1.0
})


app.add_middleware(ElasticAPM, client=apm)

@app.get("/",
         summary="文档路由接口")
def read_root():
    return {"线上文档地址": "https://paas.com/swagger-ui/",
            "本地文档地址": "http://python.com/docs",
            "调试文档地址": "http://127.0.0.1:8000/docs"}
if __name__ == "__main__":
    uvicorn.run(app, host="127.0.0.1", port=8000)

2 posts - 2 participants