Monitoring

Flowise原生支持Prometheus、Grafana和OpenTelemetry。但是,仅跟踪高级指标,如API请求、流/预测计数。有关计数器指标的列表,请参阅此处。如需详细的逐节点可观察性,我们建议使用Analytic

普罗米修斯

Prometheus 是一个开源的监控和警报解决方案。

在设置Prometheus之前,请在Flowise中配置以下环境变量:

属性文件 启用指标=true 指标提供者=prometheus METRICS_INCLUDE_NODE_METRICS=true


安装Prometheus后,使用配置文件运行它。Flowise提供了一个默认配置文件,可以在[这里](https://github.com/FlowiseAI/Flowise/blob/main/metrics/prometheus/prometheus.config.yml)找到。

请记住让Flowise实例也运行起来。你可以打开浏览器并访问端口9090。在仪表板上,你应该能看到指标端点 - `/api/v1/metrics` 现已上线。

<figure><img src="../.gitbook/assets/image (178).png" alt=""> <figcaption></figcaption></figure>

默认情况下,`/api/v1/metrics` 可供 Prometheus 从中提取指标。

<figure><img src="../.gitbook/assets/image (177).png" alt="" width="563"><figcaption></figcaption></figure>

## Grafana

Prometheus收集丰富的指标并提供强大的查询语言;Grafana将指标转换为有意义的可视化图表。

Grafana可以通过多种方式安装。请参阅[指南](https://grafana.com/docs/grafana/latest/setup-grafana/installation/)。

默认情况下,Grafana会开放端口9091:

<figure><img src="../.gitbook/assets/image (179).png" alt=""> <figcaption></figcaption></figure>

在左侧边栏,点击“添加新连接”,然后选择“Prometheus”:

<figure><img src="../.gitbook/assets/image (180).png" alt=""> <figcaption></figcaption></figure>

由于我们的Prometheus正在9090端口上运行:

<figure><img src="../.gitbook/assets/image (181).png" alt=""><figcaption></figcaption></figure>

滚动到页面底部并测试连接:

<figure><img src="../.gitbook/assets/image (182).png" alt=""> <figcaption></figcaption></figure>

记下工具栏中显示的数据源ID,我们创建仪表板时需要用到它:

<figure><img src="../.gitbook/assets/image (184).png" alt=""> <figcaption></figcaption></figure>

既然已经成功添加了连接,我们可以开始添加仪表板了。从左侧边栏,点击“仪表板”,然后点击“创建仪表板”。

Flowise提供了2个模板仪表板:

* [grafana.dashboard.app.json.txt](https://github.com/FlowiseAI/Flowise/blob/main/metrics/grafana/grafana.dashboard.app.json.txt):API指标,如聊天流/代理流数量、预测次数、工具、助手、更新向量等。
* [grafana.dashboard.server.json.txt](https://github.com/FlowiseAI/Flowise/blob/main/metrics/grafana/grafana.dashboard.server.json.txt):Flowise node.js实例的指标,如堆、CPU、RAM使用情况

如果你正在使用上述模板,请查找并替换所有出现的“cds4j1ybfuhogb”为你之前创建并保存的数据源ID。

<figure><img src="../.gitbook/assets/image (183).png" alt=""> <figcaption></figcaption></figure>

您也可以选择先导入,之后再编辑JSON:

<figure><img src="../.gitbook/assets/image (185).png" alt=""> <figcaption></figcaption></figure>

现在,尝试在Flowise上执行一些操作,你应该能看到显示的指标:

<figure><img src="../.gitbook/assets/image (186).png" alt=""> <figcaption></figcaption></figure>

<figure><img src="../.gitbook/assets/image (187).png" alt=""> <figcaption></figcaption></figure>

## OpenTelemetry

[OpenTelemetry](https://opentelemetry.io/) 是一个用于创建和管理遥测数据的开源框架。要在 Flowise 中启用 OTel,请配置以下环境变量:

属性文件
启用指标=true
指标提供者=open_telemetry
METRICS_INCLUDE_NODE_METRICS=true
METRICS_OPEN_TELEMETRY_METRIC_ENDPOINT=http://localhost:4318/v1/metrics
METRICS_OPEN_TELEMETRY_PROTOCOL=http # http | rpc | proto(默认为http)
METRICS_OPEN_TELEMETRY_DEBUG=true

接下来,我们需要OpenTelemetry Collector来接收、处理和导出遥测数据。Flowise提供了一个docker compose文件,可用于启动收集器容器。

cd Flowise
进入metrics目录并执行命令,然后进入otel目录
docker compose up -d

收集器将使用同一目录下的otel.config.yml文件进行配置。目前仅支持Datadog和Prometheus,如需配置其他APM工具(如Zipkin、Jaeger、New Relic、Splunk等),请参阅Open Telemetry文档。

请确保在yml文件中为导出器替换为必要的API密钥。

Last updated