Recently, I started up services one after another with Docker on Raspberry Pi 4B (4GB), and I wanted to monitor the server, so I made a note of how to do it.
--Server monitoring tool compatible with Docker --Supports ARM architecture --I want to monitor the server itself on Docker
It should be useful for greedy people.
Monitor the status (CPU, memory, process) of the server running on Raspberry Pi 4B (4GB).
Requests to each server are distributed using nginx-proxy.
There are many server monitoring tools, but the ones that support Docker are limited. For the selection of services, I referred to this article and selected New Relic, which is a SaaS type and can be used easily and for free. The price of the server monitoring tool is high, and I felt that it was difficult to introduce it to a service that was only released for personal development, but with New Relic One, it is a free license up to 100 GB of data acquisition every month. You can use it. It's more than enough for personal use. New Relic has multiple services such as app performance monitoring (APM) and ping alive monitoring, but this time we will use Infrastructure, which allows you to see the amount of CPU and memory used.
Go to the New Relic site and press "Free sign up" in the upper right corner to create an account. Once you've created your account, select Account settings
from the account dropdown in the upper right and click API keys
from the left sidebar.
Press Create key
to create a key with Key type
as Ingest --License
and Name
as any name.
For x86-64, the Docker image is officially provided, so all you have to do is start the container according to the Official Document, but since it is arm64, you need to build it yourself.
That said, all you have to do is replace the three binaries newrelic-infra
, newrelic-infra-ctl
, and newrelic-infra-service
that are plunged into the image.
The binaries are officially provided, so download them from the link below (as of January 2021, 1.9.7 is the latest).
https://download.newrelic.com/infrastructure_agent/binaries/linux/
mkdir ~/newrelic-infra-setup
cd ~/newrelic-infra-setup
wget https://download.newrelic.com/infrastructure_agent/binaries/linux/arm64/newrelic-infra_linux_1.9.7_arm64.tar.gz
tar -zxvf newrelic-infra_linux_1.9.7_arm64.tar.gz
Next, clone the newrelic/infrastructure-agent GitHub repository.
git clone https://github.com/newrelic/infrastructure-agent.git
For how to build the Docker image, refer to This page. First, copy the downloaded binary to the specified folder. Putting the arm64 binary in linux_amd64
is also a thing, but that is through.
mkdir -p infrastructure-agent/target/bin/linux_amd64
cp newrelic-infra/usr/bin/* infrastructure-agent/target/bin/linux_amd64/
cd infrastructure-agent/build/container
export IMAGE_VERSION=1.0 #Appropriately. 0 if not specified.Become 0
make build/base
Now that the Docker image is generated, set up the container in the same procedure as x86-64. Follow the steps on this page (https://docs.newrelic.com/docs/infrastructure/install-infrastructure-agent/linux-installation/docker-container-infrastructure-monitoring).
Put the first license key you got in newrelic-infra.yml
.
cd ~/newrelic-infra-setup
echo "license_key: {YOUR_LICENSE_KEY}" > newrelic-infra.yml
touch newrelic-infra.dockerfile
vim newrelic-infra.dockerfile #Any editor is fine
newrelic-infra.dockerfile
FROM newrelic/infrastructure:latest
ADD newrelic-infra.yml /etc/newrelic-infra.yml
touch docker-compose.yaml
vim docker-compose.yaml #Any editor is fine
docker-compose.yaml
version: '3'
services:
agent:
container_name: newrelic-infra
build:
context: .
dockerfile: newrelic-infra.dockerfile
cap_add:
- SYS_PTRACE
network_mode: host
pid: host
privileged: true
volumes:
- "/:/host:ro"
- "/var/run/docker.sock:/var/run/docker.sock"
restart: unless-stopped
docker-compose build
docker-compose up -d
Now that server monitoring has already started, select Infrastructure
from the top bar on the New Relic website and you'll see a graph of CPU usage and free memory percentage.
Also, if you open Entity explorer
from the top bar, there are various other graphs and tables, so you can add whatever you like to the dashboard.
newrelic-infra
uses the most CPU, grass.
--Infrastructure> Hosts> Docker Containers does not get information for each container
--docker-compose logs
is throwing an error (" integration exited with error state "
)
I chose New Relic because it supports Docker, but I can't use it because it's overwhelming, so I'd like to fix it somehow.
New Relic Pricing (Japanese) New Relic license key Docker container for infrastructure monitoring Docker instrumentation for infrastructure monitoring newrelic/infrastructure-agent newrelic/infrastructure-agent - Containerized Agent newrelic/infrastructure-agent - ARM64 (aarch64) support #107 Service that monitors Docker container New Relic, which advocates the "digital new normal concept," has renewed its products and pricing system
Recommended Posts