Anomaly » collectd https://anomaly.io Just another WordPress site Fri, 21 Dec 2018 19:16:49 +0000 en-US hourly 1 http://wordpress.org/?v=4.2.2 Detecting Anomalies with Skylinehttps://anomaly.io/detect-anomalies-skyline/ https://anomaly.io/detect-anomalies-skyline/#comments Tue, 28 Jul 2015 16:00:43 +0000 https://anomaly.io/?p=2761 The post Detecting Anomalies with Skyline appeared first on Anomaly.

]]>

install skyline anomaly detection

Skyline is free and open source anomaly detection software. Simply plug Graphite metrics into Skyline to detect anomalous behaviour automatically without any configuration.

Skyline Architecture

Skyline is usually set to use Graphite metrics. This is done by placing a daemon call “carbon-relay” in front of the usual Graphite stack. Carbon-relay will repeat the metrics to multiple hosts. One of them will be the essay editing service traditional Graphite stack, and the other host will be the Skyline stack.

skyline with graphite

Skyline is composed of several parts:

  • Horizon – Responsible for collecting, cleaning, and formatting incoming metrics before pushing to a Redis database.
  • Analyzer – Fetches metrics from Redis and runs mathematical equations to detect anomalies
  • Skyline-webapp – A Django webapp to display an anomaly graph when it occurs

In the above schema, CollectD is used to monitor and push server metrics to carbon-cache. Read more about Graphite architecture.

Install Graphite

Graphite Required

Skyline is commonly used with Graphite. That’s why you need to Install Graphite on CentOS.
You don’t have to run the Graphite full stack; running carbon-relay is enough. But, as carbon-relay is part of Graphite, you still have to install Graphite.

Configure Carbon-relay

Set the list of hosts carbon-relay needs to forward its metrics to.

sudo vim /opt/graphite/conf/relay-rules.conf

# change the file
[...]
destinations = 127.0.0.1:2004, 127.0.0.1:2024
[...]

With this configuration, carbon-relay will forward metrics to Skyline on port 2024 and to paper writers carbon-cache (Graphite) on port 2004. Both services run locally in this tutorial. Also, edit the carbon configuration:

sudo vim /opt/graphite/conf/carbon.conf

# change the file
[...]
DESTINATIONS = 127.0.0.1:2004, 127.0.0.1:2024
[...]

Start carbon-relay

Start carbon-relay using systemd:

sudo systemctl restart carbon-relay

Install Skyline

Required

Open a terminal and install a few tools. This includes an Apache server (which is probably already installed), the Redis database, and Python with few mathematical libraries and some compile tools:

sudo yum -y install httpd redis git
sudo yum -y install gcc gcc-c++ git pycairo mod_wsgi
sudo yum -y install python-pip python-devel blas-devel lapack-devel libffi-devel

Download and install Skyline

cd /opt
sudo git clone https://github.com/etsy/skyline.git
cd /opt/skyline

sudo pip install -U six
sudo pip install -r requirements.txt
sudo pip install numpy
sudo pip install scipy
sudo pip install pandas
sudo pip install patsy
sudo pip install statsmodels
sudo pip install msgpack-python

Some of the Python packages might take very long to compile. Be patient, maybe grab a coffee…

Configure Skyline

Don’t forget to create the required directory and configuration:

sudo cp /opt/skyline/src/settings.py.example /opt/skyline/src/settings.py
sudo mkdir /var/log/skyline
sudo mkdir /var/run/skyline
sudo mkdir /var/log/redis
sudo mkdir /var/dump/

Skyline requires some settings, so edit the file:

sudo vim /opt/skyline/src/settings.py

and replace the following with your own values:

  • GRAPHITE_HOST = ‘YOUR_GRAPHITE_HOST
  • HORIZON_IP = ‘0.0.0.0
  • WEBAPP_IP = ‘YOUR_SKYLINE_HOST_IP

In my case I replace with the same IP as Skyline and Graphite run locally on the same host:

  • GRAPHITE_HOST = ‘192.168.50.6
  • HORIZON_IP = ‘0.0.0.0
  • WEBAPP_IP = ‘192.168.50.6

Start Skyline

The Skyline stack is made up of a Redis database and three Python processes. Start all services:

cd /opt/skyline/bin

sudo redis-server redis.conf
sudo ./horizon.d start
sudo ./analyzer.d start
sudo ./webapp.d start

Access Skyline-WebApp

Open your browser at http://localhost:1500/
Warning! To access a remote IP such as http://remote_ip:1500/ you need to set rules into the CentOS default firewall. Or simply disable the firewall:

#disable firewall
sudo systemctl disable firewalld
sudo systemctl stop firewalld

Skyline-WebApp should be empty as no anomaly will have been detected at first. Don’t worry if some anomalies are listed. This will stabilize with time.

skyline screenshot

Send Metrics to Skyline and Graphite

Carbon-relay now forwards its data to Skyline and carbon-cache. Any metrics sent to carbon-relay should be available in Skyline and Graphite.

