DCImanager 6 saves information about the operation of services in log files. The data from log files can be used to diagnose the platform operation. Log files are stored in the /var/log directories of docker containers.
Log files list
Main log files on platform server
The platform installation log is saved in the file /opt/ispsystem/dci/install.log.
The log files of the diagnostics operation are listed in the Diagnostics check article.
The authorization service logs are written to the standard output of the dci_auth_back4_1 container.
Main log files on location server
Working with logs
Copy log file from a container
To copy a log file from the container to the current directory, run the command:
docker cp <container_name>:<path_to_log> ./
docker cp dci_auth_back_1:/var/log/licupdate.log ./
View log files in a container
-
Enter the required container:
docker exec -it <container_name> sh
Comments to the commandExample commanddocker exec -it dci_back sh
-
View the log file using standard Linux utilities. For example, cat, tail, less, grep, etc.
Example command: Find out when the switch was polledgrep 'Switch status start' /var/log/dci_switch_1_handler.log
-
Exit the container:
exit
Viewing log files via stdout
Separate log files are not created for some services. Logs of these services are written to stdout. To view such logs, run the command:
docker logs <container_name> --tail <lines> --since <period>
docker logs dci_consul_1 --tail 100 --since 60m
Collecting platform logs
To collect all the log files of the platform in one directory:
- Connect to the server with the platform via SSH.
-
Create the bash script getlog.sh with the following content:
#!/bin/bash BEGIN_DATE=$(date +'%Y-%m-%d %H:%M:%S' --date '-1 day') SINCE=${1:-${BEGIN_DATE}} /bin/echo "Remove old files" /bin/rm -rf /home/logs && /bin/mkdir -p /home/logs/container && /bin/mkdir -p /home/logs/service && /bin/cd /home/logs /bin/echo "---===Step 1/3===---" DOCKER_CONTAINER_NAMES=`journalctl --field CONTAINER_NAME` CONTAINERS=($DOCKER_CONTAINER_NAMES) /bin/echo "Get logs of the containers" for container in ${CONTAINERS[@]} do /bin/echo "Get log of the container: ${container}" /bin/journalctl --no-pager CONTAINER_NAME=${container} --since "${SINCE}" > /home/logs/container/${container}.log done /bin/echo "---===Step 2/3===---" DOCKER_SERVICES_NAMES=`journalctl --field SYSLOG_IDENTIFIER` SERVICES=($DOCKER_SERVICES_NAMES) /bin/echo "Get logs of the services" for service in ${SERVICES[@]} do /bin/echo "Get log of the service: ${service}" /bin/journalctl --no-pager SYSLOG_IDENTIFIER=${service} --since "${SINCE}" > /home/logs/service/${service}.log done /bin/echo "---===Step 3/3===---" ARCHIVE_NAME="logs_$(date +'%Y_%m_%d_%H_%M_%S').tar.gz" tar -cvzf /home/$ARCHIVE_NAME -C /home/logs . /bin/echo "Done"
-
Run the script using one of the commands:
Before collecting logs, the script deletes all files from the /home/logs/ directory.Collect logs for the last daybash getlog.sh
Collect logs since a certain datebash getlog.sh "YYYY-MM-DD"
Collect logs since a certain date and timebash getlog.sh "YYYY-MM-DD HH:MM:SS"
Comments to the commandsThe script:
- Saves container logs in the /home/logs/container/ directory.
- Saves service logs in the /home/logs/service/ directory.
- Creates an archive logs_<current_date>_.tar.gz in the /home/ directory.
Logging in journald
Logging settings
The platform uses the journald system service to collect logs. journald collects logs for all containers except dci_consul_1. You can change the journald logging level, read more in the Logging level management.
The journald service on the platform server and the location server is configured automatically. The service configuration is saved in the /usr/lib/systemd/journald.conf.d/dci.conf file. If the service has already been configured on the server, the configuration set by the platform will have a higher priority.
Configuration parameters set by the platform:
- Storage=persistent — store files on disk;
- Compress=yes — compress data in logs;
- SystemMaxFileSize=500M — the maximum size of the log file is 500 Mb. When this value is reached, logs are rotated;
- SystemMaxUse=20G — the maximum disk size for storing logs is 20 GB. When this value is reached, older files will be deleted.
Operations with logs
journald saves logs in the /var/log/journal/ directory. You can view the logs using the journalctl utility. Examples of how to use the utility:
journalctl --field CONTAINER_NAME
journalctl -f CONTAINER_NAME=<container_id>
journalctl --field SYSLOG_IDENTIFIER
journalctl -f SYSLOG_IDENTIFIER=<service_id>
journalctl --no-pager CONTAINER_NAME=dci_auth_back4_1 --since "YYYY-MM-DD"
Related topics: