---
name: monitoring-change_linux_agent
title: Customizing Linux monitoring agents
description: By default, the monitoring agent collects data from a range of platforms and applications. You can edit the agent config file to change its default behavior, and include or exclude data. You can customize the monitoring agent configuration file to include custom metrics such as JMX, StatsD, and Prometheus. You also can filter out metrics and containers.
last-updated: 2024-10-21
---

> ## Documentation Index
> The table of contents for this documentation set is at https://cloud.ibm.com/docs/monitoring?format=markdown
> The index for all IBM Cloud docs is at: https://cloud.ibm.com/docs/llms.txt
> Use these files to discover more information as needed.

# Customizing Linux monitoring agents
{: #change_linux_agent}

By default, the monitoring agent collects data from a range of platforms and applications. You can edit the agent config file to change its default behavior, and include or exclude data. You can customize the monitoring agent configuration file to include custom metrics such as JMX, StatsD, and Prometheus. You also can filter out metrics and containers.
{: shortdesc}

The monitoring agent uses two configuration files that specify what data to collect automatically:

| File                   | Description                                                     | Location                                |
|------------------------|-----------------------------------------------------------------|-----------------------------------------|
| `dragent.default.yaml` | Main configuration file   \n **IMPORTANT:** Do not edit this file.  | `/opt/draios/etc/dragent.default.yaml`  |
| `dragent.yaml`         | Configuration file that you edit to customize the monitoring agent. | `/opt/draios/etc/dragent.yaml`          |
{: caption="monitoring agent configuration files" caption-side="top"}

You can edit the *dragent.yaml* file to customize the data that is collected. Changes take effect immediately after you save the file. The agent detects the change and automatically restarts. You can find the frequency and the files that a monitoring agent checks in the *dragent.default.yaml* file.

For example, a *dragent.default.yaml* includes the following information:

```yaml
check_frequency_s: 5
files:
- /opt/draios/etc/dragent.yaml
- /opt/draios/etc/kubernetes/config/dragent.yaml
- /opt/draios/etc/kubernetes/secrets/access-key
```
{: screen}



## Editing the dragent yaml file
{: #change_linux_agent_edit_agent}

The yaml file is loacated in `/opt/draios/etc/`.

Complete the following steps to edit the file and apply the changes:

1. Access the *dragent.yaml* directly. The file is located in `/opt/draios/etc/dragent.yaml`.
2. Edit the file. Use valid YAML syntax.
3. Restart the agent. Run the following command:

    ```text
    service dragent restart
    ```
    {: codeblock}


## Blocking ports
{: #change_linux_agent_block_ports}

To block network traffic and metrics from network ports, you must customize the **blacklisted_ports** section in the *dragent.yaml* file. You must list the ports from which you want to filter out any data.

**Note:** Port 53 (DNS) is always blacklisted.

For example, the following sample shows how to set the *blacklisted_ports* section of a monitoring agent to exclude data coming from ports 6666 and 6379:

```yaml
blacklisted_ports:
    - 6666
    - 6379
```
{: screen}

## Including and excluding metrics
{: #change_linux_agent_inc_exc_metrics}

To filter custom metrics, you must customize the **metrics_filter** section in the *dragent.yaml* file. You can specify which metrics to include and which ones to filter out by configuring the **include** and **exclude** filtering parameters.

**Note:** The filtering rule order is set as follows: the first rule that matches a metric is applied.

For example, if the *metrics_filter* section of a monitoring agent looks as follows:

```yaml
metrics_filter:
  - include: metricA.*
  - exclude: metricA.*
  - include: metricB.*
  - include: haproxy.backend.*
  - exclude: haproxy.*
  - exclude: metricC.*
```
{: screen}

* You are configuring the monitoring agent to collect all data from metrics that start with *metricA*, *metricB*, and *haproxy.backend*.
* You are filtering out metrics that start with *metricC* and other metrics that start with *haproxy*.
* The entry `exclude: metricA.*` is ignored.


## Changing the log level
{: #change_linux_agent_log_level}

To configure the log level, you must customize the **log** section in the *dragent.yaml* file.

The monitoring agent generates log entries in */opt/draios/logs/draios.log*.
* The log file rotates when it reaches 10MB in size.
* The 10 most recent log files are kept. The date-stamp that is appended to the filename is used to determine which files to keep.
* Valid log levels are: *none*, *error*, *warning*, *info*, *debug*, *trace*
* The default log level is *info*, where an entry is created for each aggregated metrics transmission to the backend servers, once per second, in addition to entries for any warnings and errors.
* You can customize the type of log and the entries that are collected by configuring the monitoring agent configuration file **/opt/draios/etc/dragent.yaml**. After you edit the file, you must restart the agent at the shell with `service dragent restart` to activate the changes.

| Use cases                                     | Log section entry           |
|-----------------------------------------------|-----------------------------|
| Troubleshoot agent behavior                   | `file_priority: debug`      |
| Reduce container console output               | `console_priority: warning` |
| Filtering events by severity                  | `event_priority: warning`   |
| Verify what metrics are included or excluded  | `metrics_excess_log: true`  |
{: caption="Log section entries" caption-side="top"}