Document Control

Author

Version

Time

Comment

[email protected]

V0.1

Mar 1st , 2019

First commit

[email protected]

V0.2

Mar 4th , 2019

add data source from influxDB

Grafana topologic

Grafana introduction_第1张图片

graphite is solution for data source scale out

Grafana introduction_第2张图片

statsD to limited the metric sent to graphite

Grafana introduction_第3张图片

Install MYSQL 5.7

Download MySQL Yum Repository

https://dev.mysql.com/downloads/repo/yum/

wget http://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm

Grafana introduction_第4张图片

install the repo

rpm -ivh mysql80-community-release-el7-2.noarch.rpm

clip_image010[4]

see if the repo is enable or disable

yum repolist all | grep mysql

Grafana introduction_第5张图片

enable mysql 5.7

yum-config-manager --enable mysql57-community

Grafana introduction_第6张图片

check repo to make sure 5.7 is enable in repo

cat mysql-community.repo

Grafana introduction_第7张图片

yum repolist enabled | grep mysql

clip_image018[4]

yum install mysql-community-server

Grafana introduction_第8张图片

systemctl start mysqld

systemctl status -l mysqld

Grafana introduction_第9张图片

yum install python34-PyMySQL.noarch

Grafana introduction_第10张图片

find mysql root initial password

sudo grep 'temporary password' /var/log/mysqld.log

2019-03-01T04:19:58.304407Z 1 [Note] A temporary password is generated for root@localhost: 1XGPZC)o

mysql -uroot -p

Grafana introduction_第11张图片

change root password

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@123';

create user graphite identified by 'Grap@123';

clip_image028[4]

create database graphite;

clip_image030[4]

grant all ON graphite.* to graphite@'%';

clip_image032[4]

Install Grafana on Docker

sudo yum install -y yum-utils \

device-mapper-persistent-data \

lvm2

sudo yum-config-manager \

--add-repo \

https://download.docker.com/linux/centos/docker-ce.repo

sudo yum install docker-ce docker-ce-cli containerd.io

Grafana introduction_第12张图片

service docker start

Grafana introduction_第13张图片

docker run -d --name graphite --restart=always -p 81:81 -p 80:80 -p 8125:8125/udp hopsoft/graphite-statsd

please check 8125 is StatsD traffic port in UDP mapping

Grafana introduction_第14张图片

clip_image040[4]

visit http://10.143.40.170/login with admin/admin

Grafana introduction_第15张图片

Grafana introduction_第16张图片

change admin password

http://10.143.40.170/admin/users/edit/1

Grafana introduction_第17张图片

Install Grafana on CentOS

find download information from http://docs.grafana.org/installation/rpm/

vi /etc/yum.repos.d/grafana.repo

[grafana]

name=grafana

baseurl=https://packages.grafana.com/oss/rpm

repo_gpgcheck=1

enabled=1

gpgcheck=1

gpgkey=https://packages.grafana.com/gpg.key

sslverify=1

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

yum install Grafana

Grafana introduction_第18张图片

binding ip address and mysql account information

vi /etc/grafana/grafana.ini

Grafana introduction_第19张图片

Grafana introduction_第20张图片

systemctl start grafana-server

systemctl status -l grafana-server

Grafana introduction_第21张图片

check port is up

netstat -ntlp

Grafana introduction_第22张图片

goto http://192.168.1.60:3000

Grafana introduction_第23张图片

login as admin/admin

Grafana introduction_第24张图片

install server side image rendering

yum install -y fontconfig freetype* urw-fonts

Grafana introduction_第25张图片

Using Grafana

First time in web UI

Grafana introduction_第26张图片

Grafana introduction_第27张图片

create folder and dashboard

Grafana introduction_第28张图片

Grafana introduction_第29张图片

add panel

clip_image072[4]

Grafana introduction_第30张图片

Grafana introduction_第31张图片

share the link

Grafana introduction_第32张图片

take a local snapshot

Grafana introduction_第33张图片

Grafana introduction_第34张图片

take a Cloud snapshot

Grafana introduction_第35张图片

