[英]How to specify a whitelist of the metrics I want to use in spring-boot with micrometer
[英]How to retrieve metrics from spring-boot micrometer
我正在使用以下代碼試驗千分尺。 我如何配置速率聚合並從應用程序中的給定計數器獲取速率聚合數據。 通過聚合率,我的意思是之前發布間隔的數據?
final MeterRegistry myRegistry = new SimpleMeterRegistry();
final Random random = new Random();
for (iteration = 0; iteration < 1000; iteration++)
{
final int randomNum = random.nextInt(10);
final Counter myCounter = myRegistry.counter("myTestCounter", "random", Integer.toString(randomNum));
myCounter.increment();
Thread.sleep(100);
}
System.out.println("measure = [" + myRegistry.counter("myTestCounter", "random", "0").measure());
System.out.println("count = [" + myRegistry.counter("myTestCounter", "random", "0").count());
注意:我不想將指標發布到任何監控系統。 我想跟蹤應用程序本身中每個間隔給定標簽的請求數(例如,給定間隔的成功/失敗請求)並將其用於彈性目的。
根據項目作者的評論,Micrometer 打算將指標導出到像 Prometheus 這樣的外部產品就緒監控系統,所以你的方法有點不尋常。
Micrometer 支持監控系統的速率聚合,這些系統不支持像 InfluxDB 這樣的速率聚合,它的支持來自StepMeterRegistry
。 但是SimpleMeterRegistry
不是它的子類之一,所以如果你想堅持這種方法,你需要創建自己的一個。
更新:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.