An open API service indexing awesome lists of open source software.

https://github.com/hrmeetsingh/containermonitor

Monitors container states using cAdvisor, Prometheus etc
https://github.com/hrmeetsingh/containermonitor

Last synced: 2 months ago
JSON representation

Monitors container states using cAdvisor, Prometheus etc

Awesome Lists containing this project

README

        

# Container Monitor
This utility can connect to a container to monitor its state. This is still WIP and thats why no more details at the moment.

## Prerequisites
- docker
- docker-compose
- bash

The script uses docker-compose to start and stop the monitoring services, so make sure you have docker and docker-compose installed on your system.

## Setup
- Clone the repo `git clone https://github.com/hrmeetsingh/ContainerMonitor.git`
- Run `cd ContainerMonitor`
- Run `chmod +x monitor.sh`
- Run `./monitor.sh start` to start monitoring
- Run `./monitor.sh stop` to stop monitoring
- Run `./monitor.sh logs ` to view logs from a container
- Run `./monitor.sh stream ` to stream logs from a container
- Run `./monitor.sh query ` to query Prometheus (refer Queries section)

Since the script abstracts the docker-compose file, you can modify the configuration as you see fit. It hides the complexity of docker-compose and provides a simple way to start and stop monitoring services.

## Screenshots
cAdvisorDashboard

Its probably an already solved problem. I am trying this in my free time to get understanding of the tools and the approach.
The code is generated by Claude and I have tweaked it to suit my purpose, so I do not claim any credit for this

## Queries
Metrics used for querying Prometheus:
```
# Container CPU Usage
container_cpu_usage_seconds_total

# Container Memory Usage
container_memory_usage_bytes

# Network I/O
container_network_receive_bytes_total
container_network_transmit_bytes_total

# Filesystem Usage
container_fs_usage_bytes
container_fs_reads_total
container_fs_writes_total
```

Aggregated Metrics:
```
# CPU Usage Percentage
sum(rate(container_cpu_usage_seconds_total{container_label!=""}[5m])) by (container_label) * 100

# Memory Usage Percentage
(container_memory_usage_bytes{container_label!=""} / container_spec_memory_limit_bytes{container_label!=""}) * 100

# Top 5 Containers by CPU Usage
topk(5, sum(rate(container_cpu_usage_seconds_total[5m])) by (container_label))

# Network Traffic
rate(container_network_receive_bytes_total[5m])
```

Querying with command line:
```
./monitor.sh query "container_cpu_usage_seconds_total"
```

Querying with web interface:
![Prometheus](./img/PrometheusQuery.png "Prometheus")