You are on page 1of 34

collectd-> InfluxDB) -> Grafana

InfluxDB Go

v0.8.8

collectd C

Grafana Javascript InfluxDB

collectd InfluxDB Grafana

InfluxDB

server 172.18.1.113

InfluxDB Grafana

Client 172.18.2.125

Collectd

server

influxdb
1 YUM

cat <<EOF |tee /etc/yum.repos.d/influxdb.repo

[influxdb]

name = InfluxDB Repository - RHEL \$releasever

baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable

enabled = 1

gpgcheck = 1

gpgkey = https://repos.influxdata.com/influxdb.key

EOF

#yum install -y influxdb

#service influxdb start

web http://172.18.1.113:8083/

API 172.18.1.113:8086

/etc/influxdb/influxdb.conf

grafana
1.RPM

#wget https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0-1.x86_64.rpm

#rpm -Uvh grafana-2.6.0-1.x86_64.rpm

/var/log/grafana/grafana.log

/etc/grafana/grafana.ini

#vim /etc/grafana/grafana.ini

// 3000

http_port = 3001

#/etc/init.d/grafana-server restart

http://172.18.1.113:3001
Client

collectd Linux YUM

#yum insatll -y collectd


InfluxDB collectd

InfluxDB collectd collectd 0.8.4

influxdb-collectd-proxy collectd InfluxDB.

InfluxDB collectd enabled = true database =

collectd collectd InfluxDB

influxdb 25826 InfluxDB

25826

#vim /etc/influxdb/influxdb.conf

[collectd]

enabled = true

bind-address = ":25826"

database = "collectd"

# types.db can be found in a collectd installation or on github:

# https://github.com/collectd/collectd/blob/master/src/types.db

#types.db

typesdb = "/usr/share/collectd/types.db"
batch-size = 5000 # will flush if this many points get buffered

batch-pending = 10 # number of batches that may be pending in memory

batch-timeout = "10s" # will flush at least this often even if we haven't hit buffer limit

read-buffer = 0 # UDP Read buffer size, 0 means OS default. UDP listener will fail if set above OS max.

#service influxdb restart

influxdb

[httpd] 2016/02/26 09:47:39 Starting HTTP service

[httpd] 2016/02/26 09:47:39 Authentication enabled: false

[httpd] 2016/02/26 09:47:39 Listening on HTTP: [::]:8086

[collectd] 2016/02/26 09:47:39 Starting collectd service

[collectd] 2016/02/26 09:47:39 Listening on UDP: [::]:25826

collectd

http://172.18.1.113:8083/ collectd grafana


client collectd

YUM

#vim /etc/collectd.conf

LoadPlugin load

LoadPlugin memory

LoadPlugin network

// network

<Plugin network>

Server "172.18.1.113" "25826"

</Plugin>

/etc/init.d/collectd restart

influxdb WEB

# influx

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 0.10.1

InfluxDB shell 0.10.1

> show databases;

name: databases

---------------

name

_internal

collectd

grafana

> use collectd;

Using database collectd

> select * from /load/;

1456491843000000000 t125 load 0

1456491853000000000 t125 load 0

1456491863000000000 t125 load 0


1456491873000000000 t125 load 0

1456491883000000000 t125 load 0

1456491893000000000 t125 load 0

1456491903000000000 t125 load 0

1456491913000000000 t125 load 0

1456491923000000000 t125 load 0

1456491933000000000 t125 load 0

1456491943000000000 t125 load 0

1456491953000000000 t125 load 0

1456491963000000000 t125 load 0

1456491973000000000 t125 load 0

1456491983000000000 t125 load 0

grafana

test connection
c
dashboard

Panel


[] collectd + InfluxDB + Grafana

RRD

MRTG CactiRRD

Cacti 24 :

24 :

RRD

ELK stack ELK stack Elasticsearch

() collectd + InfluxDB + Grafana

Grafana ELK Kibana

InfluxDB GraphiteOpenTSDB Elasticsearch

collectd InfluxDB

Grafana

CentOS 7 collectd + InfluxDB + Grafana

(IP 192.168.111.241)

InfluxDB

1. RPM Repo InfluxDB

1 cat<<EOF>/etc/yum.repos.d/influxdb.repo

2 [influxdb]

3 name = InfluxDB Repository - RHEL $releasever

4 baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable

5 enabled = 1

6 gpgcheck = 1
7 gpgkey = https://repos.influxdata.com/influxdb.key

8 EOF

9 yum install influxdb -y

10systemctl enable influxdb.service

11systemctl start influxdb.service

2.

cat<<EOF>/etc/firewalld/services/influxdb.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<service>
3
<short>InfluxDB</short>
4
<description>InfluxDB is an open source time series database with no external
5
dependencies. It's useful for recording metrics, events, and performing
6
analytics.</description>
7
<port protocol="tcp" port="8083"/>
8
<port protocol="tcp" port="8086"/>
9
</service>
10
EOF
11
chmod 600 /etc/firewalld/services/influxdb.xml
12
firewall-cmd --add-service=influxdb --permanent
firewall-cmd --reload