Install CollectD

To collect and push metrics to carbon-relay we like to use CollectD. If you haven’t installed CollectD yet, follow these easy instructions:

Configure CollectD

Carbon-cache listens on a different port. Make sure you edit /opt/collectd/etc/collectd.conf to send the data on port 2013.

sudo vim /opt/collectd/etc/collectd.conf

# edit the file
[...]

   Host "localhost"
   Port "2013"
   Prefix "collectd."
   Protocol "tcp"

[...]

Start CollectD

If you installed the systemd script simply run:

# start with SytemD
sudo systemctl restart collectd.service

# or manualy
sudo /opt/collectd/sbin/collectd

Test Skyline Integration

Let your Linux idle for at least 10 minutes. Skyline will train itself to recognize low CPU activity as being normal. To create an anomaly, suddenly create some high CPU activity:

# wait at least 10 minutes before creating the anomaly
timeout 40s dd if=/dev/zero of=/dev/null &
timeout 40s dd if=/dev/zero of=/dev/null &
timeout 40s dd if=/dev/zero of=/dev/null &
timeout 40s dd if=/dev/zero of=/dev/null &

Open Skyline-webApp in your browser on port 1500. It should detect the anomaly within 10 seconds.

skyline anomaly detected

Test Graphite

Graphite should still work the same as before, since it receives its metrics through carbon-relay. Wait a few seconds and open Graphite-WebApp. Same as previously, you should see some new metrics in the left panel. Open one of them to render it.
Warming! By default, Graphite-WebApp renders a 24 hour graph. To see some data points zoom in or wait a bit longer.

graphite graph

Troubleshooting

If you follow the above steps exactly, this should work just fine. But in case you don’t see your data in Graphite try the following.

Check Graphite Troubleshooting

Try the troubleshooting solutions provided in Graphite installation tutorial.

Check Skyline log files

less +F /var/log/skyline/horizon.log
less +F /var/log/skyline/analyzer.log
less +F /var/log/skyline/webapp.log

Check That Every Process is Running

ps aux | grep "carbon-ca\|httpd\|collectd\|(wsgi:graphite)\|horizon-agent.py\|analyzer-agent.py\|horizon-agent.py\|carbon-relay.py\|webapp.py"

# result somthing like:
# [...]
# sudo /opt/collectd/sbin/collectd -C /opt/collectd/etc/collectd.conf -f
# [...]
# python /opt/skyline/bin/../src/horizon/horizon-agent.py start
# [...]
# python /opt/skyline/bin/../src/analyzer/analyzer-agent.py start
# [...]
# python /opt/skyline/bin/../src/webapp/webapp.py restart
# /usr/sbin/httpd -DFOREGROUND
# [...]
# /bin/python bin/carbon-relay.py --instance=a start
# /bin/python bin/carbon-cache.py --instance=a start
# [...]

Conclusion

Skyline is the first of its kind: it detects anomalies and trigger alarms in real time. Skyline is definitively trying to build a better world, where DevOps don’t need to spend their time watching metrics!

But there are some drawbacks. It only detects very obvious anomalies. This isn’t too bad, as many anomalies are obvious, but it will still fail to detect complex anomalies. the idea was to build a solution you can extend with homemade detectors, but no third party detectors have yet been released, so we are stuck with the basic functionality.

Of course I’m biased, but for easier monitoring and detection of many other anomaly types, I recommend using our product “Anomaly.io”. We believe it beats Skyline in every way.

The post Detecting Anomalies with Skyline appeared first on Anomaly.

]]>
https://anomaly.io/detect-anomalies-skyline/feed/ 2
Installing Graphite on CentOShttps://anomaly.io/install-graphite-centos/ https://anomaly.io/install-graphite-centos/#comments Tue, 28 Jul 2015 12:59:59 +0000 https://anomaly.io/?p=2721 The post Installing Graphite on CentOS appeared first on Anomaly.

]]>

Install Graphite
on centOS

Graphite is a very powerful set of tools for monitoring and graphing server performance created in 2006. Graphite is still wildly used, but it’s now falling behind more modern monitoring solutions such as the trendy solution InfluxDB / Graphana.

Graphite Architecture

Graphite is a set of monitoring tools composed of:

  • carbon – A (few) daemons in charge of listening for data (TCP/UDP)
  • whisper – A database library for storing time series data
  • graphite webapp – A Django webapp that renders graphs

graphite achitecture

CollectD can be used to record and push monitoring metrics into carbon-cache.

Install Graphite

Requirement

Open a terminal and install the required tools:

sudo yum -y update
sudo yum -y install httpd gcc gcc-c++ git pycairo mod_wsgi epel-release
sudo yum -y install python-pip python-devel blas-devel lapack-devel libffi-devel

Download and install Graphite

The following code snippet will download the last version of Graphite (carbon and web) and install writy my essay it all into /opt/graphite:

cd /usr/local/src
sudo git clone https://github.com/graphite-project/graphite-web.git
sudo git clone https://github.com/graphite-project/carbon.git

