Edge Container Log Output Guide

Background

Storage space of edge devices (for example, an Atlas 500 A2 edge station) is limited. In addition, edge devices mostly use a flash such as an eMMC as a storage medium, but the service life of this medium is limited. To prevent services from being affected by used-up storage space or premature failure of storage medium, refer to the following suggestions for properly outputting edge container logs.

Output Mode

Currently, edge containerized applications running on Atlas hardware are generally managed by an edge management platform compatible with Kubernetes, for example, Huawei Cloud IEF or a third-party edge platform built based on KubeEdge. On such platforms, container logs can be output in the following modes:

  • Standard output (STDOUT or STDERR) using the container console
  • (Recommended) Log mounting to the host directory
  • Direct output to the log service

If a log server exists in the system, you are advised to export logs to the log service in the container. If no log server exists, you are advised to mount logs to the host directory to reduce the impact of logs on hardware and other services.

Standard Output Using the Container Console

In this mode, applications output container logs as standard outputs. By default, the Docker engine captures the standard output of all containers and writes the output to a file in JSON format. The file is saved to the /var/lib/docker/containers/{containerid} directory on the host, as shown in Figure 1.

Figure 1 Path of the {containerid}-json.log file

If the edge management platform does not support log file rotation or the log rotation configuration is incorrect, the /var/lib/docker directory will be fully occupied, affecting the deployment of new containers and the normal running of other container services. Therefore, this mode is not recommended.

(Recommended) Log mounting to the host directory

Figure 2 illustrates how to collect edge platform logs in this mode.

Figure 2 Solution architecture

The application mounts the container logs to the edge host. The edge management platform provides host log collection and rotates host file logs.

  • The application can mount container logs to non-key large-capacity directories on the host. It is not recommended that container logs be mounted to storage media such as eMMCs to avoid affecting the overall hardware service life.
  • Generally, the edge container management platform supports this capability to reduce the impact on the system directory /var/lib/docker. For security purposes, the configuration must meet the security requirements of your organization.

Direct output to the log service

If there is a log server in the application environment, logs can be directly output to the external log server. In this way, logs do not need to be written to disks in the edge environment, minimizing the impact on hardware and other services. See Figure 3.

Figure 3 Solution architecture