SlideShare a Scribd company logo
Introduction to
MicroProfile Metrics
HASUNUMA Kenji

GlassFish Users Group Japan

k.hasunuma@coppermine.jp

Twitter: @khasunuma
#jjug_ccc #ccc_i1
Why not JMX?
• JXM/RMI is not easy to deal with

• Integration with non-Java is too hard

• Microservices may include 

Java and non-Java environments

-> REST based Metrics API
#jjug_ccc #ccc_i1 @khasunuma
MicroProfie Metrics
• Included MicroProfile 1.2 or later

• Built on JAX-RS and CDI

• Expose system and user metrics

• Using generic text format
#jjug_ccc #ccc_i1 @khasunuma
Key features
• REST endpoint

• Registry -- i.e. Scope

Base, Vendor and Application

• Format

• Prometheus text format: text/plain

• JSON format: application/json
#jjug_ccc #ccc_i1 @khasunuma
REST endpoint
• /metrics by default

e.g. http://localhost:8080/metrics

• With Registry (see later)

• /metrics/base

• /metrics/vendor

• /metrics/application
#jjug_ccc #ccc_i1 @khasunuma
Registry
Store of metrics values:

• Base -- JVM metrics, Required

• Typically obtained from MBean

• Vendor -- Vendor specific metrics

• Application -- User metrics
#jjug_ccc #ccc_i1 @khasunuma
Format (Prometheus)
# TYPE base:cpu_system_load_average gauge

# HELP base:cpu_system_load_average Displays...

base:cpu_system_load_average -1.0

# TYPE base:thread_count counter

# HELP base:thread_count Displays...

base:thread_count 90

# TYPE base:classloader_current_loaded_class_count counter

# HELP base:classloader_current_loaded_class_count Displays...

base:classloader_current_loaded_class_count 11150

# TYPE base:classloader_total_loaded_class_count counter

# HELP base:classloader_total_loaded_class_count Displays...

base:classloader_total_loaded_class_count 11193

# TYPE vendor:system_cpu_load gauge

# HELP vendor:system_cpu_load Display...

vendor:system_cpu_load 0.1491192437579042
#jjug_ccc #ccc_i1 @khasunuma
Format (JSON)
{

"base": {

"cpu.systemLoadAverage": -1,

"thread.count": 90,

"classloader.currentLoadedClass.count": 11150,

"classloader.totalLoadedClass.count": 11193,

},

"vendor": {"system.cpu.load": 0.1491192437579042}

}
#jjug_ccc #ccc_i1 @khasunuma
Simple Metrics
Counter
Gauge
#jjug_ccc #ccc_i1 @khasunuma
Complex Metrics
Meter Histogram Timer
#jjug_ccc #ccc_i1 @khasunuma
How to expose metrics
1. Denote metric(s) as field, method,
constructor, parameter or class

• The way depends on metric types

2. Fire an event to update metric(s)

3. Show metrics using REST endpoint
#jjug_ccc #ccc_i1 @khasunuma
To denote metrics
@Inject

@Metric

Counter counter;
Same as ...

- Meter

- Histogram

- Timer
@Gauge

int gauge() {

...

return value;

}
and more ...
#jjug_ccc #ccc_i1 @khasunuma
To update metrics
• Counter#inc() or Counter#dec()

• Meter#mark()

• Histogram#update()

• Timer#time() & Timer.Context#close()

• Call annotated method:

