|
| 1 | +[note] |
| 2 | +**Note**: All commands are written for `juju >= v3.1` |
| 3 | + |
| 4 | +If you're using `juju 2.9`, check the [`juju 3.0` Release Notes](https://juju.is/docs/juju/roadmap#heading--juju-3-0-0---22-oct-2022). |
| 5 | +[/note] |
| 6 | + |
| 7 | +Please read this doc in its entirety before deploying anything. In particular, please decide what Parca backend you would like to use. You can either deploy Charmed Parca K8s or use Polar Signals Cloud. |
| 8 | + |
| 9 | +# Enable Profiling |
| 10 | + |
| 11 | +This guide contains the steps to enable profiling with [Parca](https://www.parca.dev/docs/overview/) for your PostgreSQL application. |
| 12 | + |
| 13 | +To summarize: |
| 14 | +* [Deploy Charmed PostgreSQL](#heading--deploy) |
| 15 | +* [Optional: Deploy the COS-lite bundle and Charmed Parca K8s + Offer interfaces for cross-model integrations](#heading--cos) |
| 16 | +* [Deploy Charmed Parca Agent and integrate with Charmed PostgreSQL](#heading--parcaagent) |
| 17 | +* [Integrate Charmed Parca Agent with the Parca Backend](#heading--parcabackend) |
| 18 | +* [View PostgreSQL machine profiles](#heading--view) |
| 19 | + |
| 20 | +<a href="#heading--deploy"><h2 id="heading--deploy"> Deploy Charmed PostgreSQL </h2></a> |
| 21 | + |
| 22 | +See [How to scale units](https://discourse.charmhub.io/t/charmed-postgresql-how-to-scale-units/9689) for reference of how you can deploy Charmed PostgreSQL in a machine model. |
| 23 | + |
| 24 | +[note] |
| 25 | +**Note**: 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. |
| 26 | + |
| 27 | +To ensure that a virtual machine is used instead of a system container, you would need to add constraints, e.g. `juju deploy postgresql --constraints="virt-type=virtual-machine"`. |
| 28 | +[/note] |
| 29 | + |
| 30 | +[note] |
| 31 | +**Note:** Please note the base of the Charmed PostgreSQL application. |
| 32 | + |
| 33 | +Nothing needs to be done if the base is `ubuntu@24.04` which already loads the kernel symbol table for debugging by default. |
| 34 | + |
| 35 | +If your base is `ubuntu@22.04`, you will need to ensure that your are using the `generic` flavor (see output of `uname -r` to confirm) of Linux. If you do not have the `generic` flavor, you can enable it on a unit to be profiled as follows: |
| 36 | + |
| 37 | +``` |
| 38 | +juju ssh postgresql/0 bash |
| 39 | +sudo apt-get update && sudo apt-get install linux-image-virtual |
| 40 | +sudo apt-get autopurge linux-image-kvm |
| 41 | +# only run the following if your application is deployed in an LXD model |
| 42 | +# rm /etc/default/grub.d/40-force-partuuid.cfg |
| 43 | +
|
| 44 | +# Then open the /etc/default/grub file and replace the line that starts with GRUB_DEFAULT= with: |
| 45 | +release=$(linux-version list | grep -e '-generic$' | sort -V | tail -n1) |
| 46 | +GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux $release" |
| 47 | +# Exit out of the /etc/default/grub file |
| 48 | +
|
| 49 | +sudo update-grub |
| 50 | +sudo reboot |
| 51 | +``` |
| 52 | +[/note] |
| 53 | + |
| 54 | +<a href="#heading--cos"><h2 id="heading--cos"> Optional: Deploy the COS-lite bundle and Charmed Parca K8s + Offer interfaces for cross-model integrations </h2></a> |
| 55 | + |
| 56 | +Please refer to [Getting started on MicroK8s](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s) and deploy the 'cos-lite' bundle from the `latest/edge` track in a Kubernetes environment. |
| 57 | + |
| 58 | +Then, please refer to [Deploy Charmed Parca on top of COS-lite](https://discourse.charmhub.io/t/how-to-deploy-charmed-parca-on-top-of-cos-lite/16579) to deploy Charmed Parca K8s in the same model as the 'cos-lite' bundle. |
| 59 | + |
| 60 | +Next, offer interfaces for cross-model integrations from the model where Charmed PostgreSQL is deployed. |
| 61 | + |
| 62 | +``` |
| 63 | +juju offer <parca_k8s_application_name>:parca-store-endpoint |
| 64 | +``` |
| 65 | + |
| 66 | +<a href="#heading--parcaagent"><h2 id="heading--parcaagent"> Deploy Charmed Parca Agent and Integrate with Charmed PostgreSQL </h2></a> |
| 67 | + |
| 68 | +Switch to the Charmed PostgreSQL model, then deploy Charmed Parca Agent and relate with Charmed PostgreSQL: |
| 69 | + |
| 70 | +``` |
| 71 | +juju switch <machine_controller_name>:<postgresql_model_name> |
| 72 | +
|
| 73 | +juju deploy parca-agent --channel latest/edge |
| 74 | +juju integrate postgresql parca-agent |
| 75 | +``` |
| 76 | + |
| 77 | +<a href="#heading--parcabackend"><h2 id="heading--parcabackend"> Integrate Charmed Parca Agent with the Parca backend </h2></a> |
| 78 | + |
| 79 | +### Integrating with Parca K8s in a K8s model |
| 80 | + |
| 81 | +If you deployed Charmed Parca K8s in a Kubernetes model, consume the parca offer from a previous section and integrate with them: |
| 82 | + |
| 83 | +``` |
| 84 | +juju switch <machine_controller_name>:<postgresql_model_name> |
| 85 | +
|
| 86 | +juju find-offers <k8s_controller_name>: |
| 87 | +``` |
| 88 | + |
| 89 | +> :exclamatin: Do not miss the ":" in the command above. |
| 90 | +
|
| 91 | +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: |
| 92 | + |
| 93 | +``` |
| 94 | +Store URL Access Interfaces |
| 95 | +k8s admin/cos.parca admin parca_store:parca-store-endpoint |
| 96 | +``` |
| 97 | + |
| 98 | +Next, consume this offer so that is reachable from the current model. Then relate Charmed Parca Agent with the consumed offer endpoint: |
| 99 | + |
| 100 | +``` |
| 101 | +juju consume k8s:admin/cos.parca |
| 102 | +
|
| 103 | +juju integrate parca-agent parca |
| 104 | +``` |
| 105 | + |
| 106 | +### Integrating with Polar Signals Cloud |
| 107 | + |
| 108 | +Please refer to [How to integrate with Polar Signals Cloud](https://discourse.charmhub.io/t/charmed-parca-docs-how-to-integrate-with-polar-signals-cloud/16559). We recommend configuring `parca-agent` to forward profiles to the cloud instance instead of configuring `parca-k8s` server to forward profiles to the cloud instance. This would entail deploying the `polar-signals-cloud-integrator` in the same model as Charmed PostgreSQL. |
| 109 | + |
| 110 | +<a href="#heading--view"><h2 id="heading--view"> View Profiles </h2></a> |
| 111 | + |
| 112 | +After this 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). |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +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. |
| 117 | + |
| 118 | + |
0 commit comments