sudo pip install -r /usr/local/src/graphite-web/requirements.txt

cd /usr/local/src/carbon/
sudo python setup.py install

cd /usr/local/src/graphite-web/
sudo python setup.py install

sudo cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf
sudo cp /opt/graphite/conf/storage-schemas.conf.example /opt/graphite/conf/storage-schemas.conf
sudo cp /opt/graphite/conf/storage-aggregation.conf.example /opt/graphite/conf/storage-aggregation.conf
sudo cp /opt/graphite/conf/relay-rules.conf.example /opt/graphite/conf/relay-rules.conf
sudo cp /opt/graphite/webapp/graphite/local_settings.py.example /opt/graphite/webapp/graphite/local_settings.py
sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
sudo cp /opt/graphite/examples/example-graphite-vhost.conf /etc/httpd/conf.d/graphite.conf

sudo cp /usr/local/src/carbon/distro/redhat/init.d/carbon-* /etc/init.d/
sudo chmod +x /etc/init.d/carbon-*

Configure Graphite

This code snippet creates the local database (SQLite). It also imports some static content for Graphite-webapp, and write my essay creates some folders with the correct permissions.

cd /opt/graphite
#create database
sudo PYTHONPATH=/opt/graphite/webapp/ django-admin.py syncdb --settings=graphite.settings
#reply: "Yes" and enter
#user: root
#passwd: myPassword

#import static files
sudo PYTHONPATH=/opt/graphite/webapp/ django-admin.py collectstatic --settings=graphite.settings
# reply "yes"

#set permission
sudo chown -R apache:apache /opt/graphite/storage/
sudo chown -R apache:apache /opt/graphite/static/
sudo chown -R apache:apache /opt/graphite/webapp/

By default, the Apache package provided in CentOS is restrictive with regard to directory aliases. Edit graphite Apache conf to allow the static directory:

sudo vim /etc/httpd/conf.d/graphite.conf

[...]
 Alias /static/ /opt/graphite/static/

   Require all granted

   Order allow,deny
   Allow from all
   Require all granted

[...]

Start Graphite

Carbon’s daemons can be started with systemd. Graphite-WebApp is an apache website. To start both simply run:

sudo systemctl start carbon-cache

sudo systemctl enable httpd
sudo systemctl start httpd

Access Graphite-WebApp

Open your browser at http://localhost/

Warning! To access a remote IP such as http://remote_ip/ you need to set rules in the CentOS default firewall, or simply disable it:

#disable firewall
sudo systemctl disable firewalld
sudo systemctl stop firewalld

No data should be available yet as we haven’t sent any metrics to Graphite.

graphite webapp

Send Metrics to Graphite

Install CollectD

To collect and push metrics to Graphite, we like to use CollectD. To install CollectD, follow these easy instructions:

Configure CollectD

If you followed the instructions to install CollectD on CentOS, edit the configuration file located in /opt/collectd/etc/collectd.conf. Using the write_graphite plugin, forward CollectD metrics to Graphite on port 2003:

sudo vim /opt/collectd/etc/collectd.conf

# edit file
[...]
LoadPlugin write_graphite
[...]

   Host "localhost"
   Port "2003"
   Prefix "collectd."
   Protocol "tcp"

Start CollectD

If you installed the systemd script, simply run:

sudo systemctl start collectd.service

 You can also start CollectD manually with:

sudo /opt/collectd/sbin/collectd

Wait a few seconds, then open Graphite-WebApp. You should see some new metrics in the left panel. Open one of them to render it.
Warming! by default Graphite-WebApp renders a 24 hour graph. To see some data points, zoom in or wait a bit longer.

graphite graph

Troubleshooting

If you follow the steps above exactly, everything should work just fine. If you don’t see any data in Graphite, try a few of these ideas.

Restart CollectD with Logging

Edit CollectD configuration and enable logging:

sudo vim /opt/collectd/etc/collectd.conf

# edit file
[...]
LoadPlugin syslog
LoadPlugin logfile

  LogLevel info
  File STDOUT
  Timestamp true
  PrintSeverity false

  LogLevel info

[...]

#start CollectD in foreground
/opt/collectd/sbin/collectd -f

You shouldn’t see any messages like “write_graphite plugin: Connecting to localhost:2013 via tcp failed. The last error was: failed to connect to remote host: Connection refused”

Check Carbon-cache

Check the carbon-cache log:

less +F /opt/graphite/storage/log/carbon-cache/carbon-cache-a/console.log

Check Graphite-WebApp log

less +F /opt/graphite/storage/log/webapp/error.log

Check that All Processes are Running

Make sure every necessary process is running:

ps aux | grep "carbon-ca\|httpd\|collectd\|(wsgi:graphite)"

#result somthing like:
# /usr/sbin/httpd -DFOREGROUND
# (wsgi:graphite) -DFOREGROUND
# [...]
# sudo /opt/collectd/sbin/collectd -C /opt/collectd/etc/collectd.conf -f
# /opt/collectd/sbin/collectd -C /opt/collectd/etc/collectd.conf -f
# /usr/sbin/httpd -DFOREGROUND
# [...]
# /bin/python bin/carbon-cache.py --instance=a start

