metric-histogram-example.toml 1.7 KB

123456789101112131415161718192021222324
  1. [[metric]] # 定义一个指标配置
  2. context = "test_histo" # 指标的上下文或分类,这里是 "test_histo",表示这是一个用于测试的直方图
  3. # SQL 查询,选择了多个字段来模拟直方图的不同桶(buckets)和相关的计数值
  4. request = "SELECT 'firstlabel' as label1, 'secondlabel' as label2, 3 as le_20, 19 as le_40, 31 as le_60, 40 as le_80, 45 as count, 123.45 as data FROM DUAL"
  5. # 描述字段 data 为直方图类型,表示数据字段的所有值的总和
  6. metricsdesc = { data = "Histogram - sum total of all values in the data field." }
  7. # 指定 data 字段的类型为直方图(histogram)
  8. metricstype = { data = "histogram" }
  9. # 定义标签字段,这里是 "label1" 和 "label2",可以作为直方图的维度来区分数据
  10. labels = [ "label1", "label2" ]
  11. # 配置每个桶(bucket)的阈值,用于定义直方图的范围
  12. metricsbuckets = { data = { le_20 = "20", le_40 = "40", le_60 = "60", le_80 = "80" } }
  13. # 该直方图指标将生成如下形式的度量数据:
  14. # HELP xugudb_test_histo_data Histogram - sum total of all values in the data field.
  15. # TYPE xugudb_test_histo_data histogram
  16. # xugudb_test_histo_data_bucket{label1="firstlabel",label2="secondlabel",le="20"} 3
  17. # xugudb_test_histo_data_bucket{label1="firstlabel",label2="secondlabel",le="40"} 19
  18. # xugudb_test_histo_data_bucket{label1="firstlabel",label2="secondlabel",le="60"} 31
  19. # xugudb_test_histo_data_bucket{label1="firstlabel",label2="secondlabel",le="80"} 40
  20. # xugudb_test_histo_data_bucket{label1="firstlabel",label2="secondlabel",le="+Inf"} 45
  21. # xugudb_test_histo_data_sum{label1="firstlabel",label2="secondlabel"} 123.45
  22. # xugudb_test_histo_data_count{label1="firstlabel",label2="secondlabel"} 45