IoT Edge代理上的日志轮换

时间:2019-09-23 10:33:10

标签: azure docker azure-iot-hub azure-iot-edge

我正在关注Microsoft documentation,并尝试通过容器选项设置边缘代理的日志。我的deployment.template.json文件如下:

{
 "$schema-template": "2.0.0",
  "modulesContent": {
    "$edgeAgent": {
      "properties.desired": {
        "schemaVersion": "1.0",
        "runtime": {
          "type": "docker",
          "settings": {
            "minDockerVersion": "v1.25",
            "loggingOptions": "",
            "registryCredentials": {
              "myRegistryName": {
                "username": "$CONTAINER_REGISTRY_USERNAME",
                "password": "$CONTAINER_REGISTRY_PASSWORD",
                "address": "myRegistryAddress.azurecr.io"
              }
            }
          }
        },
        "systemModules": {
          "edgeAgent": {
            "type": "docker",
            "settings": {
              "image": "mcr.microsoft.com/azureiotedge-agent:1.0",
              "createOptions": {
                "HostConfig": {
                  "LogConfig": {
                      "Type": "json-file",
                      "Config": {
                          "max-size": "10m",
                          "max-file": "3"
                      }
                  }
                }
              }
            }
          },
          "edgeHub": {
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "settings": {
              "image": "mcr.microsoft.com/azureiotedge-hub:1.0",
              "createOptions": {
                "HostConfig": {
                  "PortBindings": {
                    "5671/tcp": [
                      {
                        "HostPort": "5671"
                      }
                    ],
                    "8883/tcp": [
                      {
                        "HostPort": "8883"
                      }
                    ],
                    "443/tcp": [
                      {
                        "HostPort": "443"
                      }
                    ]
                  },
                  "LogConfig": {
                    "Type": "json-file",
                    "Config": {
                        "max-size": "10m",
                        "max-file": "3"
                    }
                  }
                }
              }
            }
          }
        },
        "modules": {
          "Module_Name": {
            "version": "1.0",
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "settings": {
              "image": "${MODULES.Module_Name}",
              "createOptions": {
                "HostConfig": {
                  "LogConfig": {
                      "Type": "json-file",
                      "Config": {
                          "max-size": "10m",
                          "max-file": "3"
                      }
                  }
                }
              }
            }
          }
        }
      }
    },
    "$edgeHub": {
      "properties.desired": {
        "schemaVersion": "1.0",
        "routes": {
          "route": "FROM /messages/* INTO $upstream"
        },
        "storeAndForwardConfiguration": {
          "timeToLiveSecs": 7200
        }
      }
    }
  }
}

在我的设备上构建和部署它时,将应用edge Hub和模块日志轮换,但不会应用edgeAgent日志轮换。我在 /var/lib/docker/containers/{container_id}/hostconfig.json文件。

我到目前为止所做的事情:

通过sudo docker rmi sudo docker rmi mcr.microsoft.com/azureiotedge-agent:1.0删除了图像,并删除了所有容器,包括edgeAgent容器,并通过sudo systemctl restart iotedge重新启动了边缘环境。日志旋转仍然不会应用于边缘运行时创建的新容器。我不确定,我想念什么?任何帮助表示赞赏。 请注意,我不想通过创建daemon.json文件并将其放置在边缘运行时文件夹中来应用日志轮换。我需要通过deploy.template.json文件中指定的容器选项来完成此操作。

1 个答案:

答案 0 :(得分:1)

这是一个已知的错误,如果版本号与config.yaml中的版本相同,则边缘代理部署不适用;请帮助为其创建github问题。要解决此问题,请在config.yaml中设置选项。