Conclusion

Graphite is an incredible tool: easy to install, fast and flexible. Since its creation in 2006 it has seen the development of many plugins and tools. But it is getting a bit outdated by the next generation of monitoring tools, such as the trendy Grafana / Influx, which promise more flexibility and scalability.

The problem with graphite: it’s easy to monitor, but you need to spend your time watching all metrics to spot malfunctions. To solve this problem you could install Skyline to detect anomalies, but this will only detect (very) obvious problems. To monitor and detect complex anomalies in real time, sign up with Anomaly.io.

The post Installing Graphite on CentOS appeared first on Anomaly.

]]>
https://anomaly.io/install-graphite-centos/feed/ 0
SQL Database Monitoring with CollectD and MySQLhttps://anomaly.io/sql-monitoring-collectd/ https://anomaly.io/sql-monitoring-collectd/#comments Tue, 26 May 2015 10:21:17 +0000 https://anomaly.io/?p=2366 The post SQL Database Monitoring with CollectD and MySQL appeared first on Anomaly.

]]>

database monitoring collectd

The CollectD DBI Plugin executes custom SQL queries to generate metrics from most relational databases. Over any interval of time, the result of SQL requests such as “SELECT count(*) FROM pageview” is reported. The difference between successive call results is the number of events recorded in the database over the specified time period.

Because it’s widely used, MySQL will be used for this example, but this also works for:

DBI Plugin Example

On our website, each time a user performs a pageview, edit or postcomment action we save it in the interaction table. A user can belong to one of the groups admin, user or guest. Using CollectD DBI Plugin and some custom SQL requests, we can monitor what is happening in our MySQL database.

SELECT event_type, count(user_id) AS value
FROM interaction GROUP BY event_type;
+-------------+-------+
| event_type  | value |
+-------------+-------+
| edit        |     1 |
| pageview    |     8 |
| postcomment |     2 |
+-------------+-------+

SELECT 'visitor.pageview' as c_key , count(*) AS c_value
FROM interaction WHERE event_type = "pageview";
+------------------+---------+
| c_key            | c_value |
+------------------+---------+
| visitor.pageview |       8 |
+------------------+---------+

(Optional) To get the exactly same result, download the database dump and import in MySQL:

$ mysql --user=root -p
mysql> create database mydb;
mysql> exit
$ mysql --user=root -p mydb < import.sql
$ mysql --user=root -p
mysql> use mydb;
mysql> SELECT * FROM interaction;
+---------+------------+-------------+---------------------+
| user_id | group_name | event_type  | event_date          |
+---------+------------+-------------+---------------------+
|       1 | admin      | edit        | 2015-05-25 15:45:14 |
|       1 | admin      | pageview    | 2015-05-25 15:45:14 |
|       1 | admin      | postcomment | 2015-05-25 15:45:14 |
|       2 | user       | pageview    | 2015-05-25 15:45:14 |
|       2 | user       | pageview    | 2015-05-25 15:45:14 |
|       2 | user       | pageview    | 2015-05-25 15:45:14 |
|       3 | user       | pageview    | 2015-05-25 15:45:14 |
|       3 | user       | postcomment | 2015-05-25 15:45:14 |
|       4 | guest      | pageview    | 2015-05-25 15:45:14 |
|       5 | guest      | pageview    | 2015-05-25 15:45:14 |
|       5 | guest      | pageview    | 2015-05-25 15:45:14 |
+---------+------------+-------------+---------------------+

Executing both SQL requests every second produces new monitoring metrics:

  • event_type.edit
  • event_type.pageview
  • event_type.postcomment
  • visitor.pageview

Install Plugin DBI for CollectD

To query our MySQL database with Plugin DBI we will need to recompile CollectD with some extra dependencies:

apt-get install libdbi-dev
apt-get install libdbd-mysql

# For other databases
# apt-get install libdbd-pgsql
# apt-get install libdbd-sqlite
# apt-get install libdbd-sqlite3

After the dependencies are installed, install CollectD as usual:

During CollectD compilation ./configure you should see:

[...]
 curl . . . . . . . . no
 curl_json . . . . . . no
 curl_xml . . . . . . no
 dbi . . . . . . . . . yes
[...]

Configure and Start the Plugin DBI

Edit the CollectD configuration, usually located at /opt/collectd/etc/collectd.conf

<Query "interaction_stats">
   Statement "SELECT event_type, count(user_id) AS value FROM interaction GROUP BY event_type"
   
   Type "gauge"
   InstancesFrom "event_type"
   ValuesFrom "value"
   
 
 <Query "pageview">
   Statement "SELECT 'visitor.pageview' as c_key ,count(*) AS c_value FROM interaction WHERE event_type = 'pageview'"
   
   Type "gauge"
   InstancesFrom "c_key"
   ValuesFrom "c_value"
   
 

 <Database "sessionmetrics">
   Driver "mysql"
   DriverOption "host" "localhost"
   DriverOption "username" "root"
   DriverOption "password" "mypassword"
   DriverOption "dbname" "mydb"
   Query "interaction_stats"
   Query "pageview"

