【java】 prometheus監控告警

(1)場景:使用prometheus監控k8s集羣的運行狀態,並做到監控告警。

(2)pom:  git地址

        <dependency>
            <groupId>io.kubernetes</groupId>
            <artifactId>client-java</artifactId>
            <version>5.0.0</version>
            <scope>compile</scope>
        </dependency>

(3)實現思路

通過調用kubernetes api 實現資源文件的創建,進而達到目的。(說的比較籠統,細節我存在一些疑問,大佬可以替我補充補充)

(4)用的主要api,其實就是調用kube-apiserver的接口

    @Autowired
    private ApiClient apiClient;

    @Autowired
    private CoreV1Api coreV1Api;

    @Autowired
    private CustomObjectsApi customObjectsApi;
customObjectsApi + apiClient 是操作PrometheusRule資源對象、coreV1Api是操作AlertManager資源對象。

說到這裏可能大家根本不知道我在講啥,下面我說下prometheus的結構。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章