3. influx influxdb

1create user admin with password 'password' with all privileges;

2exit

4. influxdb http://192.168.111.241:8083

Grafana

1. RPM Repo Grafana

1 cat<<EOF>/etc/yum.repos.d/grafana.repo
2 [grafana]

3 name=grafana

4 baseurl=https://packagecloud.io/grafana/stable/el/6/\$basearch

5 repo_gpgcheck=1

6 enabled=1

7 gpgcheck=1

8 gpgkey=https://packagecloud.io/gpg.key

9 https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana

10sslverify=1

11sslcacert=/etc/pki/tls/certs/ca-bundle.crt

12EOF

13yum install grafana y

14systemctl enable grafana-server.service

systemctl start grafana-server.service

2.

1 cat<<EOF>/etc/firewalld/services/grafana.xml

2 <?xml version="1.0" encoding="utf-8"?>

3 <service>

4 <short>Grafana</short>
5 <description>Grafana provides a powerful and elegant way to create, explore,

6 and share dashboards and data with your team and the world.</description>

7 <port protocol="tcp" port="3000"/>

8 </service>

9 EOF

10chmod 600 /etc/firewalld/services/grafana.xml

11firewall-cmd --add-service=grafana --permanent

firewall-cmd --reload

influxdb collectd plugin

1. collectd

1yum install collectd -y

2. /etc/influxdb/influxdb.conf [[collectd]]

1enabled = false

1 enabled = true

2 bind-address = ":25826" # the bind address

3 database = "collections" # Name of the database that will be written to

4 retention-policy = ""

5 batch-size = 5000 # will flush if this many points get buffered

6 batch-pending = 10 # number of batches that may be pending in memory

7 batch-timeout = "10s"

8 read-buffer = 0 # UDP read buffer size, 0 means to use OS default

9 typesdb = "/usr/share/collectd/types.db"

10#enabled = false

3.

1systemctl restart influxdb.service

4.

1 cat<<EOF>/etc/firewalld/services/collectd.xml

2 <?xml version="1.0" encoding="utf-8"?>

3 <service>
4 <short>collectd</short>

5 <description>collectd daemon for InfluxDB</description>

6 <port protocol="udp" port="25826"/>

7 </service>

8 EOF

9 firewall-cmd --add-service=collectd --permanent

10firewall-cmd --reload

5. influx influxdb

1CREATE DATABASE collections

2CREATE USER collectdrw WITH PASSWORD 'readwrite'

3GRANT ALL ON collections to collectdrw

4CREATE USER collectdread WITH PASSWORD 'readonly'

5GRANT READ ON collections TO collectdread

6exit

collectd for influxdb

1. collectd

InfluxDB
?

1 cat<<EOF>/etc/collectd.d/network.conf

2 Hostname "grafana"

3 FQDNLookup false

4 LoadPlugin network

5 LoadPlugin uptime

6 <Plugin network>

7 Server "192.168.111.241" "25826"

8 </Plugin>

9 EOF

10systemctl enable collectd.service

11systemctl start collectd.service

2. influxdb Database

collections
3. collections Query Templates Show Measurements

4. Enter collections cpu_value

5. SHOW TAG KEYS FROM "cpu_value" Enter

cpu_value key hostinstancetype


type_instance

6. SHOW TAG VALUES FROM "cpu_value" WITH KEY = "host"

Enter host key grafana

collectd

7. SHOW TAG VALUES FROM "cpu_value" WITH KEY = "host"

Enter InfluxDB collectd


Grafana Dashboard

1. Grafana http://192.168.111.241:3000

2. admin / admin
3. admin

4. Data Sources "+Add data source"

5. Url direct

http://localhost:8086 http://192.168.111.241:8086

o Name: Collectd

o Default:

o Type: InfluxDB

o Url: http://192.168.111.241:8086

o Access:direct

o Http Auth:

o Database: collections

o User: collectdread

o Password: readonly

o Default group by time:


6. "Add" Data Source

7. Dashboards > + New


8. Manage dashboard Settings

9. System Information

X Dashboard
10. ROW Add Panel > Graph

11. Graph Metrics

Panel data source Collectd

12. Metrics A
13. Grafana Toggle Edit

Mode

14.

SELECT last("value") FROM "load_shortterm" WHERE "host" = 'grafana' AND


1
$timeFilter GROUP BY time($interval) fill(null)
15. "+ Add query" Metrics

SELECT last("value") FROM "load_midterm" WHERE "host" = 'grafana' AND

1$timeFilter GROUP BY time($interval) fill(null)

2SELECT last("value") FROM "load_longterm" WHERE "host" = 'grafana' AND

$timeFilter GROUP BY time($interval) fill(null)


16. General Panel Load

17. Legend MinMaxAvg Current

18. X Dashboard CTRL+S

Dashboard
19. Dashboard System

Information Dashboard

Grafana (Graph) (Table) (Singlestat)

Dashboard Templating

Metrics Dashboard

Grafana /
()

(InfluxDBGraphtie )

You might also like