Now restart CollectD:

$ # using systemd
$ service collectd restart
$ 
$ # or manually
$ /opt/collectd/sbin/collectd -C /opt/collectd/etc/collectd.conf

For troubleshooting, add this configuration:

LoadPlugin logfile

 LogLevel info
 File STDOUT

And start CollectD in the foreground:

$
$ /opt/collectd/sbin/collectd -C /opt/collectd/etc/collectd.conf -f
$

Metrics Dashboard

At this point, integrating with a monitoring dashboard should be easy. To record MySQL request results, we chose the excellent InfluxDB. For displaying the metrics from InfluxDB, we chose Grafana.

To graph the MySQL metrics you will need to:

  1. Install CollectD on Debian or CentOS
  2. Install InfluxDB from source (or from InfluxDB)
  3. Send CollectD metrics to InfluxDB
  4. Install and Configure Grafana with InfluxDB

Optional: You don’t have to use InfluxDB/Grafana. CollectD integrates with many time series databases. It is fairly easy to integrate with different time series databases / monitoring dashboards.

Fake some user activity in MySQL:

INSERT INTO `interaction` (`user_id`, `group_name`, `event_type`) VALUES
(4, 'guest', 'pageview');

With more pageviews, the value should increase:

count MySQL request

We can use InfluxDB DIFFERENCE aggregator to highlight events accruing in real time.

difference MySQL request

Open the Grafana web UI. Replicate the InfluxDB request:
SELECT difference(value) FROM dbi_value WHERE type_instance=’visitor.pageview’ AND $timeFilter GROUP BY time($interval) ORDER ASC;

Grafana MySQL monitoring

Done! We can watch our pageviews per second update in real time. Proceed the exact same way for the postcomment, pageview and edit metrics.

Conclusion

Code monitoring with StatsD is easy to install and configure. It’s even easier since CollectD now embeds a StatsD implementation.
But making code changes is a bit painful.

With CollectD DBI Plugin, it becomes possible to monitor an application, or at least its output, without any code changes. Any SQL request that generate numbers can be used to produce new metrics.

It is definitively a good starting point into application monitoring since it requires no code changes. However, it can also be considered an advance technique for monitoring what’s really happening within the database.

The post SQL Database Monitoring with CollectD and MySQL appeared first on Anomaly.

]]>
https://anomaly.io/sql-monitoring-collectd/feed/ 0
StatsD Embedded into CollectDhttps://anomaly.io/statsd-in-collectd/ https://anomaly.io/statsd-in-collectd/#comments Sat, 23 May 2015 18:17:45 +0000 https://anomaly.io/?p=2307 The post StatsD Embedded into CollectD appeared first on Anomaly.

]]>

embedded StatsD in CollectD
Since version 5.4, CollectD implements the StatsD network protocol. This means that you might not need to run two separate processes anymore.

About StatsD in CollectD

StatsD and CollectD are complementary monitoring solutions:

  • Stats is an event counter/aggregation service. Simply send events to this external service to monitor your own code. The aggregated events are periodically sent to a database.
  • CollectD is a statistics collection daemon. It periodically polls various sources, such as your OS, CPU, RAM, and network, but also many databases and software.

StatsD is also “embedded” into CollectD since v5.4 with the StatsD plugin. CollectD can now act as a StatsD process.

Install StatsD Plugin for CollectD

Edit the CollectD configuration file usually located at /opt/collectd/etc/collectd.conf

Uncomment or add StatsD plugin and configuration:

LoadPlugin statsd

  Host "0.0.0.0"
  Port "8125"
  DeleteSets     true

Don’t forget to restart CollectD:

$ 
$ service collectd restart
$

  • Host “0.0.0.0”: Listen to any IP. Change to “127.0.0.1” to only allow localhost to send metrics.
  • port 8125: Where StatsD metrics will be received.
  • DeleteSets true: The values of type sets metrics will not be sent if they didn’t change since the last interval.

Read more about StatsD plugin configuration.

Calling CollectD StatsD

Many StatsD client libraries exist in various programming languages. Pick your favorite and call StatsD on port 8125. It’s also possible to call the plugin from the command line:

$
$ echo "my.own.metric:1|c" | nc -w 1 -u 127.0.0.1 8125
$ echo "my.own.metric:4|c" | nc -w 1 -u 127.0.0.1 8125
$

If, like us, your CollectD sends its metrics to InfluxDB, you should see the values in your database.

Calling both commands:

  • Within the interval will result in an aggregate value of 5
  • Out of the interval will result in two values: 4 and 1

influxdb statsd aggregated

Conclusion

StatsD is a very clever idea implemented in simple software. It behavior was replicated in 730 lines of C.

