Performance Testing - monitoring tool Grafana introduction and use

1 Introduction

Grafana is a language developed by Go source data visualization tool that can do data monitoring and statistics, with alarm function. At present there are many companies use grafana, such as paypal, ebay, intel and so on.

1.1 seven characteristics

① Visualization: fast and flexible client with a variety of graphics options. Panel insert many different ways to visualize metrics and logs.
② Alarm: Visualization for the most important indicators define alert rule. Grafana will continue to evaluate them, and send notifications.
③ notification: When the alarm changes state, it notifies you. Receive e-mail notification.
④ dynamic dashboards: Using template variables to create dynamic and reusable dashboard, these variables as a template drop-down menu at the top of the dashboard.
⑤ mixing Source:! In the same FIG mix different data sources may be specified according to each data source query. This even applies to custom data sources.
⑥ Comments: Comments charts from different data sources. Hover over an event to display the complete event metadata and tags.
⑦ Filter: Filters allow you to dynamically create a new key / value filter, the filter is automatically applied to all queries of the data source.

2 Installation

Detailed installation tutorials Reference: http://docs.grafana.org/installation/debian/

2.1 Download the installation package

wget <u> https://dl.grafana.com/oss/release/grafana-6.0.1-1.x86_64.rpm </ u>

2.2 Installation environment dependent

yum install initscripts fontconfig  
yum install freetype
yum install urw-fonts

2.3 Installation Services Grafana

rpm -Uvh grafana-6.0.1-1.x86_64.rpm

2.4 plug-in installation

使用grafana-cli工具安装

#获取可用插件列表

grafana-cli plugins list-remote 修改图形为饼状 grafana-cli plugins install grafana-piechart-panel 安装其他图形插件 grafana-cli plugins install grafana-clock-panel #钟表形展示 grafana-cli plugins install briangann-gauge-panel #字符型展示 grafana-cli plugins install natel-discrete-panel #服务器状态 grafana-cli plugins install vonage-status-panel 

2.5 plug-in uninstall

例:grafana-cli plugins uninstall vonage-status-panel
安装和卸载后需要重启grafana才能够生效

2.6 start, restart, shut down

启动:service grafana-server start
停止:service grafana-server stop
重启:service grafana-server restart
加入开机自启动: chkconfig --add grafana-server on 

2.7 Test start

