本文将为您介绍如何为 Prometheus 监控配置公网地址。
实践步骤
步骤1:购买 Prometheus 实例
1. 登录 Prometheus 监控服务控制台。
2. 单击左上角的新建,进入 Prometheus 购买页,可根据自己的实际情况购买对应的实例,详情请参见 创建实例。
3. 成功购买后,单击创建的实例 ID/名称,进入实例详情页的基本信息,获取 Prometheus IPV4 地址。
![](https://qcloudimg.tencent-cloud.cn/image/document/b107a098d54c20a1f5618c8e939fa4f7.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/b107a098d54c20a1f5618c8e939fa4f7.png)
步骤2:申请 CLB 跨 VPC 功能(内测功能)
1. 进入 负载均衡跨地域绑定2.0及混合云部署内测申请页。
2. 根据填好资料,填写完后提交申请。
3. 申请通过后即可使用 CLB 跨 VPC 功能。
步骤3:新建公网 CLB 实例
1. 进入 负载均衡控制台,新建 CLB 实例。
2. 根据提示选择并填写信息,具体操作说明可参见 创建负载均衡实例。
说明:
需创建与 Prometheus 同 VPC 下的 CLB 实例,才可绑定 Prometheus 内网 IP。若已有公网的 CLB 实例,可不新建。
3. 创建完后进入实例基本信息页,开启跨 VPC 功能。
![](https://qcloudimg.tencent-cloud.cn/image/document/a400d071effef659b94f515529193183.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/a400d071effef659b94f515529193183.png)
步骤4:绑定后端服务
1. 进入监听器管理页面。
2. 单击 TCP/UDP/TCP SSL/QUIC 监听器下的新建。
![](https://qcloudimg.tencent-cloud.cn/image/document/bbebe6632df5f529020808fcc17876cd.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/bbebe6632df5f529020808fcc17876cd.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/898f96a9aba697d3817e436d4b770ec4.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/898f96a9aba697d3817e436d4b770ec4.png)
3. 新建完监听器后,单击监听器名称。在子窗口中单击绑定,绑定后端服务。
![](https://qcloudimg.tencent-cloud.cn/image/document/605a0aa31058307533c303a646349913.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/605a0aa31058307533c303a646349913.png)
目标类型:选择 IP 类型。
默认端口:9090。
IP 地址:需填写步骤1获取的 Prometheus IPV4 地址。
![](https://qcloudimg.tencent-cloud.cn/image/document/0b39fa2b2f6951057ed4e2d52a3435fd.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/0b39fa2b2f6951057ed4e2d52a3435fd.png)
4. 单击监听器名称,查看是否监听正常。![](https://qcloudimg.tencent-cloud.cn/image/document/aa1e8e93a3c89af19e07f94168367477.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/aa1e8e93a3c89af19e07f94168367477.png)
步骤5:测试是否配置成功
1. 查看公网 CLB 的地址,这里假设查看的地址为:192.168.1.1 。
![](https://qcloudimg.tencent-cloud.cn/image/document/c7e687631c914e22854e0726aea7e7c1.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/c7e687631c914e22854e0726aea7e7c1.png)
2. 查看监听配置端口。如下列端口为:8080。
![](https://qcloudimg.tencent-cloud.cn/image/document/85a903a46a4156c34234f8440a5c6690.png)
根据上述两个信息,确定 Prometheus 转发的公网地址为如下新 IP:PORT 地址为:
![](https://qcloudimg.tencent-cloud.cn/image/document/85a903a46a4156c34234f8440a5c6690.png)
192.168.1.1:8080
。3. 到浏览器或者机器上查看是否可以通过这个 IP 获取 UP 数据。
HTTP API 地址:
http://IP:PORT/api/v1/query?query=up
用对应 CLB 的公网 IP 和端口 替换 IP:PORT 后如下:
http://81.71.21.123:8080/api/v1/query?query=up
4. 进入链接地址
http://81.71.21.123:8080/api/v1/query?query=up
。用户名:填写您的主账号 ID (APPID)。
密码:在实例的基本信息页面获取 Token 。
![](https://qcloudimg.tencent-cloud.cn/image/document/5d61a53c32195403013740e71ea05936.png)
如下图所示,Prometheus 配置公网地址成功。
![](https://qcloudimg.tencent-cloud.cn/image/document/1267b921d10b70de8c5240ed76b5ff76.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/5d61a53c32195403013740e71ea05936.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/1267b921d10b70de8c5240ed76b5ff76.png)