@Counted, @Metered, @Timed
#jjug_ccc #ccc_i1 @khasunuma
Example: Counter
@Path("ping")
@ApplicationScoped
public class PingResource {
// Expose metrics as counter
// Metrics is exposed as entity name with package
// (Metric name can be customized)
@Inject
@Metric
private Counter counter;
// Increment the counter each method call
@GET
public String ping() {
counter.inc();
return "pong";
}
}
#jjug_ccc #ccc_i1 @khasunuma
Example: Counter
$ curl http://localhost:8080/app/rest/ping
pong
$ curl -H "Accept: application/json" http://localhost:8080/
metrics
{"vendor":{"system.cpu.load":0.06088091680189212},
"base":{"classloader.totalLoadedClass.count":
15949,"cpu.systemLoadAverage":-1.0,"thread.count":
158,"classloader.currentLoadedClass.count":
15944,"jvm.uptime":80989,"memory.committedNonHeap":
127795200,"gc.PS MarkSweep.count":4,"memory.committedHeap":
415760384,"thread.max.count":160,"gc.PS Scavenge.count":
21,"cpu.availableProcessors":4,"thread.daemon.count":
144,"classloader.totalUnloadedClass.count":
5,"memory.usedNonHeap":113395160,"memory.maxHeap":
477626368,"memory.usedHeap":77223776,"gc.PS MarkSweep.time":
1394,"memory.maxNonHeap":-1,"gc.PS Scavenge.time":325}
"application":{"com.example.app.PingResource.counter":1}}
#jjug_ccc #ccc_i1 @khasunuma
What's Metrics?
• New feature of MicroProfile 1.2+

• API for expose metrics value

• Using REST for polyglot environment

• Built on JAX-RS and CDI

• Simple, flexible and generic
#jjug_ccc #ccc_i1 @khasunuma

More Related Content

PDF
How to adapt MicroProfile API for generic Web applications
Kenji HASUNUMA
 
PDF
Introduction to MicroProfile Metrics
Kenji HASUNUMA
 
PDF
Introduction to JCA and MDB
Kenji HASUNUMA
 
PPTX
Stored procedure in Mule
Khasim Saheb
 
PPTX
Mule new jdbc component
Anirban Sen Chowdhary
 
PPT
Anypoint data gateway
Praneethchampion
 
PPT
Mule anypoint data gateway
D.Rajesh Kumar
 
PPTX
Mule soa
Son Nguyen
 
How to adapt MicroProfile API for generic Web applications
Kenji HASUNUMA
 
Introduction to MicroProfile Metrics
Kenji HASUNUMA
 
Introduction to JCA and MDB
Kenji HASUNUMA
 
Stored procedure in Mule
Khasim Saheb
 
Mule new jdbc component
Anirban Sen Chowdhary
 
Anypoint data gateway
Praneethchampion
 
Mule anypoint data gateway
D.Rajesh Kumar
 
Mule soa
Son Nguyen
 

What's hot (20)

PPT
Overview of Mule
mdfkhan625
 
PPTX
Mule jdbc
Rajarajan Sadhasivam
 
PPT
Identifying Web Servers: A First-look Into the Future of Web Server Fingerpri...
Jeremiah Grossman
 
PPTX
Anypoint connector dev kit
Son Nguyen
 
PPTX
Connecting to external_application
Rajarajan Sadhasivam
 
PPTX
Mule Microsoft Service Bus
Ankush Sharma
 
PDF
Apache ActiveMQ
Srushti Patel
 
PPTX
Mule jms
Rajarajan Sadhasivam
 
PPTX
Calling database with groovy in mule
Anirban Sen Chowdhary
 
PPTX
MuleSoft ESB Composite Source
akashdprajapati
 
PPTX
For each component in mule demo
Sudha Ch
 
PPTX
Mule java part-1
Ravinder Singh
 
PPT
Mule overview-ppt
Prabhat gangwar
 
PPTX
Mule LDAP Connector
Ankush Sharma
 
PPTX
Mule accessing multiple database in parallel
Anirban Sen Chowdhary
 
PPTX
Mule: Java Transformer
Sulthony Hartanto
 
PPTX
Mule rabbitmq
Praneethchampion
 
PPT
Anypoint data gateway
Khan625
 
PPTX
Database component in mule
Rajkattamuri
 
PPTX
Mule soa
Khasim Saheb
 
Overview of Mule
mdfkhan625
 
Identifying Web Servers: A First-look Into the Future of Web Server Fingerpri...
Jeremiah Grossman
 
