# Agent

### 简介

Agent 主要的功能是：

* 检查 Workload 的状态（例如健康状态、网络信息等），并且上报至 Core
* 检查此 Node 的状态，并且上报至 Core
* 获取并转发 Workload 的日志
* 获取并转发 Metrics

Agent 并没有 HA 机制，建议在一个 Node 上只部署一个 Agent，用于监控这个 Node 及在其上运行的 Workload 的状态。

### 结构

Agent 的主体结构如下图：

![](/files/-MlPGNTt3T_Zon_-w3VA)

和 Core 一样，Agent 并不与 Runtime 类型强耦合。Agent 把所有与运行时相关的逻辑抽象为如下图所示的 `Runtime` 接口，只需要通过简单适配，实现这个接口即可支持任意 Runtime。目前已经支持了 `Docker` 和 `Yavirt`，未来还会支持 `Systemd` 等。

![](/files/-MlPGNTuUG3y4kAUV40m)

Agent 还做了其它抽象化的工作，例如将 `Core Service` 抽象为 `Store`，将 `ETCD` 抽象为 `KV`。这些抽象不仅增强了扩展性，还为设计单元测试提供了便利。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.eru.dev/components/agent.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
