当前位置:网站首页>Grafana Getting Started tutorial

Grafana Getting Started tutorial

2022-06-29 03:20:00 Endwas

Recently, companies need to use Grafana Make a chart to show , Monitor the indicators on the first line , Just took the time to learn , It's very powerful , I've stepped on a lot of holes , Dynamic configuration in many places is also poorly understood , So write an introductory tutorial , Let's explain it with Mysql As a data source grafana Chart display .

Grafana Introductory tutorial

1. install 、 download

1. Windows Installation and downloading

https://grafana.com/grafana/download?platform=windows

2.Mac Installation and downloading

1. Download package

curl -O https://dl.grafana.com/enterprise/release/grafana-enterprise-9.0.0.darwin-amd64.tar.gz

tar -zxvf grafana-enterprise-9.0.0.darwin-amd64.tar.gz

2.Brew Download start

brew install grafana

brew services start grafana

Grafana Introductory tutorial

1. install 、 download

1. Windows Installation and downloading

https://grafana.com/grafana/download?platform=windows

2.Mac Installation and downloading

1. Download package

curl -O https://dl.grafana.com/enterprise/release/grafana-enterprise-9.0.0.darwin-amd64.tar.gz

tar -zxvf grafana-enterprise-9.0.0.darwin-amd64.tar.gz

2.Brew Download start

brew install grafana

brew services start grafana

2. Import and export

1. Select a Dashboad

 Insert picture description here

2. export json file

 Insert picture description here

3. Select the import page

 Insert picture description here

 Insert picture description here
Just import .

3. Access control

Localhost:3000

1. Configure data sources Data source

 Insert picture description here

 Insert picture description here

 Insert picture description here

2. To configure Dashboard

1. Select the table you want to export , To configure Query Parameters

 Insert picture description here

2. Handwriting sql sentence

 Insert picture description here

3. To configure variable

Enter a Dashboard

 Insert picture description here

 Insert picture description here

 Insert picture description here

e.g

 Insert picture description here

4. Query editor

1.Select table, time column and metric column (FROM)

When you first enter edit mode or add a new query ,Grafana You will try to pre populate the query builder with the first table with timestamp columns and numeric Columns .

stay FROM Field ,Grafana It will be recommended to configure the tables in the database .

Select... In another database that database users have access to Table or view , You can manually enter the fully qualified name (database.table), Such as otherDb.metrics.

The time column field is the name of the column that holds your time value . by Metric Selecting a value in the column field is optional . If you select a value ,Metric The column field will be used as the series name .

The metric column recommendations will only contain data with text data types (text、tinytext、mediumtext、longtext、varchar、char) The column of .

If you want to use columns with different data types as measurement Columns , You can enter a column name with a cast :CAST(numericColumn as CHAR).

You can also enter any... In the measure column field SQL expression , These expressions evaluate to text data types , Such as CONCAT(column1, “ “, CAST(numericColumn as CHAR)).

2.Columns and Aggregation functions (SELECT)

stay SELECT In line , You can specify which columns and functions to use .

In the column field , You can write any expression , Not like it column1 * column2 / column3 Such column names .

If you use aggregate functions , You need to group the result set .

If you add an aggregate function , The editor will automatically add GROUP BY Time .

You can add more value columns by clicking the plus button and selecting columns from the menu .

Multiple value columns are drawn as separate series in the graphics panel .

3.Filter data (WHERE)

To add a filter , Please click on the WHERE The plus icon to the right of the condition .

You can remove the filter by clicking filter and selecting remove .

The filter for the currently selected time range is automatically added to the new query .

4.Gap Filling

When you group by time ,Grafana Missing values can be populated .

time The function takes two arguments .

The first parameter is the time window you want to group , The second parameter is what you want Grafana Fill in the value of the missing item .

5.Text Editor Mode (RAW)

You can switch the editor mode by clicking the icon and selecting it, or click Edit... Under query SQL To switch to the original query editor mode .

If you use the original query editor , Please ensure that your query has at least ORDER BY Filters for time and return time ranges .

5.Panel Option

explain :

  1. Tooltip mode That is, move the mouse over the graph to display all the indicators , It is also an indicator of mouse position . Used for multiple broken line indicators .
  2. Legend Logo mode , Display type of indicator , Table or list, etc .
  3. Standard options Configuration properties , Such as unit value , Unit range, etc .
  4. Thresholds Display threshold line , Such as alarm line , Warning line, etc .
  5. Graph styles The style of the chart , Straight and curved lines .

6.Q&S

  1. The time interval 8 Hours

Change the time zone ,Configuration - 》 preferences -》 Timezone -》 choice UTC Time -> save

Or go into a Dashboard -》 settings -》 General -》Time options

  1. Grafana Time stamp to specific time

Grafana Direct conversion , Just confirm the time zone .

  1. How to dynamically transfer parameters

Get into dashboard settings, choice variable To configure , Select a data source or a fixed value , If you want to pass in other variable, use $value Pass in .

  1. How to group

Adding add panel When There's a... On the right add a new row Add separator .

  1. Grafana Dynamically connect data sources

In some cases , Possible database connections / perhaps es Under the index It changes over time , At this time, we can configure dynamic data . If you still can't connect to es, Determine the permission of the account .

[log_abc_]YYYY_MM_DD Include parameters in brackets YYYY_MM_DD Represent wildcard

  1. Grafana How to dynamically modify according to the time selector sql sentence

Official website passed $_from , $_to To get properties
https://grafana.com/docs/grafana/latest/variables/variable-types/global-variables/

summary

Grafana Is a very powerful visual monitoring software , Support complete data sources , It also includes very powerful dynamic data sources 、 Dynamic parameter function , It also contains a variety of chart software , I think than superset、metabase And so on .

原网站

版权声明
本文为[Endwas]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/180/202206290314390482.html