Anypoint connector dev kit
Son Nguyen
 
Connecting to external_application
Rajarajan Sadhasivam
 
Mule Microsoft Service Bus
Ankush Sharma
 
Apache ActiveMQ
Srushti Patel
 
Calling database with groovy in mule
Anirban Sen Chowdhary
 
MuleSoft ESB Composite Source
akashdprajapati
 
For each component in mule demo
Sudha Ch
 
Mule java part-1
Ravinder Singh
 
Mule overview-ppt
Prabhat gangwar
 
Mule LDAP Connector
Ankush Sharma
 
Mule accessing multiple database in parallel
Anirban Sen Chowdhary
 
Mule: Java Transformer
Sulthony Hartanto
 
Mule rabbitmq
Praneethchampion
 
Anypoint data gateway
Khan625
 
Database component in mule
Rajkattamuri
 
Mule soa
Khasim Saheb
 
Ad

Similar to Introduction to MicroProfile Metrics (20)

PPTX
Performance eng prakash.sahu
Dr. Prakash Sahu
 
PDF
Performance Metrics and Ontology for Describing Performance Data of Grid Work...
Hong-Linh Truong
 
PDF
Performance Metrics and Ontology for Describing Performance Data of Grid Work...
Hong-Linh Truong
 
PDF
A Practical Deep Dive into Observability of Streaming Applications with Kosta...
HostedbyConfluent
 
PDF
Microservices @ Work - A Practice Report of Developing Microservices
QAware GmbH
 
PDF
Monitoring with Prometheus
Richard Langlois P. Eng.
 
PDF
observability pre-release: using prometheus to test and fix new software
Sneha Inguva
 
PPTX
How to Monitor Application Performance in a Container-Based World
Ken Owens
 
PDF
Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...
Tony Erwin
 
PDF
Taking your machine learning workflow to the next level using Scikit-Learn Pi...
Philip Goddard
 
PDF
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
PDF
Monitoring und Metriken im Wunderland
D
 
PDF
IBM MQ - Monitoring and Managing Hybrid Messaging Environments
MarkTaylorIBM
 
PDF
MIIMETIQ - M2M framework
Oriol Rius
 
PPTX
Tooling for Machine Learning: AWS Products, Open Source Tools, and DevOps Pra...
SQUADEX
 
PDF
Profiling Mondrian MDX Requests in a Production Environment
Raimonds Simanovskis
 
PDF
stackconf 2023 | How to reduce expenses on monitoring with VictoriaMetrics by...
NETWAYS
 
PPTX
Cloudify workshop at CCCEU 2014
Uri Cohen
 
PPTX
Geek Sync | Top Metrics to Monitor in Your MySQL Databases
IDERA Software
 
PDF
How to reduce expenses on monitoring
RomanKhavronenko
 
Performance eng prakash.sahu
Dr. Prakash Sahu
 
Performance Metrics and Ontology for Describing Performance Data of Grid Work...
Hong-Linh Truong
 
Performance Metrics and Ontology for Describing Performance Data of Grid Work...
Hong-Linh Truong
 
A Practical Deep Dive into Observability of Streaming Applications with Kosta...
HostedbyConfluent
 
Microservices @ Work - A Practice Report of Developing Microservices
QAware GmbH
 
Monitoring with Prometheus
Richard Langlois P. Eng.
 
observability pre-release: using prometheus to test and fix new software
Sneha Inguva
 
How to Monitor Application Performance in a Container-Based World
Ken Owens
 
Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...
Tony Erwin
 
Taking your machine learning workflow to the next level using Scikit-Learn Pi...
Philip Goddard
 
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Monitoring und Metriken im Wunderland
D
 
IBM MQ - Monitoring and Managing Hybrid Messaging Environments
MarkTaylorIBM
 
MIIMETIQ - M2M framework
Oriol Rius
 
Tooling for Machine Learning: AWS Products, Open Source Tools, and DevOps Pra...
SQUADEX
 