Grafana introduction_第36张图片

Add data source

Grafana introduction_第37张图片

Grafana introduction_第38张图片

Grafana introduction_第39张图片

fill in mysql account information

Grafana introduction_第40张图片

click save and test for testing the connection

Grafana introduction_第41张图片

Integration with InfluxDB

installation influxdatabase

topologic introduce https://www.influxdata.com/time-series-platform/

Grafana introduction_第42张图片

goto https://portal.influxdata.com/downloads/ get download link

wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.4.x86_64.rpm

sudo yum localinstall influxdb-1.7.4.x86_64.rpm

Grafana introduction_第43张图片

systemctl start influxdb

Grafana introduction_第44张图片

enter influx to enter the shell

clip_image104[4]

create and show database

Grafana introduction_第45张图片

insert data by shell

insert cpu,host=nginx value=0.5

Grafana introduction_第46张图片

insert data by API

curl -i -XPOST 'http://localhost:8086/write?db=TelitDemo' --data-binary 'cpu,host=apache value=4'

clip_image110[4]

query database

Grafana introduction_第47张图片

create admin user in influxdb

CREATE USER "admin" WITH PASSWORD 'Pass@123' WITH ALL PRIVILEGES

enable auth in influxdb

vi /etc/influxdb/influxdb.conf

[http]

enabled = true

bind-address = "10.143.40.163:8088"

auth-enabled = true

then restart the influxdb

systemctl restart influxdb

Grafana introduction_第48张图片

Add data source in Grafana

goto Grafana web ui http://10.143.40.160:3000 and find configuration in left menu

Grafana introduction_第49张图片

Grafana introduction_第50张图片

enter influxdb connection information

Grafana introduction_第51张图片

click save and test to make sure db link is available

clip_image122[4]

add panel to dashboard

create influx DS folder and create new dashboard

Grafana introduction_第52张图片

clip_image126[4]

add query and select data source

Grafana introduction_第53张图片 Grafana introduction_第54张图片

edit panel

Grafana introduction_第55张图片

add fake data

clip_image134[4]

data will show up in the panel

Grafana introduction_第56张图片

Integration with MySQL

add data source

Grafana introduction_第57张图片

update with mysql account information

Grafana introduction_第58张图片

Make fake data in database

create production table and column

Grafana introduction_第59张图片

make some fake number

Grafana introduction_第60张图片

Add panel

create mysql folder and switch datasource to mysql

Grafana introduction_第61张图片

Grafana introduction_第62张图片

select add a table

Grafana introduction_第63张图片

Grafana introduction_第64张图片

SELECT * from production

order by SalesTime desc

limit 10

;

Grafana introduction_第65张图片

finally go back to dashboard and looks like this

Grafana introduction_第66张图片

Notification & Alert

Grafana introduction_第67张图片

update SMTP information in /etc/grafana/grafana.ini

Grafana introduction_第68张图片

and update alerting configuration in Grafana webUI

Grafana introduction_第69张图片

Grafana introduction_第70张图片

Worldping plug

download & installation

https://grafana.com/plugins/raintank-worldping-app/installation

grafana-cli plugins install raintank-worldping-app

Grafana introduction_第71张图片

service grafana-server restart

clip_image168[4]

enable worldping in Grafana plugings

Grafana introduction_第72张图片

go and get Grafana.com API Key

https://grafana.com/login?to=%2Fprofile%2Fapi-keys

Grafana introduction_第73张图片

register user and find key

https://grafana.com/orgs/pcdog/api-keys

Grafana introduction_第74张图片

Grafana introduction_第75张图片

Grafana introduction_第76张图片

Grafana introduction_第77张图片

Grafana introduction_第78张图片

dashboard like this

Grafana introduction_第79张图片

Add End point

goto world ping home in left menu

Grafana introduction_第80张图片

Grafana introduction_第81张图片

add endpoint

Grafana introduction_第82张图片

Grafana introduction_第83张图片

wait data information collection

Grafana introduction_第84张图片

wait for a while for the ping data collection , the dashboard will looks like this.

Grafana introduction_第85张图片