This Plugin is stable and was able to achieve 50k events per second on commodity hardware. If you already run CollectD and don’t need to run StatsD at scale it is highly recommended that you use this plugin to save yourself the pain of running both services.

The post StatsD Embedded into CollectD appeared first on Anomaly.

]]>
https://anomaly.io/statsd-in-collectd/feed/ 0
InfluxDB Configuration Example with CollectDhttps://anomaly.io/influxdb-configuration-collectd/ https://anomaly.io/influxdb-configuration-collectd/#comments Tue, 14 Apr 2015 15:23:28 +0000 http://anomalyts.io/?p=2013 The post InfluxDB Configuration Example with CollectD appeared first on Anomaly.

]]>

Note that this is just an InfluxDB configuration example. Change it to suit your own needs.

Run InfluxDB with its configuration file:

influxd -config="config.toml"

With this configuration InfluxDB will:

  • Not require any login/password to read and write to the database
  • Listen to commands on port 8066
  • Listen to CollectD metrics on port 25826
  • Save CollectD metrics in “collectd_db”  (InfluxDB database must exist)
  • Run the admin web interface on port 8083
  • Record on disk in the /var/opt/influxdb/ directory

# Welcome to the InfluxDB configuration file.

# If hostname (on the OS) doesn't return a name that can be resolved by the other
# systems in the cluster, you'll have to set the hostname to an IP or something
# that can be resolved here.
# hostname = ""
bind-address = "0.0.0.0"

# The default cluster and API port
port = 8086

# Once every 24 hours InfluxDB will report anonymous data to m.influxdb.com
# The data includes raft id (random 8 bytes), os, arch and version
# We don't track ip addresses of servers reporting. This is only used
# to track the number of instances running and the versions, which
# is very helpful for us.
# Change this option to true to disable reporting.
reporting-disabled = false

# Controls settings for initial start-up. Once a node is successfully started,
# these settings are ignored.  If a node is started with the -join flag,
# these settings are ignored.
[initialization]
join-urls = "" # Comma-delimited URLs, in the form http://host:port, for joining another cluster.

# Control authentication
# If not set authetication is DISABLED. Be sure to explicitly set this flag to
# true if you want authentication.
[authentication]
enabled = false

# Configure the admin server
[admin]
enabled = true
port = 8083

# Configure the HTTP API endpoint. All time-series data and queries uses this endpoint.
[api]
# ssl-port = 8087    # SSL support is enabled if you set a port and cert
# ssl-cert = "/path/to/cert.pem"

# Configure the Graphite plugins.
[[graphite]] # 1 or more of these sections may be present.
enabled = false
# protocol = "" # Set to "tcp" or "udp"
# address = "0.0.0.0" # If not set, is actually set to bind-address.
# port = 2003
# name-position = "last"
# name-separator = "-"
# database = ""  # store graphite data in this database

# Configure the collectd input.
[collectd]
enabled = true
#address = "0.0.0.0" # If not set, is actually set to bind-address.
port = 25826
database = "collectd_db"
typesdb = "/opt/collectd/share/collectd/types.db"

# Configure the OpenTSDB input.
[opentsdb]
enabled = false
#address = "0.0.0.0" # If not set, is actually set to bind-address.
#port = 4242
#database = "opentsdb_database"

# Configure UDP listener for series data.
[udp]
enabled = false
#bind-address = "0.0.0.0"
#port = 4444

# Broker configuration. Brokers are nodes which participate in distributed
# consensus.
[broker]
enabled = true
# Where the Raft logs are stored. The user running InfluxDB will need read/write access.
dir  = "/var/opt/influxdb/raft"

# Data node configuration. Data nodes are where the time-series data, in the form of
# shards, is stored.
[data]
enabled = true
dir = "/var/opt/influxdb/db"

# Auto-create a retention policy when a database is created. Defaults to true.
retention-auto-create = true

# Control whether retention policies are enforced and how long the system waits between
# enforcing those policies.
retention-check-enabled = true
retention-check-period = "10m"

# Configuration for snapshot endpoint.
[snapshot]
enabled = true # Enabled by default if not set.
bind-address = "127.0.0.1"
port = 8087

[logging]
write-tracing = false # If true, enables detailed logging of the write system.
raft-tracing = false # If true, enables detailed logging of Raft consensus.

# InfluxDB can store statistical and diagnostic information about itself. This is useful for
# monitoring purposes. This feature is disabled by default, but if enabled, these data can be
# queried like any other data.
[monitoring]
enabled = false
write-interval = "1m"          # Period between writing the data.

The post InfluxDB Configuration Example with CollectD appeared first on Anomaly.

]]>
https://anomaly.io/influxdb-configuration-collectd/feed/ 0
Sending CollectD Metrics to InfluxDBhttps://anomaly.io/collectd-metrics-to-influxdb/ https://anomaly.io/collectd-metrics-to-influxdb/#comments Mon, 13 Apr 2015 15:56:56 +0000 http://anomalyts.io/?p=1996 The post Sending CollectD Metrics to InfluxDB appeared first on Anomaly.

]]>