Profiling Mondrian MDX Requests in a Production Environment
Raimonds Simanovskis
 
stackconf 2023 | How to reduce expenses on monitoring with VictoriaMetrics by...
NETWAYS
 
Cloudify workshop at CCCEU 2014
Uri Cohen
 
Geek Sync | Top Metrics to Monitor in Your MySQL Databases
IDERA Software
 
How to reduce expenses on monitoring
RomanKhavronenko
 
Ad

More from Kenji HASUNUMA (14)

PDF
Life of our small product
Kenji HASUNUMA
 
PDF
Jakarta EE: The First Parts
Kenji HASUNUMA
 
PDF
Introduction to JCA and MDB
Kenji HASUNUMA
 
PDF
Basic method for Java EE Web Profile
Kenji HASUNUMA
 
PDF
Introduction to JavaFX Dialogs
Kenji HASUNUMA
 
PDF
Brand New Date and Time API
Kenji HASUNUMA
 
PDF
Virtualization Fundamental
Kenji HASUNUMA
 
PDF
JLS Myths - If-then-else statement -
Kenji HASUNUMA
 
PDF
Introduction to Date and Time API 4
Kenji HASUNUMA
 
PDF
Fundamental Java
Kenji HASUNUMA
 
PDF
Collections Framework Beginners Guide 2
Kenji HASUNUMA
 
PDF
Introduction to Date and Time API 3
Kenji HASUNUMA
 
PDF
Introduction to Date and Time API 2
Kenji HASUNUMA
 
PDF
Introduction to Date and Time API
Kenji HASUNUMA
 
Life of our small product
Kenji HASUNUMA
 
Jakarta EE: The First Parts
Kenji HASUNUMA
 
Introduction to JCA and MDB
Kenji HASUNUMA
 
Basic method for Java EE Web Profile
Kenji HASUNUMA
 
Introduction to JavaFX Dialogs
Kenji HASUNUMA
 
Brand New Date and Time API
Kenji HASUNUMA
 
Virtualization Fundamental
Kenji HASUNUMA
 
JLS Myths - If-then-else statement -
Kenji HASUNUMA
 
Introduction to Date and Time API 4
Kenji HASUNUMA
 
Fundamental Java
Kenji HASUNUMA
 
Collections Framework Beginners Guide 2
Kenji HASUNUMA
 
Introduction to Date and Time API 3
Kenji HASUNUMA
 
Introduction to Date and Time API 2
Kenji HASUNUMA
 
Introduction to Date and Time API
Kenji HASUNUMA
 

Recently uploaded (20)

PPTX
Presentation about variables and constant.pptx
kr2589474
 
PPTX
oapresentation.pptx
mehatdhavalrajubhai
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PDF
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Presentation about variables and constant.pptx
kr2589474
 
oapresentation.pptx
mehatdhavalrajubhai
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 

