Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cAdvisor support #445

Open
kanyi opened this issue Nov 9, 2022 · 9 comments
Open

cAdvisor support #445

kanyi opened this issue Nov 9, 2022 · 9 comments

Comments

@kanyi
Copy link

kanyi commented Nov 9, 2022

cAdvisor as datasource. That will be a big help of monitoring containers in Monitorix.

@mikaku
Copy link
Owner

mikaku commented Nov 10, 2022

is this is related to #313?

@kanyi
Copy link
Author

kanyi commented Nov 10, 2022

Yes. cAdvisor can create more detailed statistics for containers, but yes, basically the same.

@mikaku
Copy link
Owner

mikaku commented Nov 10, 2022

I'd like to avoid using third party tools that might be difficult to install in all systems. I mean, I'd prefer using podman to get the statistics.

In this aspect, and as I already said in #313, I'm not familiarized with podman or containers in general. So, I'm pretty lost when trying to get stats of running containers using the root user, when the containers are being ran using another user (which will be the common case).

Can you, please, share a list of useful commands that Monitorix can run to get general container statistics?
That would get me an idea to develop the new module container.pm.

@kanyi
Copy link
Author

kanyi commented Nov 10, 2022

Sorry but I don't use podman until now. I wil check it, and figure out these command is working or not. But, maybe this is help for you.

The normal docker stat command but separated the values:
docker stats --format "table {{.Container}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.MemPerc}}\t{{.PIDs}}"

The last 2 values (MemPerc and PIDs) works only linux systems.
The trick about running docker command, under linux you have a GID name is docker, not only a user. So every user who is in these docker group can run all of the docker commands without any other privileges. I your case, under linux, the monitorix user is added to docker group you can read the stats and run docker commands.

@mikaku
Copy link
Owner

mikaku commented Nov 10, 2022

As I read it, podman and docker are very similar tools, they share almost the same options and syntax. Moreover, I discovered that I can install the package podman-docker on Fedora to emulate Docker CLI using Podman.

So, I just ran your command and I got the following:

$  docker stats --format "table {{.Container}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.MemPerc}}\t{{.PIDs}}"
<no value>  NAME        CPU %       MEM USAGE / LIMIT  NET IO      BLOCK IO    MEM %       PI DS
Error: template: stats:1:13: executing "stats" at <.Container>: can't evaluate field Container in type containers.containerStats
$

No stats.

Then I checked the processes with containers using docker and I see the same output as with podman:

$ docker ps -a
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
CONTAINER ID  IMAGE                             COMMAND     CREATED            STATUS                     PORTS       NAMES
6725ce9cb235  docker.io/library/busybox:latest  sh          About an hour ago  Exited (0) 51 minutes ago              compassionate_bose
$ 

@kanyi
Copy link
Author

kanyi commented Nov 11, 2022

Looks podman can not recognize the {{.Container}} variable. - That's true https://docs.podman.io/en/latest/markdown/podman-stats.1.html So here is a difference, in docker and podman. :-)
I think this work, under podman (this is working for me Debian 11, Docker 20.10):
You can leave the table this is only for headers.
docker stats --format "{{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.MemPerc}}\t{{.PIDs}}"

@mikaku
Copy link
Owner

mikaku commented Nov 11, 2022

Still no stats.

Moreover, the command does not return. It keeps refreshing which ruins the chance to get stats.
Monitorix runs under the root user, if that user cannot get Docker/Podman generic (all users) stats then this will be hard to implement.

@kanyi
Copy link
Author

kanyi commented Nov 11, 2022

For me, the root user can run a docker stats command without any problem.
For you maybe podman stats -a --no-stream ?

@kanyi
Copy link
Author

kanyi commented Nov 11, 2022

Oh, and Docker has an API interface, more detailed statistics. In this case you have to know the container ID, but I don't think is a problem monitoring only the given ID's and not all of the containers.

Access API information as follows for a JSON stream in every second:
curl -v --unix-socket /var/run/docker.sock \ http://localhost/containers/CONTAINER_ID/stats
Substitute CONTAINER_ID with the actual ID of the container being inspected.

But in this case you have a "little" more work: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/building_running_and_managing_containers/assembly_using-the-container-tools-api_building-running-and-managing-containers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants