Grafana的安装和使用

本文涉及的产品
可观测可视化 Grafana 版,10个用户账号 1个月
简介: 1.grafana introductionGrafana is an open source metric analytics & visualization suite. It is most commonly used for visualizing time ser...

1.grafana introduction

Grafana is an open source metric analytics & visualization suite. It is most commonly used for visualizing time series data for infrastructure and application analytics but many use it in other domains including industrial sensors, home automation, weather, and process control.

这是官方原话,个人理解,grafana就是一个实时监控及可视化的工具;当然grafana还有很多功能,还有待深入学习;


2.Installation grafana

因为我们生产上使用的是4.1.2这个版本,所以这里就用这个版本来demo:

[root@sht-sgmhadoopcm-01 local]#wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.1.2-1486989747.linux-x64.tar.gz

[root@sht-sgmhadoopcm-01 local]#tar -zxvf grafana-4.1.2-1486989747.linux-x64.tar.gz

[root@sht-sgmhadoopcm-01 local]#mv grafana-4.1.2-1486989747 grafana

[root@sht-sgmhadoopcm-01 local]#mkdir -p /usr/local/grafana/data/{log,plugins}


grafana has a number of configuration options, but we only  need update a part of parameter, other can default.

grafana配置文件有很多参数,但是我们只需要注意和修改以下几个,其他默认即可

[root@sht-sgmhadoopcm-01 grafana]# vim conf/defaults.ini
app_mode = production
instance_name = ${HOSTNAME}
[paths]
data = data
logs = data/log
plugins = data/plugins
[server]
protocol = http
http_port = 3000
domain = localhost
[database]
type = sqlite3
host = 127.0.0.1:3306
name = grafana
user = root
path = grafana.db
[session]
provider = file
provider_config = sessions
cookie_name = grafana_sess
cookie_secure = false
session_life_time = 86400
gc_interval_time = 86400
[security]
admin_user = admin
admin_password = admin



Start grafana 启动grafana:

[root@sht-sgmhadoopcm-01 grafana]# ./bin/grafana-server web &


Note:

如果你没有使用默认的参数,启动grafana的使用需要指定参数启动

The custom configuration file path can be overridden using the -config parameter

[root@sht-sgmhadoopcm-01 grafana]# bin/grafana-server web -config conf/custom.ini &


3. Adding the Data Source

这里所使用到的源数据是ES,在上一篇博客中有介绍如何使用ES,请参考链接:http://blog.51cto.com/darrenmemos/2125317

grafana展示的数据来源就是通过query ES,除了ES,grafana还支持Graphite,Prometheus,InfluxDB,OpenTSDB,MySQL,AWS Cloudwatch等;


添加源数据的Step:

(1) Open the side menu by clicking the Grafana icon in the top header.

(2) In the side menu under the Dashboards link you should find a link named Data Sources.

(3) Click the + Add data source button in the top header.

(4) Select Elasticsearch from the Type dropdown.


blob.png


4.Creating Dashboard and panel

创建Dashboard比较简单,这里不再演示,一旦dashboard创建好,我们就可以同时选择一个panel;

panel有这么几种:Graph,Singlestat,Table,Test,Alert List等,常用的是前三种;

具体可以参考链接:http://docs.grafana.org/v4.1/features/datasources/graphite/



5.Case: 实时展示系统每1分钟的负载

实现功能:实时展示系统每1分钟的负载,这里共有三个instance:


blob.png



blob.png



blob.png


6.case:实时展示系统memory已使用百分比

blob.png


blob.png



7.case:实时展示系统磁盘使用百分比

这里每个instance只选择使用百分比最大的挂载点展示

blob.png



8.case:实时展示error log:


8.1 先创建template变量

create templating :hostname 和log_type


blob.png


blob.png


8.2 创建panel

blob.png


blob.png


blob.png



8.3 Test

[root@sht-sgmhadoopcm-01 log]# echo "Error" >> /var/log/messages

[root@sht-sgmhadoopnn-02 log]# echo "Error" >> messages

blob.png


9. 最后调整一下面板,再展示一下整体效果图

blob.png

目录
相关文章
|
2月前
|
存储 Prometheus 监控
Grafana 系列文章(十四):Helm 安装 Loki
Grafana 系列文章(十四):Helm 安装 Loki
|
2月前
|
Prometheus 监控 Kubernetes
Prometheus + Grafana安装
Prometheus + Grafana安装
|
2月前
|
Prometheus Cloud Native Java
微服务框架(二十三)Prometheus + Grafana 安装、配置及使用
此系列文章将会描述Java框架Spring Boot、服务治理框架Dubbo、应用容器引擎Docker,及使用Spring Boot集成Dubbo、Mybatis等开源框架,其中穿插着Spring Boot中日志切面等技术的实现,然后通过gitlab-CI以持续集成为Docker镜像。 本文为Prometheus + Grafana 安装、配置及使用 本系列文章中所使用的框架版本为Spring ...
|
12月前
|
数据可视化 Go API
安装Grafana并使用Cloudera Manager DataSource
安装Grafana并使用Cloudera Manager DataSource
184 1
|
8月前
|
Prometheus Cloud Native
Mac下安装 Prometheus+Grafana
Mac下安装 Prometheus+Grafana
237 0
|
2月前
阿里云Grafana服务支持一键安装Grafana插件
【2月更文挑战第12天】阿里云Grafana服务支持一键安装Grafana插件
48 4
|
2月前
|
Prometheus 数据可视化 数据库
可视化工具Grafana:简介及安装
可视化工具Grafana:简介及安装
66 0
|
2月前
获取Grafana安装包并安装
获取Grafana安装包并安装
54 1
|
2月前
|
Prometheus Cloud Native Linux
Linux下安装prometheus & grafana
Linux下安装prometheus & grafana
167 0
|
7月前
|
Prometheus Kubernetes Cloud Native
k8s grafana 安装插件配置
k8s grafana 安装插件配置
187 1