Prometheus promotheus监视一个简单的应用程序
我试图使用prometheus监控一个简单的应用程序,但不确定从哪里开始 我创建了一个简单的测试函数,将休眠10秒,并使用prometheus-Summary metric进行跟踪Prometheus promotheus监视一个简单的应用程序,prometheus,Prometheus,我试图使用prometheus监控一个简单的应用程序,但不确定从哪里开始 我创建了一个简单的测试函数,将休眠10秒,并使用prometheus-Summary metric进行跟踪 from prometheus_client import Summary import time from datetime import datetime TF_CALL_SUMMARY = Summary("call_seconds", "Time spent inside test function")
from prometheus_client import Summary
import time
from datetime import datetime
TF_CALL_SUMMARY = Summary("call_seconds", "Time spent inside test function")
def test():
while True:
t1 = datetime.now()
time.sleep(10)
t2 = datetime.now()
delta = t2 - t1
TF_CALL_SUMMARY.observe(delta.total_seconds())
print delta
print 'start application'
test()
print 'end application'
现在,这不是一个可以有/metric端点的web应用程序
如何将此度量导出到prometheus服务器?您需要向prometheus公开数据:
from prometheus_client import start_http_server
if __name__ == '__main__':
start_http_server(8000)
然后你需要普罗米修斯来清理这个数据源。向Prometheus配置文件中添加以下内容:
# Prometheus.yml
scrape_configs:
- job: "python"
static_configs:
- targets: ["localhost:8000"]
下面是一个详细介绍Python应用程序检测的示例,它将对您有用。您需要向Promethueus公开数据:
from prometheus_client import start_http_server
if __name__ == '__main__':
start_http_server(8000)
然后你需要普罗米修斯来清理这个数据源。向Prometheus配置文件中添加以下内容:
# Prometheus.yml
scrape_configs:
- job: "python"
static_configs:
- targets: ["localhost:8000"]
下面是一个详细说明Python应用程序的指令插入的示例,它将对您有用。每个应用程序都应该运行一个要监视的服务,对吗?@user1050619是的。来自:“Prometheus是一个监控平台,它通过在被监控目标上删除HTTP端点来收集被监控目标的指标。”每个应用程序都应该运行一个被监控的服务,对吗?@user1050619是。来自:“Prometheus是一个监控平台,通过在这些目标上删除HTTP端点来收集监控目标的指标。”