Skip to main content

Your submission was sent successfully! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates from Canonical and upcoming events where you can meet our team.Close

Thank you for contacting us. A member of our team will be in touch shortly. Close

Note: All commands are written for juju >= v3.1

If you’re using juju 2.9, check the juju 3.0 Release Notes.

Enable profiling with Parca

This guide contains the steps to enable profiling with Parca for your PostgreSQL application.

Summary


Prerequisites

Do not skip this section if you are deploying PostgreSQL in an LXD model or if your base is [email protected].

This guide assumes you already have a juju model with Charmed PostgreSQL deployed.

See: How to deploy PostgreSQL

In order for your Charmed PostgreSQL deployment to be correctly set up for integration with Parca, there are two important considerations:

LXD virtualization type

If you are deploying Charmed PostgreSQL in a LXD model, you will need to ensure that LXD’s virtualization type is set to virtual-machine for the Juju application.

This is because LXD does not allow /sys/kernel/tracing to be mounted in a system container (even in privileged mode) due to security isolation concerns.

To ensure that a virtual machine is used instead of a system container, you would need to add constraints, for example:

juju deploy postgresql --constraints="virt-type=virtual-machine"`. 

Base (Ubuntu version)

If your base is [email protected], you will need to ensure that your are using the generic flavor of Linux.

See the output of uname -r to confirm.

If you do not have the generic flavor, you can enable it on a unit to be profiled as follows:

juju ssh postgresql/0 bash
sudo apt-get update && sudo apt-get install linux-image-virtual
sudo apt-get autopurge linux-image-kvm

If your application is deployed in an LXD model, run the following command:

rm /etc/default/grub.d/40-force-partuuid.cfg

Open the /etc/default/grub file with your editor of choice and replace the line that starts with GRUB_DEFAULT= with:

release=$(linux-version list | grep -e '-generic$' | sort -V | tail -n1)
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux $release"

Exit out of the /etc/default/grub file, update GRUB, and reboot:

sudo update-grub
sudo reboot

Nothing needs to be done if the base is [email protected], which already loads the kernel symbol table for debugging by default.

Set up the Parca backend

There are two potential backends:

Charmed Parca K8s

This section goes through the steps for enabling profiling with Charmed Parca K8s as the backend.

1. Deploy cos-lite and parca-k8s

Refer to Getting started on MicroK8s and deploy the cos-lite bundle from the latest/edge track in a Kubernetes environment.

Then, refer to Deploy Charmed Parca on top of COS-lite to deploy Charmed Parca K8s in the same model as the cos-lite bundle.

2. Offer interfaces

Offer interfaces for cross-model integrations:

juju offer <parca_k8s_application_name>:parca-store-endpoint

3. Deploy and integrate parca-agent with postgresql

Switch to the model containing the Charmed PostgreSQL deployment, deploy Charmed Parca Agent, and integrate it with Charmed PostgreSQL:

juju switch <machine_controller_name>:<postgresql_model_name>

juju deploy parca-agent --channel latest/edge
juju integrate postgresql parca-agent

4. Integrate parca-agent with parca-k8s

Consume the parca offer from Step 2 and integrate with them:

juju find-offers <k8s_controller_name>:

:exclamation: Do not miss the colon “:” in the command above.

Below is a sample output where k8s is the K8s controller name and cos is the model where cos-lite and parca-k8s are deployed:

Store  URL                            Access  Interfaces
k8s    admin/cos.parca                admin   parca_store:parca-store-endpoint

Next, consume this offer so that is reachable from the current machine model:

juju consume k8s:admin/cos.parca

Finally, relate Charmed Parca Agent with the consumed offer endpoint:

juju integrate parca-agent parca 

Polar Signals Cloud

This section goes through the steps for enabling profiling with Polar Signals Cloud (PSC) as the backend.

With PSC, cos-lite and parca-k8s are not required. This section goes through the recommended setup, where polar-signals-cloud-integrator is deployed in the same model as postgresql, and parca-agent is used to relay traffic to PSC.

If you would like to use parca-k8s to relay traffic to PSC instead, refer to Steps 1 and 2 in the Charmed Parca K8s section.

1. Deploy and integrate parca-agent with postgresql

In the machine model where PostgreSQL is deployed, deploy parca-agent and integrate it with postgresql:

juju deploy parca-agent --channel latest/edge
juju integrate postgresql parca-agent

2. Integrate parca-agent with polar-signals-cloud-integrator

Follow the guide How to integrate with Polar Signals Cloud.

View profiles

After the backend setup is complete, the profiles for the machines where the PostgreSQL units are running will be accessible from the Parca web interface.

If you are running Charmed Parca K8s, you can also access the link for Parca’s web interface from COS catalogue (juju run traefik/0 show-proxied-endpoints in the K8s model where cos-lite is deployed).

Furthermore, if you have cos-lite deployed, you can use Grafana to explore profiles under the Explore section with parca-k8s as the data source.

Last updated a day ago. Help improve this document in the forum.