默认用户密码:admin/admin, 访问地址:  服务地址 : [http://grafana服务地址:3000](http://localhost:3000/) 如果出现登录界面,代表安装启动成功 

3 Create Dashboard

3.1 Data source configuration

Dashboard is based on the establishment of a data source, you must first add a data source.

 
Increase MySQL data source

3.2 Visually

There are many ways to visualize, but Graph, Table, Pie chart had to meet three basic requirements of data presentation.

 
Visually

3.2.1 Graph

Note: Only Graph can configure alarms

New variable time interval

 
New variable time interval

Graph line chart

 
Graph line chart
SELECT $__timeGroupAlias(create_time,$__interval), country_name as metric, COUNT(user_id) as '用户数量' FROM `user` WHERE $__timeFilter(create_time) GROUP BY 1,2 ORDER BY $__timeGroup(create_time,$__interval); 
 
The default is to show the way lines

Graph Histogram

Copy this line graph Graph A, you can change it to show the way.

 
 
 
 
 
Lines for the change Bars

3.2.2 Table

Create a filter query variables

 
Create a drop-down list to do screening

user list

 
user list
select user_id,user_name,mobile,id_number,country_name,money,create_time from user WHERE $__timeFilter(create_time) and country_name in ($countryName)

Note: After you have added the default table, if there is a number, will be in K, such as the 300,000-bit display 30k.
Digital display modify, Add column style:

 
Modify digital style

3.2.3 Pie

 
Pie
select country_name, create_time as time, count(*) as c from user where $__timeFilter(create_time) group by country_name order by c asc; 

3.3 Rights Management

3.3.1 User Management

 
User Management

3.3.2 Management Team

 
New Team

 
Team members plus

3.3.3 Folder permissions

 
 

3.3.4 dashboarad permission settings

 
 

If the user role = admin in this org, you have admin rights to the dashboard, and love doing doing, such as configuring the dashboard, look dashboard, the dashboard configuration rights.
If the user role = editor at the org, it has the authority to operate the dashbaord edit, you can edit the dashboard, of course, can be seen.
If the user in the org role = viewer, you have permission to view the operation of the dashbaord, it is that you can look at this dashboard, but can not be edited.
Set on the above chart, if the login user is admin, you can edit it; if the login user is wade, only viewing rights.

3.4 template variables

When the data appears in the table, need to be screened by the screening conditions, grafana provides a template for the custom variable filter field.
Type: define the variable type
Query: This type of variable allows you to write a data source query, the query usually returns a metric names, tag values or keys. For example, the return erver names, query sensor ids or data centers list.
interval: interval values. This variable represents the time span. Do histogram date or time interval a hard-coded set, use this type of variable.

Legacy: When you select 1d (units d), will be reported parse error: error parsing interval 1d, yet resolved;

Datasource: This type allows you to quickly change the data source of the whole instrument panel. If there are multiple instances of data sources in different environments, it is very useful.
Custom: Use a comma-separated list of options to manually define the variables.
Constant: the definition of a hidden constant. Useful metric path prefix dashboards, you want to share. In the dashboard export, during the constant variable will serve as an important option.
Ad hoc filters: a very special type of variable, only for certain data sources, InfluxDB and Elasticsearch currently. It allows you to add automatically added to all key / value metric filter query using the specified data source.

The above Graph and Table interval are used to define and query variable filter, not repeated.

Text box

 
New input box

 
 

Custom

 
New Custom Variable

 
Drop-down selection

3.5 Version Control

 
 

4 alarm notification

4.1 Turning the alarm

grafana only graph support alarm notification.
There are many grafana alarm notification channels, such as Email, Teams, nails, etc. are supported.
To set an alarm in grafana.ini in:

#################################### Alerting ############################
[alerting]
# Disable alerting engine & UI features
enabled = true   #开启
# Makes it possible to turn off alert rule execution but alerting UI is visible
execute_alerts = true  #开启
# Default setting for new alert rules. Defaults to categorize error and timeouts as alerting. (alerting, keep_state)
;error_or_timeout = alerting
# Default setting for how Grafana handles nodata or null values in alerting. (alerting, no_data, keep_state, ok)
;nodata_or_nullvalues = no_data
# Alert notifications can include images, but rendering many images at the same time can overload the server
# This limit will protect the server from render overloading and make sure notifications are sent out quickly
;concurrent_render_limit = 5

4.2 Mail Notification

4.2.1 STMP server configuration

To be able to send e-mail notifications, you need to configure the mail server and other information in the configuration file grafana.ini in:

#################################### SMTP / Emailing ##########################
[smtp]
enabled = true #是否允许开启
host = #发送服务器地址,可以再邮箱的配置教程中找到: user = 你的邮箱 # If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;""" password = 这个密码是你开启smtp服务生成的密码 ;cert_file = ;key_file = skip_verify = true from_address = 你的邮箱 from_name = Grafana # EHLO identity in SMTP dialog (defaults to instance_name) ;ehlo_identity = dashboard.example.com [emails] ;welcome_email_on_sign_up = false 

Finished modifying the configuration, remember to restart the service Grafana

4.2.2 Send e-mail

Configuring e-mail notification channel

 
Configuring e-mail notification channel

Send Test

 
Send Test

Set an alarm condition

 
 

5 Summary

Grafana is a powerful and very beautiful presentation layer of data visualization monitoring tool, based on Grafana This part describes the installation and pose common MySQL data sources, and also supports other data sources such as ElasticSearch, InfluxDB and so on.



Guess you like

Origin www.cnblogs.com/xiaobaicai-doudou/p/12580914.html