當您部署 Apache Cassandra 叢集的 Azure 受控執行個體 時,服務會在每個資料節點上配置 Metrics Collector for Apache Cassandra 代理程式軟體。 Prometheus 會收集這些計量資料,並透過 Grafana 將其視覺化。 本文說明如何設定 Prometheus 與 Grafana,以視覺化您 Managed Instance 叢集所發出的指標。
以下任務是要視覺化指標的:
- 在 Managed Instance 所在的 Azure 虛擬網路中部署 Ubuntu 虛擬機器(VM)。
- 將 Prometheus 儀表板 安裝到虛擬機上。
Warning
Prometheus 和 Grafana 是開源軟體,不屬於 Azure 受控執行個體 for Apache Cassandra 的支援範圍。 本文所述的視覺化指標需要你同時托管並維護一台虛擬機作為 Prometheus 和 Grafana 的伺服器。 本文中的說明僅針對 Ubuntu Server 18.04 進行測試。 也不能保證它們能和其他 Linux 發行版相容。
遵循此方法意味著您必須支援可能出現的問題,例如空間不足或伺服器可用性不足。 若要獲得完整支援且託管的指標體驗,請考慮使用 Azure 監視器 指標或 Azure 監視器 合作夥伴整合。
部署 Ubuntu 伺服器
登入 Azure 入口網站。
前往您 Managed Instance 叢集所在的資源群組。 選擇 新增 並搜尋 Ubuntu Server 18.04 LTS 映像檔。
選取影像,然後選擇 「建立」。
在 「建立虛擬機器 」窗格中,輸入下列欄位的值。 您可以為其他欄位保留預設值:
- 虛擬機器名稱:輸入您的虛擬機名稱。
- 區域:選擇您虛擬網路部署的相同區域。
在 「網路」 索引標籤中,選擇您部署 Managed Instance 的虛擬網路。
最後,選擇 Review + create 以建立您的指標伺服器。
安裝 Prometheus 儀表板
首先,請確保您新部署的 Ubuntu 伺服器的網路設定中,有允許使用
9090連接埠與3000的入站埠規則。 這些連接埠稍後會分別供 Prometheus 和 Grafana 使用。
透過 Azure CLI 或您偏好的用戶端工具,透過 Secure Shell 連接至 Ubuntu 伺服器。
連接虛擬機後,安裝指標收集軟體。 首先,下載並解壓這些檔案:
#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將叢集中每個節點的 IP 位址加入
targets,每個節點的埠號為 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檔案現在應該會看起來像以下範例。 請確保每一行的 Tab 字元與範例相符:
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 應該可在你的 metrics server 上透過連接埠
3000存取,而 Grafana 儀表板則可在連接埠9090上存取。
相關內容
在本文中,您學習如何使用 Grafana 設定儀表板以在 Prometheus 中視覺化指標。 透過以下文章進一步了解 Apache Cassandra 的 Azure 受控執行個體: