[MUSIC PLAYING]
YURI GRINSHTEYN: If you use Prometheus
to monitor your services and infrastructure,
you probably have a set of configurations
you've developed over months or years that serve you really
well.
But managing and maintaining them can be a challenge.
Today, I'm going to show you how to migrate your existing
Prometheus setup, including your application monitoring
configurations, to Managed Collection,
and remove the need to manage any part of Prometheus
at scale.
My name is Yuri, and I'm an SRE at Google Cloud.
Welcome back to Engineering for Reliability.
[MUSIC PLAYING]
The Prometheus Operator is a common way
to manage Prometheus deployments in production.
The Operator uses custom resources
to manage the Prometheus server itself.
You then define service monitor resources
to configure how specific services are monitored.
You can certainly use Prometheus Operator with Google Cloud's
Managed Service for Prometheus.
But migrating to Managed Collection
means you won't have to manage any Prometheus
infrastructure at all.
Let's have a look at how to migrate an existing Prometheus
configuration, managed by the operator,
to Managed Collection.
Let's start by reviewing our existing configuration.
We have a Prometheus operator and the Prometheus server
running in the monitoring namespace.
Our app is running in the default namespace.
We can confirm that it's exposing
Prometheus metrics on the slash matrix endpoint
by using port-forward.
And there we are.
We instructed Prometheus operator
to monitor our app by using a service monitor resource.
Here's our configuration.
And here it is deployed on the server.
We can use port forwarding to confirm
that Prometheus has our app as a target
and that it is ingesting our app's metrics.
At this point, we're ready to migrate to Managed Collection.
We're going to enable Managed Collection in the Cloud console
here.
You can also do this with a gcloud command.
If you're now running a GKE, you can also use kubectl.
Once that's done, we need to instruct
Prometheus to monitor our app.
To do this, we'll use a pod monitoring configuration.
Managed collection uses pod monitoring and resources
instead of service monitors to guarantee
that each collector only scrapes targets
on the nodes running now.
This guarantees scalability by minimizing
intracluster traffic.
The configuration itself is similar to the service monitor
resource, but you may need to change some fields.
We'll link to the documentation in the episode notes
so you can be sure to get this right.
Let's apply this configuration.
At this point, we can confirm that our application metrics
are being ingested by querying them using PromQL
and in Metrics Explorer.
And that's how you can migrate an existing Prometheus
configuration to Google's Managed Prometheus collection.
Thanks so much for watching today.
We learned how to migrate an existing Prometheus operator
deployment to Google's managed Prometheus collection
and how to use a pod monitoring resource to ensure
that your service is monitored.
I hope this helps you keep your services reliable and users
happy.
If you have any other reliability or observability
topic you'd like me to cover, please comment below.
Don't forget to like and subscribe to never miss out
on more Engineering for Reliability with Google Cloud.
See you soon.