►
From YouTube: Instrument GitLab with Prometheus for Self Monitoring
Description
In this video Reuben, a Backend Developer at Monitor, is walking us through the process of instrumenting GitLab application using Prometheus and displat those metrics in the GitLab Self-Monitoring project
A
B
A
A
A
Okay,
so
so
this
is
the
library
that
github
uses
here.
You
can
see
examples
of
how
to
use
this
library.
Your
counters
are
created
gauge,
histogram,
summary,
okay,
so
so
this
Fork
was
originally
created,
I
think
because
we
needed
a
library
that
could
work
with
multi-process
application
servers
like
unicorn,
so
at
the
top.
If
you
see
it
says
this
funkiest
library
is
a
fork
of
the
Prometheus
ruby
client
that
uses
memory
mapped
files
to
share
metrics
from
multiple
processes.
A
A
B
A
Right
so
I'm
basically
skipping
a
few
steps
here.
Normally
you
would
look
at
you
know
what
you
want
to
measure
and
then
you
would
hunt
down
the
code
that
you
know
that
actually
does
it.
So,
for
example,
here
what
I
thought,
what
I
had
done
was
I
looked
at
the
matrix
dashboard
and
then
followed
the
path
from
there
look
at
the
API,
which
serves
that
then
find
the
code
which
actually
does
what
you
want
to
measure.
So,
for
example,
this
is
the
code
that
solves
the
matrix
dashboard
page
that
we
almost
become
level
so.
A
A
So
now
we
have
a
choice
of
the
four
metric
types.
A
gauge
met,
counter
summary
and
histogram,
so
we
want
to
measure
processing
time
which
can
go
up
or
down.
So
we
can't
use
a
counter
because
counters
are
supposed
to
be
only
something
that
grows.
It
cannot
be
a
value
that
also
decreases
so
a
gauge
is
possible,
but
the
way
you
measure
it
makes
it
difficult
to
use
a
gauge,
because
the
way
pro
meters
works
is
that
an
application
measures
something
and
serves
up
a
matrix
page
and
Prometheus
periodically
scripts
it.
A
So
if
you
use
a
gauge,
you
will
be
measuring
values.
Each
time
a
user
hits
the
dashboard
endpoint,
which
is
you
know
it
can
be
hundreds
of
times
a
second.
Even
so,
what
we
want
is
an
average
over
time.
We
don't
want
from
Ethier's
to
pick
up
one
value
in
a
minute.
We
want
promises
to
pick
up
all
the
values
in
that
minute.
So
what
we
use
is
summary
which,
which
automatically
gives
you
the
count
of
the
number
of
times
that
you've
measured,
something
as
well
as
the
sum.
A
A
So
this
processor
has
one
characteristic
that
if
you
can
see
this
here
so
if
dash
board
does
not
exist,
it
can
return
nil
and
when
it
does
that
it
does
not
actually
do
any
processing.
So
the
amount
of
time
taken
will
be
very
low,
so
just
so
that
we
don't
skew
the
average.
Let's
exclude
that
case
if.
A
According
to
best
practices
for
naming
metrics,
you
should
start
with
the
name
of
the
app
in
which
the
metric
has
been
added.
So
that's
why
I
have
added
gate
lab
at
the
start
and
the
unit
is
usually
at
the
end.
So
in
this
case,
let's
use
milliseconds
and
the
second
parameter
is
the
help
string.
So
it
should
describe
what
the
metric
is
measuring.
A
A
So
you
can
say,
get
lab
metrics
both
stages.
So
this
is
a
very
long
name
and
all
the
stages
are
under
this
namespace,
so
they
will
all
have
the
same
names
so
be
only
interested
in
the
last
one,
which
is
why
we
are
splitting
by
double
colon
and
then
joining
it.
So
when
we
see
the
values
of
the
matrix,
it
will
be
clearer.
B
A
B
Is
an
out-of-the-box
metrics,
the
metrics
that
we've
instrumented
already
in
the
code
and
we
shipped
it
to
our
users,
so
I
guess
the
first
action
that
the
user
that
would
like
to
instrument
gitlab.
The
first
thing
is:
first,
you
should
go
to
the
to
the
documentation.
You
see
if
this
metrics
is
exposed,
I'm,
ready
and
available
yeah.
B
A
A
A
B
A
So
recently
we
added
the
killer
self
monitoring
project
whose
goal
is
to
allow
users
to
be
able
to
monitor
the
gitlab
instance
itself
right
out
the
right
out
of
the
box.
So
they
don't
have
to
do
anything
they'll.
They
can
just
go
to
the
admin
area.
Settings
matrix,
enable
the
self
monitoring
project-
and
you
know
eventually,
we
hope-
to
have
multiple
dashboards
in
the
self
portrait
project
which
show
you
matrix
of
get
lab
itself.
A
B
A
B
A
A
Okay,
so
right
now
we
are
only
interested
in
the
API
requests
to
get
the
actual
dashboard
which
has
completed
successfully.
The
other
things
are
not
working,
because
Prometheus
is
not
running
right
now,
we'll
draw
on
that
later.
So
now
there
should
be
two
metrics
here.
It
should
be,
should
have
run
twice.
A
A
B
A
A
B
A
A
A
A
A
A
B
A
B
A
So
this
value
that
you
can
see
here
is
from
the
service
label
and
currently
it's
showing
the
self
monitoring
both
of
this.
So,
for
example,
if
you,
if
you
open
the
system
dashboard
or
if
you
open
some
custom
dashboard,
you
will
see
those
labels
as
vary
here,.