Introduction to MicroProfile Metrics

  • 1. Introduction to MicroProfile Metrics HASUNUMA Kenji GlassFish Users Group Japan [email protected] Twitter: @khasunuma #jjug_ccc #ccc_i1
  • 2. Why not JMX? • JXM/RMI is not easy to deal with • Integration with non-Java is too hard • Microservices may include 
 Java and non-Java environments -> REST based Metrics API #jjug_ccc #ccc_i1 @khasunuma
  • 3. MicroProfie Metrics • Included MicroProfile 1.2 or later • Built on JAX-RS and CDI • Expose system and user metrics • Using generic text format #jjug_ccc #ccc_i1 @khasunuma
  • 4. Key features • REST endpoint • Registry -- i.e. Scope
 Base, Vendor and Application • Format • Prometheus text format: text/plain • JSON format: application/json #jjug_ccc #ccc_i1 @khasunuma
  • 5. REST endpoint • /metrics by default
 e.g. http://localhost:8080/metrics • With Registry (see later) • /metrics/base • /metrics/vendor • /metrics/application #jjug_ccc #ccc_i1 @khasunuma
  • 6. Registry Store of metrics values: • Base -- JVM metrics, Required • Typically obtained from MBean • Vendor -- Vendor specific metrics • Application -- User metrics #jjug_ccc #ccc_i1 @khasunuma
  • 7. Format (Prometheus) # TYPE base:cpu_system_load_average gauge # HELP base:cpu_system_load_average Displays... base:cpu_system_load_average -1.0 # TYPE base:thread_count counter # HELP base:thread_count Displays... base:thread_count 90 # TYPE base:classloader_current_loaded_class_count counter # HELP base:classloader_current_loaded_class_count Displays... base:classloader_current_loaded_class_count 11150 # TYPE base:classloader_total_loaded_class_count counter # HELP base:classloader_total_loaded_class_count Displays... base:classloader_total_loaded_class_count 11193 # TYPE vendor:system_cpu_load gauge # HELP vendor:system_cpu_load Display... vendor:system_cpu_load 0.1491192437579042 #jjug_ccc #ccc_i1 @khasunuma
  • 8. Format (JSON) { "base": { "cpu.systemLoadAverage": -1, "thread.count": 90, "classloader.currentLoadedClass.count": 11150, "classloader.totalLoadedClass.count": 11193, }, "vendor": {"system.cpu.load": 0.1491192437579042} } #jjug_ccc #ccc_i1 @khasunuma
  • 10. Complex Metrics Meter Histogram Timer #jjug_ccc #ccc_i1 @khasunuma
  • 11. How to expose metrics 1. Denote metric(s) as field, method, constructor, parameter or class • The way depends on metric types 2. Fire an event to update metric(s) 3. Show metrics using REST endpoint #jjug_ccc #ccc_i1 @khasunuma
  • 12. To denote metrics @Inject @Metric Counter counter; Same as ... - Meter - Histogram - Timer @Gauge int gauge() { ... return value; } and more ... #jjug_ccc #ccc_i1 @khasunuma
  • 13. To update metrics • Counter#inc() or Counter#dec() • Meter#mark() • Histogram#update() • Timer#time() & Timer.Context#close() • Call annotated method:
 @Counted, @Metered, @Timed #jjug_ccc #ccc_i1 @khasunuma
  • 14. Example: Counter @Path("ping") @ApplicationScoped public class PingResource { // Expose metrics as counter // Metrics is exposed as entity name with package // (Metric name can be customized) @Inject @Metric private Counter counter; // Increment the counter each method call @GET public String ping() { counter.inc(); return "pong"; } } #jjug_ccc #ccc_i1 @khasunuma
  • 15. Example: Counter $ curl http://localhost:8080/app/rest/ping pong $ curl -H "Accept: application/json" http://localhost:8080/ metrics {"vendor":{"system.cpu.load":0.06088091680189212}, "base":{"classloader.totalLoadedClass.count": 15949,"cpu.systemLoadAverage":-1.0,"thread.count": 158,"classloader.currentLoadedClass.count": 15944,"jvm.uptime":80989,"memory.committedNonHeap": 127795200,"gc.PS MarkSweep.count":4,"memory.committedHeap": 415760384,"thread.max.count":160,"gc.PS Scavenge.count": 21,"cpu.availableProcessors":4,"thread.daemon.count": 144,"classloader.totalUnloadedClass.count": 5,"memory.usedNonHeap":113395160,"memory.maxHeap": 477626368,"memory.usedHeap":77223776,"gc.PS MarkSweep.time": 1394,"memory.maxNonHeap":-1,"gc.PS Scavenge.time":325} "application":{"com.example.app.PingResource.counter":1}} #jjug_ccc #ccc_i1 @khasunuma
  • 16. What's Metrics? • New feature of MicroProfile 1.2+ • API for expose metrics value • Using REST for polyglot environment • Built on JAX-RS and CDI • Simple, flexible and generic #jjug_ccc #ccc_i1 @khasunuma