dpsoft / kamon-jfr-playground

A proof of concept of how to collect metrics using the JDK Flight Recorder event streaming(JEP 349) and Kamon to send them to Prometheus + Grafana and Apache Pinot.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JFR playground

A proof of concept of how to collect metrics using the JDK Flight Recorder event streaming(JEP 349) and Kamon telemetry to send them to Prometheus/Pinot

Prerequisites

Kamon + Prometheus + Grafana

# Prometheus + Grafana + Metrics dashboard
docker-compose -f docker/grafana-prometheus-compose.yml up

# Example service
sbt run

# Stress the service
k6 run k6/stress.js      

          /\      |‾‾| /‾‾/   /‾‾/   
     /\  /  \     |  |/  /   /  /    
    /  \/    \    |     (   /   ‾‾\  
   /          \   |  |\  \ |  (‾)  | 
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: k6/stress.js
     output: ...........

Then open the "JFR Metrics" dashboard in Grafana(localhost:3000) and Enjoy!

Bonus

Send profiling information(jdk.ObjectAllocationSample) to Pinot realtime table via Kafka and play with it ;)

# Kafka + Pinot
docker-compose -f pinot-kafka-compose.yml up

# Topic
docker exec -t kamon-jrf-playground_kafka  kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic jfr-allocation-topic

# Table Schema
curl -X POST "http://localhost:9000/schemas?override=true" -H "accept: application/json" -H "Content-Type: application/json" -d @jfr-allocation-schema.json

# Realtime Table configuration
curl -X POST "http://localhost:9000/tables" -H "accept: application/json" -H "Content-Type: application/json" -d @jfr-object-allocation-table.json

# Enable `jdk.ObjectAllocationSample` event in application.conf changing
"jdk.ObjectAllocationSample#enabled=false" to "jdk.ObjectAllocationSample#enabled=true" 

Then open the Pinot SQL Console(localhost:9000/#/query) and Enjoy!

Disclaimer

I have just scratched the surface of Pinot capabilities, and I'm sure there are other better ways of modeling than the one proposed, using other features and data types.

License

This code base is available ander the Apache License, version 2.

About

A proof of concept of how to collect metrics using the JDK Flight Recorder event streaming(JEP 349) and Kamon to send them to Prometheus + Grafana and Apache Pinot.


Languages

Language:Scala 94.8%Language:Java 3.2%Language:JavaScript 1.8%Language:Shell 0.2%