Skip to content

Commit

Permalink
Add collectd metrics (digital-asset#6189)
Browse files Browse the repository at this point in the history
* Add collectd metrics

CHANGELOG_BEGIN
CHANGELOG_END

* Remove useless file

* Fix typo
  • Loading branch information
rautenrieth-da authored Jun 3, 2020
1 parent 81aff44 commit dde5af0
Show file tree
Hide file tree
Showing 3 changed files with 1,001 additions and 0 deletions.
56 changes: 56 additions & 0 deletions ledger/metrics/collectd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Collectd metrics


## Collectd installation - macOS

First, check whether the directory `/usr/local/sbin` exists on your machine.
This directory does not exist on MacOs by default, and homebrew will try to link
collectd into this directory. If it does not exist, run:

```
sudo mkdir /usr/local/sbin
sudo chown -R `whoami`:admin /usr/local/sbin
```

To install collectd, run:

```
brew install libpq
brew install --build-from-source collectd
```

Note: The collectd bottle does not contain the postgresql plugin.
You therefore need to install `libpq` first, then build collectd from source.

If everything went well, you should have the following file on your machine:

```
/usr/local/Cellar/collectd/5.11.0/lib/collectd/postgresql.so
```

## Collectd configuration

Once installed, replace `/usr/local/etc/collectd.conf` with the [file from this directory](./collectd.conf)

## Postgres configuration

To allow collectd to monitor PostgreSQL,
create a `collectd` user and grant it priviledges to your databases.

```
psql -d postgres
# create user collectd with encrypted password 'collectd';
# grant all privileges on database damlsandbox to collectd;
# grant all privileges on database damlsandboxindex to collectd;
```

Note: this assumes your databaseses are called `damlsandbox` and `damlsandboxindex`.
If you want to monitor different databases, change also the corresponding entries in `collectd.conf`.

## Running collectd

To run collectd as a foreground process, run:

```
sudo /usr/local/sbin/collectd -f -C /usr/local/etc/collectd.conf
```
81 changes: 81 additions & 0 deletions ledger/metrics/collectd/collectd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Hostname "localhost"
FQDNLookup false
BaseDir "/usr/local/var/lib/collectd"
PIDFile "/usr/local/var/run/collectd.pid"
TypesDB "/usr/local/Cellar/collectd/5.11.0/share/collectd/types.db"

AutoLoadPlugin true

Interval 1

MaxReadInterval 86400
Timeout 2
ReadThreads 5
WriteThreads 5

<Plugin cpu>
ReportByCpu true
ReportByState true
ValuesPercentage true
</Plugin>

<Plugin load>
ReportRelative true
</Plugin>

<Plugin memory>
ValuesAbsolute true
ValuesPercentage false
</Plugin>

<Plugin "disk">
IgnoreSelected false
</Plugin>

<Plugin processes>
ProcessMatch "docker" "com.docker.hyperkit"
Process "java"
ProcessMatch "postgres" "postgres.*"
</Plugin>

<Plugin postgresql>
<Database damlsandbox>
Host "localhost"
Port "5432"
User "collectd"
Password "collectd"
# Predefined:
Query backends
Query transactions
Query queries
Query table_states
Query disk_io
Query disk_usage
</Database>
<Database damlsandboxindex>
Host "localhost"
Port "5432"
User "collectd"
Password "collectd"
# Predefined:
Query backends
Query transactions
Query queries
Query table_states
Query disk_io
Query disk_usage
</Database>
</Plugin>

<Plugin write_graphite>
<Carbon>
Host "localhost"
Port "2003"
Prefix "collectd."
Protocol "tcp"
LogSendErrors true
StoreRates true
AlwaysAppendDS false
EscapeCharacter "_"
</Carbon>
</Plugin>
Loading

0 comments on commit dde5af0

Please sign in to comment.