i’m new to prometheus, and currently i stuck with a problem.
So i need to implement prometheus metrics to the service.
The language we use is Scala, and http lib is spray.
simple start
JvmMetrics.builder.register()
val server = HTTPServer.builder.port(9345).buildAndStart
second prometheus http server is instantly dying for no reason. no error, just stopping every time “i spent too much time digging through this problem”
What i decided to do, is to scrape metrics from defaultRegistry and just return them through my http route.
And here i need help. I cant find anywhere how to turn Seq[MetricSnapshot]
to string like
# HELP jvm_buffer_pool_capacity_bytes Bytes capacity of a given JVM buffer pool.
# TYPE jvm_buffer_pool_capacity_bytes gauge
jvm_buffer_pool_capacity_bytes{pool="direct"} 16384.0
jvm_buffer_pool_capacity_bytes{pool="mapped"} 0.0
jvm_buffer_pool_capacity_bytes{pool="mapped - 'non-volatile memory'"} 0.0
If anyone know how to do that or some useful lib, please let me know. Pretty sure i’m not the only one, who want to get prometheus metrics directly from registry
P.S. If you happen to know any other solution, please also leave a commet