部署 Azure 托管实例 for Apache Cassandra 群集时,该服务会在每个数据节点上预配 Metrics Collector for Apache Cassandra 代理软件。 Prometheus 采集指标,并通过 Grafana 进行可视化。 本文介绍如何配置 Prometheus 和 Grafana,以可视化从 Managed Instance 群集发出的指标。
需要执行以下任务才能可视化指标:
- 在 Managed Instance 所在的Azure虚拟网络中部署 Ubuntu 虚拟机(VM)。
- 将 Prometheus 仪表板 安装到 VM 上。
警告
Prometheus 和 Grafana 是开源软件,不属于 Azure 托管实例 for Apache Cassandra 的支持范围。 按照本文中所述的方式可视化指标,需要您托管并维护一台 VM,将其用作 Prometheus 和 Grafana 的服务器。 本文中的说明仅针对 Ubuntu Server 18.04 进行了测试。 不能保证它们与其他 Linux 分发版一起使用。
遵循此方法意味着必须支持可能出现的任何问题,例如空间不足或服务器的可用性不足。 对于完全受支持的托管指标体验,请考虑使用Azure Monitor指标或Azure Monitor合作伙伴集成。
部署 Ubuntu 服务器
登录到 Azure 门户。
转到 Managed Instance 群集所在的资源组。 选择 “添加” 并搜索 Ubuntu Server 18.04 LTS 映像。
选择映像,然后选择“ 创建”。
在“ 创建虚拟机 ”窗格中,输入以下字段的值。 可以保留其他字段的默认值:
- 虚拟机名称:输入 VM 的名称。
- 区域:选择部署虚拟网络的同一区域。
在“网络”选项卡上,选择部署 Managed Instance 的虚拟网络。
最后,选择“查看并创建”以创建指标服务器。
安装 Prometheus 仪表板
首先,确保新部署的 Ubuntu 服务器的网络设置具有允许端口
3000和9090入站访问的规则。 Prometheus 和 Grafana 稍后需要这些端口。
使用 Azure CLI 或首选客户端工具通过 Secure Shell 进行连接,连接到 Ubuntu 服务器。
连接到 VM 后,安装指标收集器软件。 首先,下载并解压缩文件:
#install unzip utility (if not already installed) sudo apt install unzip #get dashboards wget https://github.com/datastax/metric-collector-for-apache-cassandra/releases/download/v0.3.0/datastax-mcac-dashboards-0.3.0.zip -O temp.zip unzip temp.zip接下来,转到 Prometheus 目录并使用
vi编辑tg_mcac.json文件:cd */prometheus vi tg_mcac.json在
targets中添加群集中每个节点的 IP 地址,每个地址都使用 9443 端口。 文件tg_mcac.json应如以下示例所示:[ { "targets": [ "10.9.0.6:9443","10.9.0.7:9443","10.9.0.8:9443" ], "labels": { } } ]保存文件。 接下来,在同一目录中编辑
prometheus.yaml该文件。 找到以下部分:file_sd_configs: - files: - 'tg_mcac.json'在本部分的正下方,添加以下代码片段。 此步骤是必需的,因为指标是通过 HTTPS 公开的。
scheme: https tls_config: insecure_skip_verify: true该文件现在应如以下示例所示。 确保每行中的制表符与示例匹配:
file_sd_configs: - files: - 'tg_mcac.json' scheme: https tls_config: insecure_skip_verify: true保存文件。 现在,你可以启动 Prometheus 和 Grafana。 首先,安装 Docker:
sudo apt install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu `lsb_release -cs` test" sudo apt update sudo apt install docker-ce然后安装
docker-compose:sudo apt install docker-compose现在,转到
docker-compose.yaml所在的顶级目录,并启动应用程序:cd .. sudo docker-compose upPrometheus 应该可通过指标服务器上的端口
9090访问,Grafana 仪表板可通过端口3000访问。
相关内容
本文介绍了如何使用 Grafana 配置仪表板以可视化 Prometheus 中的指标。 通过以下文章详细了解适用于 Apache Cassandra 的 Azure 托管实例: