Parca and Parca Agent as systemd Units
Setting up Parca
You can find interactive version of this tutorial at our Katacoda account. Check it out here.
You can download the latest binary release for your architecture from our releases page.
curl -sL https://raw.githubusercontent.com/parca-dev/parca/main/parca.yaml > parca.yaml curl -sL https://github.com/parca-dev/parca/releases/download/v0.22.0/parca_0.22.0_`uname -s`_`uname -m`.tar.gz | tar xvfz -
Move the binary to a place where we can refer:
mv ./parca /usr/bin
Let's install external dependencies:
apt-get install llvm binutils elfutils
/usr/bin
was selected as an example and used in the subsequent sections of this tutorial.
And let's create a user for Parca:
adduser --system --no-create-home --group parca
Parca runs with an example configuration file by default, that makes Parca to scrape itself.
object_storage:
bucket:
type: "FILESYSTEM"
config:
directory: "/tmp"
scrape_configs:
- job_name: "default"
scrape_interval: "2s"
static_configs:
- targets: ["127.0.0.1:7070"]
mkdir -p /etc/parca && cp editor/parca.yaml /etc/parca/parca.yaml
Now you can run the Parca as a systemd
unit with the following simple configuration:
[Unit]
Description=Parca service
Requires=network-online.target
After=network-online.target
[Service]
User=parca
Group=parca
Restart=on-failure
RestartSec=10
ExecStart=/usr/bin/parca --config-path=/etc/parca/parca.yaml
ExecReload=/bin/kill -HUP $MAINPID
LimitNOFILE=65535
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=parca
[Install]
WantedBy=multi-user.target
To use the configuration, we need to move it a directory that systemd
can load:
cp parca.service /etc/systemd/system/parca.service
And then simply start the unit:
sudo systemctl start parca
This will start the Parca server on port 7070
and configure it to retrieve profiles from itself every 1 second automatically.
Once Parca is running, you can navigate to the web interface on the browser.
Setting up Parca Agent
You can download the latest agent binary release for your architecture from our releases page.
curl -sL https://github.com/parca-dev/parca-agent/releases/download/v0.35.0/parca-agent_0.35.0_`uname -s`_`uname -m`.tar.gz | tar xvfz -
Move the binary to a place where we can refer:
mv ./parca-agent /usr/bin
You can run the Parca Agent as a systemd
unit with the following simple configuration:
[Unit]
Description=Parca Agent
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/bin/parca-agent --http-address=":7071" --node=systemd-test --remote-store-address=localhost:7070 --remote-store-insecure
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=parcaagent
[Install]
WantedBy=multi-user.target
The command in the above configuration targets the Parca server that is presumably running on your system. And it uses the systemd
service discovery to find the cgroups that have been running on your system.
To use the configuration, we need to move it a directory that systemd
can load:
cp parca-agent.service /etc/systemd/system/parca-agent.service
And then simply start the unit:
sudo systemctl start parca-agent
The systemd
service will be collecting profiles from docker.service
, parca.service
and parca-agent.service
that have been running on your system.