Exporting Metrics to Graphite via the collectd
Write Plugin¶
This document provides an example of using the write_graphite
write plugin to export metrics to Graphite.
Example Workflow¶
Example of metric
This example shows how to work with the single curl_json-wallarm_nginx/gauge-abnormal
metric, which shows the number of requests processed by the filter node.
The following deployment scheme is used in this document:
-
Wallarm filter node is deployed on a host accessible via the
10.0.30.5
IP address and thenode.example.local
fully qualified domain name.The
write_graphite
plugin forcollectd
on the filter node is configured as follows:- All metrics are sent to the
10.0.30.30
server listening on the2003/TCP
port. - Some Wallarm-specific
collectd
plugins support multiple instances, so thewrite_graphite
plugin contains theSeparateInstances
parameter set totrue
. Thetrue
value means that the plugin can work with several instances.
A complete list of plugin options is available here.
- All metrics are sent to the
-
Both
graphite
andgrafana
services are deployed as Docker containers on a separate host with the10.0.30.30
IP address.The
graphite
service with Graphite is configured as follows:- It listens for incoming connections on the
2003/TCP
port, to whichcollectd
will send the filter node metrics. - It listens for incoming connections on the
8080/TCP
port, through which communication with Grafana will occur. - The service shares the
sample-net
Docker network with thegrafana
service.
The
grafana
service with Grafana is configured as follows:- The Grafana web console is available at
http://10.0.30.30:3000
. - The service shares the
sample-net
Docker network with thegraphite
service.
- It listens for incoming connections on the
Configuring Metrics Export to Graphite¶
Prerequisites
It is assumed that
- Docker Community Edition and
docker-compose
are already installed on the10.0.30.30
Docker host. - The
node.example.local
filter node is already deployed, configured, available for further configuration (for example, via the SSH protocol), and working.
Deploying Graphite and Grafana¶
Deploy Graphite and Grafana on the Docker host:
-
Create a
docker-compose.yaml
file with the following content: -
Build the services by executing the
docker-compose build
command. -
Run the services by executing the
docker-compose up -d graphite grafana
command.
At this point, you should have Graphite running and ready to receive metrics from collectd
, and Grafana ready to monitor and visualize the data stored in Graphite.
Configuring collectd
¶
Configure collectd
to download metrics to Graphite:
- Connect to the filter node (for example, using the SSH protocol). Make sure you are logged in as
root
or another account with superuser privileges. -
Add the following configuration to the
/opt/wallarm/etc/collectd/wallarm-collectd.conf
file:LoadPlugin write_graphite <Plugin write_graphite> <Node "node.example.local"> Host "10.0.30.30" Port "2003" Protocol "tcp" SeparateInstances true </Node> </Plugin>
The following entities are configured here:
- The host name from which metrics are collected (
node.example.local
). - The server to which metrics should be sent (
10.0.30.30
). - The server port (
2003
) and the protocol (tcp
). - The data transfer logic: the data of one instance of the plugin is separated from the data of another instance (
SeparateInstances true
).
- The host name from which metrics are collected (
-
Restart the
wallarm
service by running the following command:
- Connect to the filter node (for example, using the SSH protocol). Make sure you are logged in as
root
or another account with superuser privileges. -
Create a file named
/etc/collectd/collectd.conf.d/export-to-graphite.conf
with the following content:LoadPlugin write_graphite <Plugin write_graphite> <Node "node.example.local"> Host "10.0.30.30" Port "2003" Protocol "tcp" SeparateInstances true </Node> </Plugin>
The following entities are configured here:
- The host name from which metrics are collected (
node.example.local
). - The server to which metrics should be sent (
10.0.30.30
). - The server port (
2003
) and the protocol (tcp
). - The data transfer logic: the data of one instance of the plugin is separated from the data of another instance (
SeparateInstances true
).
- The host name from which metrics are collected (
-
Restart the
collectd
service by running the appropriate command:
Now Graphite will receive all metrics of the filter node. You can visualize the metrics you are interested in, and monitor them with Grafana.