README
¶
Stats-log-collector
Stats-log-collector is a deployment that could be used to monitor RSS and collect logs of the virtual machine inside a cluster Kubernetes that uses Kubevirt.
Components
Stats-log-collector deployment consist in 2 containers:
- logs-collector
- memstat
Both uses a volume that is mounted, in which they will store data collected. By default,
the volume is mounted on
/data
logs-collector
logs-collector collects virt-launcher and virt-handler logs of all the vms running
in a specified namespace. It consists in a basic application that runs every hour
and retrieve the virt-handler and virt-launcher logs of the last hour. It will create
a folder inside DATA_DIR
for each vm.
You can customize the behaviour by editing the following env
of the specific container
in the deployment.yaml file:
DATA_DIR
folder where store the collected logs- default:
/logs-collector
- default:
KUBEVIRT_NAMESPACE
namespace in which Kubevirt has been deployed- default:
kubevirt
- default:
HCO_NAMESPACE
namespace in which HCO has been deployed (if exists)- default: ""
NAMESPACE
namespace of the vms you want to monitor (you can monitor only one namespace)- default:
default
- default:
memstats
memstats collects RSS data of all the vms running in a specified namespace.
It consists in a basic application that runs every POLL_INTERVAL_SECS
and
get RSS data, adding them to a csv file. This file will be stored inside a
directory named mem-stats.csv
under DATA_DIR
folder.
You can customize the behaviour by editing the following env
of the specific container
in the deployment.yaml file:
DATA_DIR
folder where store the collected logs- default:
/data
- default:
NAMESPACE
namespace of the vms you want to monitor (you can monitor only one namespace)- default:
default
- default:
POLL_INTERVAL_SECS
every how many seconds you want the data collection to run- default:
300
- default:
HTTP_PORT
port of the webserver that can be used to retrieve the csv file- default:
8099
- default:
Usage
NB: it uses the KUBECONFIG
env var on your local system to determine in which cluster
the commands should be executed.
After customizing the env
variables you can install the stats-logs-collector
by simply run:
make install
To uninstall it:
make unistall
It will destroy everything, also the PVC containing the collected data.
Export data
Export mem-stats.csv
data
memstat provides a webserver that can be used to download the csv.
In order to use it you have to provide a port-forward to map the exposed port.
- open a port forward to an available local port
kubectl port-forward <pod_name> <local_port>>:<HTTP_PORT>
- open another shell and retrieve data
curl -k http://localhost:<local_port> > <path_to_local_file>
Read logs-collector data
To read the logs you can simply go inside the pod and read it navigating through DATA_DIR
folder:
kubectl exec -it <pod_name> -- bash
or download a specific file:
kubectl cp -c logs-collector <pod_name>:<DATA_DIR>/<vm_name>/<filename> <local_path>
License
Stats-logs-collector is distributed under the Apache License, Version 2.0.
Copyright 2022
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Documentation
¶
There is no documentation for this package.