►
From YouTube: How to instrument Prometheus metrics in GitLab
Description
In this video Reuben, a Backend Developer at Monitor, is walking us through the process of instrumenting an application to track Prometheus metrics in GitLab.
B
B
B
B
B
Okay,
so
while
this
downloads
the
library
and
saves
it
into
the
filing
we'll
move
to
the
next
step,
so
the
response
time
is
the
other
library
that
we
also
need
here,
because
it's
just
it's
just
to
make
a
evoke
easier.
It
makes
it
easy
to
check
the
how
long
the
server
took
to
respond
on
a
particular
path.
B
C
B
Okay,
so
this
is
the
Prometheus
client
that
we
just
downloaded
and
saved.
Then
Prometheus
has
these
data
structures
which
you
can
use
for
matrix
gathering,
so
they
have
the
counter
the
gauge,
the
summary
histogram.
So
here
we'll
use
the
summary-
and
this
is
the
register
value
register
a
metric,
so
I'll
show
how
it's
used.
B
B
B
As
you
can
see,
the
labels
also
added,
so
you
have
the
method,
path
and
status
which
are
taken
from
the
request
method,
URL,
which
is
the
path
and
the
status
code
and
the
time
which
is
provided
by
the
response
time.
Library
is
an
observation
which
is
added
to
that
summary.
I
hope,
I,
hope,
I'm,
making
sense
here.
B
A
B
So
usually
the
best
place
is
to
look
at
the
description
of
the
library
that
you
think
so.
For
example,
I
used
the
node.js
library,
usually
in
the
readme.
There
is
examples
for
how
we
can
use
that
library,
so
here
here,
for
example,
it's
showing
you
how
to
use
it
so
we've
done
something
similar
require
a
prom
client
require
from
client
collect
default,
metrics.
D
B
A
B
A
B
B
B
B
B
C
B
The
only
metric
that
we've
added
is
respond.
Okay
responses,
m/s
that
you
can
see
right
at
the
top
canopy
responses
m/s,
so
right
now
there
is
nothing
because
we've
not
made
any
requests
to
the
base
route,
which
is
this
after
adding
the
metrics.
So
if
you
refresh
also
Italy
okay,
now
we
have
metrics
here,
so
you
can
add
more
by
simply
refreshing.
This.
B
B
All
right,
so
one
way
is
to
add
this
file
into
your
repository
with
whatever
values
you
want
and
when
deploying
gitlab
will
pick
up
the
values
from
here
and
use
them
so
we'll
try
we'll
try
this
first
or
I
think
it'll
be
better
to
try
this
one
okay.
So
the
other
method
is
to
add
this
variable
into
your
CI
CD
variables
and
add
the
appropriate
value.
So
the
value
I
think
is
not
well
documented.
The
kind
of
value
that
you
need
to
add
in
order
to
have
Prometheus
collect
metrics
from
your
application.
B
B
You
put
it
in
a
port
forward,
come
on
so
here
you
have
cube
serial
port
forward,
then
the
pod
name
and
the
port
that
you
want
to
access
on
your
local
system
:,
the
port
on
which
Prometheus
is
served
on
the
remote
system,
ankit
lab,
managed
apps
is
simply
the
namespace.
So
here
you
can
see
that
from
here,
server
is
available
under
the
get
lab
manage
apps
namespace.
So
that's
why
the
iron
flag
is
required.
B
B
B
A
E
B
E
B
B
B
So,
though,
you
had
asked
about
how
how
someone
knows
the
what
code
to
use
to
collect
these
metrics,
so
it
can
get
complicated,
because,
even
though
you
can
find
out
the
basics
of
how
to
collect
the
metrics
from
the
library
that
you
are
using,
sometimes
it
can
get
complicated
to
actually
collect
the
value
that
you
are
interested
in.
So,
for
example,
here
we
are
interested
in
a
simple
metric
which
shows
how
long
a
particular
path
the
server
takes
to
respond
right.
B
B
B
B
B
B
B
B
E
B
D
D
A
B
D
B
C
B
Okay,
so
if
you
look
at
the
the
UI,
it
has
a
button
for
generating
errors
which
generates
entry
errors,
and
these
are
just
links,
static
links.
So
even
this
button
does
not
hit
the
back
end.
It
does
not
hit
the
server.
It
generates
errors
right
on
the
front
end
and
sends
it
to
century.
So
the
only
route
that
we
have
in
this
application
is
this:
the
base
route,
the
route
route.
So
what
I've
done
here
is
I've
added
a
metric
to
calculate
the
response
time
for
that
route,
so
this
will
probably
be
familiar
to
you.
B
B
This
is
simply
to
calculate
the
response
time
for
the
route
route
and
we
told
the
server
to
use
this
response
counters
this
one
counters.
Okay,
so
that's
it.
The
application
is
a
simple
application
to
generates
entry
errors
with
only
one
route,
and
we
are
in
this
demo,
we've
added
a
metric
to
track
the
response
time
for
that
one
Rock
I
hope
this
made
things
clearer,
yeah.
A
B
B
A
A
A
D
B
So
another
common
thing
that
is
done
when
naming
matrix
is
that
you
add
the
unit
as
a
suffix
to
the
metric
name,
so
that
it's
easy
to
see
what
the
unit
of
the
value
is,
because
otherwise,
when
you
are
looking
at
something
like
this,
you
don't
really
know
what
unit
a
value
has.
So
here
it
has
a
milli
second
unit
and
as
I
was
saying,
you
have
percentiles
here,
then
this
is
the
sum
of
all
these
values,
and
this
is
a
count
of
the
number
of
observations
that
have
been
made.
B
B
B
B
B
B
B
B
A
E
B
B
B
B
B
A
B
B
So
this
should
increment
the
response
counter
every
time,
there's
a
request
to
any
of
the
routes.
Ideally,
you
would
add
a
label
of
at
least
the
URL
so
that
you
can
differentiate,
otherwise
it
will
increment
the
same
counter
for
any
request.
So,
for
example,
if
you
have
two
API
API
a
and
API
B,
it
will
increment
the
same
counter.
Each
time
you
get
either
API,
while,
if
you
add
a
label
with
the
URL,
it
will
create
a
different
counter
for
each
different
possible
label
value,
which
is
what
we
usually
want
so
yeah.