我有Django API,并且我使用所有参数将值为1的自定义api_call指标推送到每个路由的Prometheus PushGateway,因此我的指标如下所示:
api_call{ip="45.152.122.130",job="post",password="ffff",route="CustomObtainAuthToken",username="newuser1"} 1
api_call{ip="45.152.122.130",job="post",password="ffff",route="CustomObtainAuthToken",username="newuser2"} 1
api_call{ip="45.152.122.130",job="list",pk="me",route="FUserViewSet",token="Token 35c4535f8570dd127531632f9b72affc471e0afe"} 1
api_call{ip="45.152.122.130",job="retrieve",pk="450",route="UserImageViewSet",token="Token 3deb1b01acc27a624e86e9b14f98de64ada1bf8b"} 1
api_call{ip="45.152.122.130",job="create",route="UserImageViewSet",token="Token 3deb1b01acc27a624e86e9b14f98de64ada1bf8b",url="users/dbc39b1b52be4c7b88324469bfc642df",user="https://newfashion.ehedge.xyz/fusers/880/"}现在我正在尝试绘制api_call指标,以获得每隔5分钟间隔的总api_call调用计数,或者,如果没有调用,则为0,而不考虑括号中的参数,图类似于内部计数器: sum(increase(pushgateway_http_requests_total5m)).我试过rate函数-它总是返回0,sum_over_time(api_call5m)返回错误的sum。唯一有效的图形是sum(api_call),它返回不断增加的所有API调用的正确数量。我的问题是,对于具有值1和许多不同参数的指标,如何才能获得这样的图(如果值不变,则为0)的5分钟间隔增加?
发布于 2020-05-13 17:30:57
最后使用sum(api_call) -sum( API偏移5m)绘制每5分钟间隔内所有api_call调用的计数
https://stackoverflow.com/questions/61767051
复制相似问题