collectd metrics to influxdb

With the right configuration, CollectdD can save its metrics into InfluxDB, which can then be used as a data source for monitoring visualization.

Requirements

First, uou need CollectD to be installed on your server. Here is how to install CollectD on Debian / Ubuntu and how to install CollectD on CentOS / Fedora.

You don’t need any special configuration of CollectD, as it monitors the basics by default. But if you want you can configure CollectD for more system monitoring.

Send Metrics from CollectD

By default Collectd configuration is located at /opt/collectd/etc/collectd.conf or /etc/collectd.conf
Edit this configuration file.

If the network plugin isn’t loaded already, add it:

LoadPlugin network

Also add the network plugin configuration:

<Plugin "network">
    Server "myinfluxdb.com" "25826"

Localhost is the URL or IP address of your InfluxDB server, while 25826 is the port where InfluxDB will listen for CollectD metrics.

Receiving Metrics in InfluxDB

Upon InfluxDB startup, you should provide a config.toml file to overwrite default settings.
Start InfluxDB with your configuration or using this InfluxDB configuration example:

influxd -config="config.toml"

Edit config.toml and edit the [collectd] part; it should look like this:

[collectd]
enabled = true
port = 25826
database = "collectd_db"
typesdb = "/opt/collectd/share/collectd/types.db"

  • port = 25826; Make sure InfluxDB listens to the same port upon which CollectD is sending (see CollectD configuration above).
  • database = “collectd_db”; InfluxDB will write CollectD metrics into the “collectd_db” database.
    We will need to create this database in InfluxDB.
  • typesdb = “/opt/collectd/share/collectd/types.db”; this file defines how CollectD metrics are structured. It will help InfluxDB to save CollectD metrics correctly in the database.

Start CollectD and InfluxDB

Start InfluxDB with:

influxd -config="config.toml"

Start CollectD on Debian / Ubuntu or on CentOS / Fedora:

#Debian/Ubuntu
service collectd start

#or CentOS/Fedora
systemctl start collectd.service

#or manualy
/opt/collectd/sbin/collectd -C /opt/collectd/etc/collectd.conf -f

With these settings, InfluxDB will write to a database called “collectd_db”.
Log in to the webadmin myinfluxdb.com:8083 (default credentials: root / root) to create the “collectd_db” database.

You can also create the database from the command line:

curl -G http://myinfluxdb.com:8086/query --data-urlencode "q=CREATE DATABASE collectd_db"

Now InfluxDB should receive and save CollectD metrics. Check this out from the command line:

curl -G http://myinfluxdb:8086/query?pretty=true --data-urlencode "db=collectd_db" --data-urlencode "q=show series"

or execute the command show series in the webadmin.

influxdb with collectd metrics2

Live Dashboard

InfluxDB now records CollectdD metrics. The next step is to choose a dashboard to watch the metrics in real time.

We recommend using Grafana with InfluxDB

The post Sending CollectD Metrics to InfluxDB appeared first on Anomaly.

]]>
https://anomaly.io/collectd-metrics-to-influxdb/feed/ 4
Collectd Configuration for System Monitoringhttps://anomaly.io/collectd-config-system-monitoring/ https://anomaly.io/collectd-config-system-monitoring/#comments Mon, 13 Apr 2015 11:05:02 +0000 http://anomalyts.io/?p=1965 The post Collectd Configuration for System Monitoring appeared first on Anomaly.

]]>

system-monitoring-collectd

When you install CollectD, its default configuration already allows it to collect a lot of metrics from your system.
Today we will review this default configuration and change it to collect even more.

Requirements

First, collectd need to be installed on your server.
Here is how to install collectd on Debian / Ubuntu.
It’s also easy to install collectd on CentOS / Fedora.

Edit CollectD Configuration

By default, the collectd configuration is located in /opt/collectd/etc/collectd.conf
Make it look like this collectd configuration example:

Interval     1

LoadPlugin conntrack
LoadPlugin cpu
LoadPlugin df
LoadPlugin disk
LoadPlugin filecount
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin processes
LoadPlugin swap
LoadPlugin tcpconns
LoadPlugin uptime
LoadPlugin users


<Plugin filecount>
 <Directory "/var/">
   Recursive true
 </Directory>
</Plugin>

<Plugin tcpconns>
 LocalPort "80"
</Plugin>

Let’s review this configuration.

Interval 1
Collectd will record server performance every second. The default is 10 seconds but 1 second enables quicker anomaly detection.
Running CollectD every second will require a bit more CPU, but on modern hardware this is negligible.

LoadPlugin cpu
Records CPU activity, such as user, nice, system, idle, wait, interrupt, softirq and steal.

LoadPlugin df
Collects information such as the free, reserved and used space of your filesystems (including hard drives)

LoadPlugin filecount
Collects the total size and number of files in a directory. In this configuration we track the directory /var.

LoadPlugin interface
Collect network trafic, download and upload. Records the number of octets, packets and errors for transmission and reception on all network interfaces.

