azure - IoT Edge 代理上的日志轮换

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

我正在关注微软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 重新启动 iotedge。日志轮换仍不会应用于边缘运行时创建的新容器。我不确定,我错过了什么?任何帮助表示赞赏。 请注意,我不想通过创建 daemon.json 文件并将其放置在边缘运行时文件夹中来应用日志轮换。我需要通过在deployment.template.json 文件中指定的容器选项来完成此操作。

最佳答案

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

关于azure - IoT Edge 代理上的日志轮换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58060489/

相关文章:

azure - 使用 Windows Azure 服务总线 可以从 Azure 网站使用吗?

python - 通过流下载 azure blob - 导出 137

image - 我怎么能从无到有构建 docker 镜像?

Azure 流分析 : remove duplicates while aggregating

Azure 流分析作业截断数据

azure API管理: is there a way to get the operation name in the inbound policy

sql-server - 是否可以创建 SQL Server Azure VM 但使用自己的许可证?

clojure - 从另一个容器连接到在 Docker 容器中运行的 headless nREPL

python - 无法连接到 Docker 中的 MySql。抛出拒绝访问错误。 Flask-SqlAlchemy

azure - 使用 AMQP lite 使用共享访问策略和 key 连接到 IoT 中心