1

00:00:00.05 --> 00:00:02.00

- [Instructor] In Spring Boot 2.0,



2

00:00:02.00 --> 00:00:04.08

the entire metric system changed



3

00:00:04.08 --> 00:00:06.09

from the Dropwizard

metric system that we saw



4

00:00:06.09 --> 00:00:09.06

with Spring Boot 1.5 to now Micrometer.



5

00:00:09.06 --> 00:00:11.07

And this was a change that I feel



6

00:00:11.07 --> 00:00:13.06

not only improved Spring Boot,



7

00:00:13.06 --> 00:00:16.00

but improves the exporting

of those metrics.



8

00:00:16.00 --> 00:00:18.07

Micrometer is a great platform for that.



9

00:00:18.07 --> 00:00:20.05

Let's talk a little bit

about what Micrometer is.



10

00:00:20.05 --> 00:00:23.03

So, at its core, it's an instrumentation



11

00:00:23.03 --> 00:00:25.06

library for the JVM.



12

00:00:25.06 --> 00:00:27.00

But more important than that,



13

00:00:27.00 --> 00:00:29.02

from an operations perspective,



14

00:00:29.02 --> 00:00:31.04

besides being this core instrumentation,



15

00:00:31.04 --> 00:00:34.00

it also gives us third-party monitoring



16

00:00:34.00 --> 00:00:36.07

system support through modules.



17

00:00:36.07 --> 00:00:40.00

So, if you're using tools

like Prometheus or Datadog,



18

00:00:40.00 --> 00:00:42.08

you can export your metrics very easily



19

00:00:42.08 --> 00:00:45.09

out of a Spring Boot

application into those tools



20

00:00:45.09 --> 00:00:48.03

through the use of these modules



21

00:00:48.03 --> 00:00:50.09

that tie into the core Micrometer.



22

00:00:50.09 --> 00:00:52.05

What's even better is the way



23

00:00:52.05 --> 00:00:55.03

that Micrometer is handled in Spring Boot.



24

00:00:55.03 --> 00:00:58.03

If you have Actuator

already turned on which,



25

00:00:58.03 --> 00:00:59.09

let's be honest, you should be doing that



26

00:00:59.09 --> 00:01:01.08

with Spring Boot applications,



27

00:01:01.08 --> 00:01:03.03

you're going to get Micrometer for free.



28

00:01:03.03 --> 00:01:06.07

It just comes along with

the actuator plug in.



29

00:01:06.07 --> 00:01:09.02

In addition to that, it's

going to be auto-configured.



30

00:01:09.02 --> 00:01:12.05

You are going to get a

Composite MeterRegistry



31

00:01:12.05 --> 00:01:14.08

by default out of the box.



32

00:01:14.08 --> 00:01:18.09

In addition, if you add, let's

say the Datadog or Prometheus



33

00:01:18.09 --> 00:01:22.09

or any of the other tools that

are supported by Micrometer,



34

00:01:22.09 --> 00:01:25.01

if you add that to the Classpath,



35

00:01:25.01 --> 00:01:26.05

Spring Boot is going to look at it,



36

00:01:26.05 --> 00:01:29.08

notice that it's there and

auto-configure what you need



37

00:01:29.08 --> 00:01:32.03

in order to use configuration properties



38

00:01:32.03 --> 00:01:36.00

to ploy to your instance

of those applications



39

00:01:36.00 --> 00:01:39.04

that are going to do that

metrics aggregation for you.



40

00:01:39.04 --> 00:01:42.09

Now, this MeterRegistry is

injected into your bean classes



41

00:01:42.09 --> 00:01:46.09

when you want to tie

into a custom registry.



42

00:01:46.09 --> 00:01:50.01

You can create gauges and

counters from that registry



43

00:01:50.01 --> 00:01:53.07

and manipulate them in

your beans as you see fit.



44

00:01:53.07 --> 00:01:56.01

This is really good when

you're trying to keep track



45

00:01:56.01 --> 00:01:59.07

of things like, how many

times does a value change



46

00:01:59.07 --> 00:02:02.06

and if some value that is

critically your operation,



47

00:02:02.06 --> 00:02:06.01

you can leverage that through

a MeterRegistry metric



48

00:02:06.01 --> 00:02:09.04

like a counter, and

then expose that through



49

00:02:09.04 --> 00:02:12.05

the Actuator metrics

endpoint (mumbles) JMX system



50

00:02:12.05 --> 00:02:15.07

or to your metrics

collection like Prometheus.



51

00:02:15.07 --> 00:02:18.08

Now, this are leveraged and

reported based on the metadata



52

00:02:18.08 --> 00:02:22.04

that you have when you

create that gauge or counter.



53

00:02:22.04 --> 00:02:25.06

Again, you can see how to

do all of this information



54

00:02:25.06 --> 00:02:28.02

in my Spring Boot essentials course.



55

00:02:28.02 --> 00:02:30.03

Now, out of the box you

get a lot of preconfigured



56

00:02:30.03 --> 00:02:33.01

metrics as well and this

is where a lot of the value



57

00:02:33.01 --> 00:02:35.08

of this auto-configuration comes from.



58

00:02:35.08 --> 00:02:37.03

Figuring a web application,

you're going to get



59

00:02:37.03 --> 00:02:41.02

metrics from MVC, if its

reactive or in Webflux.



60

00:02:41.02 --> 00:02:44.06

If you're calling other restful endpoints,



61

00:02:44.06 --> 00:02:46.05

you're going to get metrics

around this (mumbles) to be quiet



62

00:02:46.05 --> 00:02:49.01

whether to RestTemplate or WebClient.



63

00:02:49.01 --> 00:02:51.00

All of that's going to come for

free and they're going to be



64

00:02:51.00 --> 00:02:53.05

exposed on your metrics endpoint.



65

00:02:53.05 --> 00:02:55.06

You're going to get stuff around Cache,



66

00:02:55.06 --> 00:02:57.09

and DataSource specific information



67

00:02:57.09 --> 00:03:01.03

including Hibernate for

relational databases.



68

00:03:01.03 --> 00:03:04.01

In RabbitMQ metrics, again,

you're going to get them



69

00:03:04.01 --> 00:03:05.05

out of the box for free



70

00:03:05.05 --> 00:03:08.02

if you've got AMQP on your classpath.



71

00:03:08.02 --> 00:03:11.03

Now these metrics endpoint

is based on Actuator,



72

00:03:11.03 --> 00:03:13.07

and they've restructure to

do a little bit (mumbles),



73

00:03:13.07 --> 00:03:16.00

I want to talk about

adherence that has an Actuator



74

00:03:16.00 --> 00:03:18.04

because this is really

where you'll use it.



75

00:03:18.04 --> 00:03:20.08

The Actuator metrics

endpoint is just be a dump



76

00:03:20.08 --> 00:03:23.02

of all the actual raw metrics.



77

00:03:23.02 --> 00:03:26.00

Now they've sub-categorized

the base on the metrics names



78

00:03:26.00 --> 00:03:27.08

so you can dig in deeper.



79

00:03:27.08 --> 00:03:31.08

And this is really designed

for a JMX consumption model,



80

00:03:31.08 --> 00:03:34.09

but it is there in a web

format if you turn it on.



81

00:03:34.09 --> 00:03:36.06

And that's something that you can do



82

00:03:36.06 --> 00:03:39.04

through the configuration

properties for Actuator.



