Grafana introduction

Document Control

Authorpython

Versionmysql

Timelinux

Commentnginx

Hao.Yu@telit.comweb

V0.1sql

Mar 1st , 2019docker

First commitshell

Hao.Yu@telit.comapache

V0.2centos

Mar 4th , 2019

add data source from influxDB

Grafana topologic

clip_image002[4]

graphite is solution for data source scale out

clip_image004[4]

statsD to limited the metric sent to graphite

clip_image006[4]

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

clip_image008[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

clip_image012[4]

enable mysql 5.7

yum-config-manager --enable mysql57-community

clip_image014[4]

check repo to make sure 5.7 is enable in repo

cat mysql-community.repo

clip_image016[4]

yum repolist enabled | grep mysql

clip_image018[4]

yum install mysql-community-server

clip_image020[4]

systemctl start mysqld

systemctl status -l mysqld

clip_image022[4]

yum install python34-PyMySQL.noarch

clip_image024[4]

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<rs+

mysql -uroot -p

clip_image026[4]

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

clip_image034[4]

service docker start

clip_image036[4]

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

clip_image038[4]

clip_image040[4]

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

clip_image042[4]

clip_image044[4]

change admin password

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

clip_image046[4]

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

clip_image048[4]

binding ip address and mysql account information

vi /etc/grafana/grafana.ini

clip_image050[4]

clip_image052[4]

systemctl start grafana-server

systemctl status -l grafana-server

clip_image054[4]

check port is up

netstat -ntlp

clip_image056[4]

goto http://192.168.1.60:3000

clip_image058[4]

login as admin/admin

clip_image060[4]

install server side image rendering

yum install -y fontconfig freetype* urw-fonts

clip_image062[4]

Using Grafana

First time in web UI

clip_image064[4]

clip_image066[4]

create folder and dashboard

clip_image068[4]

clip_image070[4]

add panel

clip_image072[4]

clip_image074[4]

clip_image076[4]

share the link

clip_image078[4]

take a local snapshot

clip_image080[4]

clip_image082[4]

take a Cloud snapshot

clip_image084[4]

clip_image086[4]

Add data source

clip_image088[4]

clip_image090[4]

clip_image092[4]

fill in mysql account information

clip_image094[4]

click save and test for testing the connection

clip_image096[4]

Integration with InfluxDB

installation influxdatabase

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

clip_image098[4]

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

clip_image100[4]

systemctl start influxdb

clip_image102[4]

enter influx to enter the shell

clip_image104[4]

create and show database

clip_image106[4]

insert data by shell

insert cpu,host=nginx value=0.5

clip_image108[4]

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

clip_image112[4]

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

clip_image114[4]

Add data source in Grafana

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

clip_image116[4]

clip_image118[4]

enter influxdb connection information

clip_image120[4]

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

clip_image124[4]

clip_image126[4]

add query and select data source

clip_image128[4] clip_image130[4]

edit panel

clip_image132[4]

add fake data

clip_image134[4]

data will show up in the panel

clip_image136[4]

Integration with MySQL

add data source

clip_image138[4]

update with mysql account information

clip_image140[4]

Make fake data in database

create production table and column

clip_image142[4]

make some fake number

clip_image144[4]

Add panel

create mysql folder and switch datasource to mysql

clip_image146[4]

clip_image148[4]

select add a table

clip_image150[4]

clip_image152[4]

SELECT * from production

order by SalesTime desc

limit 10

;

clip_image154[4]

finally go back to dashboard and looks like this

clip_image156[4]

Notification & Alert

clip_image158[4]

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

clip_image160[4]

and update alerting configuration in Grafana webUI

clip_image162[4]

clip_image164[4]

Worldping plug

download & installation

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

grafana-cli plugins install raintank-worldping-app

clip_image166[4]

service grafana-server restart

clip_image168[4]

enable worldping in Grafana plugings

clip_image170[4]

go and get Grafana.com API Key

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

clip_image172[4]

register user and find key

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

clip_image174[4]

clip_image176[4]

clip_image178[4]

clip_image180[4]

clip_image182[4]

dashboard like this

clip_image184[4]

Add End point

goto world ping home in left menu

clip_image186[8]

clip_image188[4]

add endpoint

clip_image190[4]

clip_image192[4]

wait data information collection

clip_image194[4]

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

clip_image196[4]

相關文章
相關標籤/搜索