LoadPlugin load
Similar to the load on a UNIX server. Records the CPU load for the last minute, last 15 minutes and last 30 minutes.

LoadPlugin memory
Collects information about the used, buffered, cached and free RAM memory.

LoadPlugin processes
Tracks the number of running, blocked, sleeping, paging, stopped and zombie processes.

LoadPlugin swap
Records the free, cached and used swap space.

LoadPlugin tcpconns
Counts the number of TCP connections on a specified port. With our configuration we record all activity on port 80 (HTTP).

LoadPlugin uptime
Tracks how long your server has been up. Convenient for detecting anomalies when your server crashes.

LoadPlugin users
Collects the number of users logged on the server

Send Metrics to Database

To use collectd you need to send its metrics frequently to a database for monitoring and visualization:

The post Collectd Configuration for System Monitoring appeared first on Anomaly.

]]>
https://anomaly.io/collectd-config-system-monitoring/feed/ 0
How to Install CollectD on CentOS / Fedorahttps://anomaly.io/install-collectd-on-centos-fedora/ https://anomaly.io/install-collectd-on-centos-fedora/#comments Thu, 09 Apr 2015 05:42:50 +0000 http://anomalyts.io/?p=1933 The post How to Install CollectD on CentOS / Fedora appeared first on Anomaly.

]]>

install collectd on centos and fedora
CollectD is one of the best daemons for regularly collecting system metrics. Today we will focus on installing and running CollectD the easy way on Linux Redhat’s CentOS and Fedora.

Install CollectD

Since we will compile CollectD from source, we need a compiler:

sudo yum install -y bzip2 wget
sudo yum install -y make automake gcc gcc-c++ kernel-devel perl-devel

Next we download CollectD 5.5.0:

cd /tmp/
wget https://collectd.org/files/collectd-5.5.0.tar.bz2
tar -jxf collectd-5.5.0.tar.bz2
cd collectd-5.5.0

The Fedora compiler might yield warnings as errors like these:
error: #warning “_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE” [-Werror=cpp]
If so you will need to disable warnings as errors first before you run ./configure

export CFLAGS="-Wno-error"

Now compile and install:

sudo ./configure
sudo make all install

Start CollectD on Startup

The easy way to manage CollectD on CentOS and Fedora is by using systemd.

cd /etc/systemd/system/
sudo wget https://raw.githubusercontent.com/martin-magakian/collectd-script/master/collectd.service
sudo chmod +x collectd.service

CollectD will now run at startup, but you can still manage it manually:

systemctl start collectd.service
systemctl stop collectd.service
systemctl status collectd.service
systemctl restart collectd.service

By default you will find:

  • The configuration file at /opt/collectd/etc/collectd.conf
  • The collectd binary at /opt/collectd/sbin/collectd

Send Metrics to Database

To use CollectD You need to send its metrics frequently to a database for monitoring:

System and App Monitoring with CollectD

By default CollectD only monitors CPU, memory, interface and load.
You can configure CollectD to monitor much more:

The post How to Install CollectD on CentOS / Fedora appeared first on Anomaly.

]]>
https://anomaly.io/install-collectd-on-centos-fedora/feed/ 0
How to install CollectD on Debian / Ubuntuhttps://anomaly.io/install-collectd-on-debian-ubuntu/ https://anomaly.io/install-collectd-on-debian-ubuntu/#comments Sat, 04 Apr 2015 16:25:54 +0000 http://anomalyts.io/?p=1919 The post How to install CollectD on Debian / Ubuntu appeared first on Anomaly.

]]>

install collectd on debian and ubuntu
CollectD is one of the best daemons for collecting system metrics periodically.
Today we will focus on installing and running CollectD on Debian Linux the easy way.

Install CollectD

Since we will compile CollectD from source, we need a compiler:

sudo apt-get install build-essential

Next we download, compile and install CollectD 5.5.0:

cd /tmp/
wget https://collectd.org/files/collectd-5.5.0.tar.bz2
tar -jxf collectd-5.5.0.tar.bz2
cd collectd-5.5.0

sudo ./configure
sudo make all install

By default you will find:

  • The configuration file at /opt/collectd/etc/collectd.conf
  • The collectd binary at /opt/collectd/sbin/collectd

Start CollectD on startup

An easier way to manage CollectD on Debian is using an init script.

sudo wget -O /etc/init.d/collectd https://raw.githubusercontent.com/martin-magakian/collectd-script/master/collectd.init
sudo chmod 744 /etc/init.d/collectd

CollectD will now run at startup, but you can still manage it manually:

service collectd start
service collectd stop
service collectd status
service collectd restart

Send Metrics to Database

CollectD is pretty useless by itself. You need to send its metrics frequently to a database for monitoring:

System and App monitoring with CollectD

By default CollectD only monitors CPU, memory, interface and load.
You can configure CollectD to monitor much more:

The post How to install CollectD on Debian / Ubuntu appeared first on Anomaly.

]]>
https://anomaly.io/install-collectd-on-debian-ubuntu/feed/ 0