Setting the time interval of metrics collection in Boatswain
Tags: boatswain, docker
Published: 2020-02-13 14:20:18

---
title: "Setting the time interval of metrics collection in Boatswain"
published: true
description: "We could control the server resources consumption of Boatswain by modifying the metrics collection period."
tags: [Boatswain, Docker]
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/nb8s5om2mqiozoquwfks.jpg
---

_Originally posted on [Boatswain Blog](https://blog.boatswain.io/post/setting-the-time-interval-of-metrics-collection-in-boatswain/)._

---

## Boatswain Agent 0.2.12 is released!

Earlier this week we have released a new version of [Boatswain][boatswain] (Agent version 0.2.12). Please follow this [update guide](https://docs.boatswain.io/boatswain-update-notes/#0-2-11-0-2-12) for different Linux distros. If you are running [Boatswain][boatswain] as a container, just use the 0.2.12 image available from [Docker Hub](https://hub.docker.com/r/boatswainio/boatswain).

### The new Period attribute

In this release, we have added a new configurable attribute called **Period** which is the collection time interval of the **Server Host** and the **Docker** metrics. Here is the new */etc/boatswain.yml* looks like:

```yaml
# Please register and get the token from https://app.boatswain.io/
token: token_here
# Period is the collection time interval of the host and docker metrics.
# CPU load could be reduced by using longer period.
#   - short   = 10s
#   - default = 30s
#   - long    = 60s
period: default
```

Prior to agent version 0.2.12, the collection time interval is 10s and there is not way to control it.

Now, as stated in the above config file, there are 3 available options for the new **Period** attribute and **default** would be used if this attribute is missing.

### The command flag for config file is updated too

When running [Boatswain][boatswain] directly through the binary as a foreground process, we could specify the location of the config file using the *-f* flag (instead of *-t* prior to agent version 0.2.12).

```
ykyuen@camus:~# boatswain --help

Usage: boatswain [options]
Options:
  -f string
      boatswain configuration file.
  -v  Show boatswain version and exit.
```

## Server resources consumption VS Period

Setting a longer period means the statistics shown on the [Boatswain web portal][boatswainio] would have a less sample size but in return, it could reduce system load significantly. Moreover, it could free more data space for monitoring more [Docker][docker] servers without hitting our BETA 2GB data limit.

Let's run [Boatswain][boatswain] to monitor itself with different **Period** settings. Here are the three runs on a Digital Ocean droplet (1vCPU, 1GB Memory) and it hosts a Drupal 7 application. Each run lasts for 30 mins.

_Note: The data size below only includes the metrics which depend on the **Period** setting._

### Period: short (10s)

![Period: short (10s)](https://dev-to-uploads.s3.amazonaws.com/i/k4y8mcyom2cdb4e00937.jpg)

```
# CPU consumption:    1.39%
# Memory consumption: 10.06% (104,647,789 Bytes)
# Data size:          8.8MB
```

### Period: default (30s)

![Period: default (30s)](https://dev-to-uploads.s3.amazonaws.com/i/z1bbcrwgfe6ajq309iv3.jpg)

```
# CPU consumption:    0.70%
# Memory consumption: 11.00% (114,425,856 Bytes)
# Data size:          4.3MB
```

### Period: long (60s)

![Period: long (60s)](https://dev-to-uploads.s3.amazonaws.com/i/k2ncx3plyt4li1mctepg.jpg)

```
# CPU consumption:    0.57%
# Memory consumption: 6,61% (68,772,546 Bytes)
# Data size:          1.9MB
```

### Result

1. CPU consumption dropped significantly.
  - :small_red_triangle_down: 49.64% from **1.39%** to **0.70%** (Period: 10s :arrow_right: 30s)
  - :small_red_triangle_down: 58.99% from **1.39%** to **0.57%** (Period: 10s :arrow_right: 60s)
1. Memory consumption was more or less the same.
  - Although the value dropped a lot (Period: 10s :arrow_right: 60s), it raised to **11.90% (123,901,542 Bytes)** after running 6 hours.
1. Data size dropped significantly.
  - :small_red_triangle_down: 51.14% from **8.8MB** to **4.3MB** (Period: 10s :arrow_right: 30s)
  - :small_red_triangle_down: 78.41% from **8.8MB** to **1.9MB** (Period: 10s :arrow_right: 60s)

## Other metrics

[Boatswain][boatswain] also collects other metrics including

- Container Status
- Container Logs
- Web Analytics

They are **independent** of the new **Period** attribute as the logs and web analytics metrics are received in real time while the container status is monitored in a fixed 10s time interval.

## What's next?

It has been more than one year since our BETA-I release and [Boatswain][boatswain] looks more complete after the recent updates. Probably it's time to move on. :ship:

Stay tuned with [us][twitter]!





[boatswain]: https://boatswain.io/
[boatswainio]: https://app.boatswain.io/
[docker]: https://www.docker.com/
[twitter]: https://twitter.com/BoatswainIO