> For the complete documentation index, see [llms.txt](https://kchuene.gitbook.io/data-communication-project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kchuene.gitbook.io/data-communication-project/setup/ubuntu-production-server/wazuh-agent.md).

# Wazuh Agent

Wazuh Agent for Host Intrusion Detection and DVWA Apache logs collection. Reports back to the Wazuh Manager.

## Add Wazuh Repository

**Install APT https support package**

{% code overflow="wrap" lineNumbers="true" %}

```
sudo apt install gnupg apt-transport-https
```

{% endcode %}

**Install GPG key**

{% code overflow="wrap" lineNumbers="true" %}

```
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | sudo gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import && sudo chmod 644 /usr/share/keyrings/wazuh.gpg
```

{% endcode %}

**Add the repository**

{% code overflow="wrap" lineNumbers="true" %}

```
echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | sudo tee -a /etc/apt/sources.list.d/wazuh.list
```

{% endcode %}

**Update package information**

{% code overflow="wrap" lineNumbers="true" %}

```
sudo apt update
```

{% endcode %}

## Install and Deploy Wazuh Agent

**Install configuring Wazuh Manager IP Address**

{% code overflow="wrap" lineNumbers="true" %}

```
WAZUH_MANAGER="192.168.56.1" sudo apt install wazuh-agent
```

{% endcode %}

**Enable Wazuh Agent service for startup**

{% code overflow="wrap" lineNumbers="true" %}

```
sudo systemctl daemon-reload
sudo systemctl enable wazuh-agent
sudo systemctl start wazuh-agent
```

{% endcode %}

**Confirm connectivity**

Go to the **Wazuh Manager** web interface on the controller node and visit the `/app/endpoints-summary#/agents-preview` endpoint or **Agent Management > Summary**.

## Log Collection

Assuming the bind mount to **DVWA** container's **Apache 2** and **MySQL** log folders was created at `/var/log/dvwa` on the host.

**Create Production group in Wazuh (Optional)**

Navigate to **Agent Management > Groups > Add new group** and provide `production` for our group name.

**Add agent to group (Optional)**

Navigate to **Agent Management > Groups > production > Manage Agents**

{% code overflow="wrap" lineNumbers="true" %}

```
https://localhost/app/endpoint-groups#/manager/?tab=groups&group=production
```

{% endcode %}

and add the **Wazuh Agent** to the `production`  group.&#x20;

**Configure collection of DVWA logs**

Navigate to configuration for `production` agent in the **Wazuh Dashboard** at **Agent Management > Groups > Action > Edit group configuration** and add the following for the appropriate group, i.e. `production`.

{% code overflow="wrap" lineNumbers="true" %}

```xml
<agent_config>
    <!-- Shared agent configuration here -->
    
    <!-- Apache log collection -->
    <localfile>
      <log_format>apache</log_format>
      <location>/var/log/apache2/access.log</location>
    </localfile>
    <localfile>
      <log_format>apache</log_format>
      <location>/var/log/apache2/error.log</location>
    </localfile>
</agent_config>
```

{% endcode %}

{% embed url="<https://documentation.wazuh.com/current/installation-guide/wazuh-agent/wazuh-agent-package-linux.html>" %}

{% embed url="<https://medium.com/@prakrititimilsina56/wazuh-100-detecting-sql-injection-and-xss-attacks-using-dvwa-wazuh-siem-18b2b40738ef>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://kchuene.gitbook.io/data-communication-project/setup/ubuntu-production-server/wazuh-agent.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
