部署grafana-7.4.0

发布时间 2023-09-11 00:48:07作者: 山河剑心

部署grafana组件

解压grafana组件到指定目录

# 解压
tar xzvf grafana-7.4.0.linux-amd64.tar.gz -C /data/applications/prometheus

# 创建软连接
ln -s grafana-7.4.0 grafana

创建文件夹

# 进入文件夹
cd /data/applications/prometheus/grafana

# 创建文件夹
mkdir data logs dashboards script

配置grafana.ini文件

#################################### Paths ####################################
[paths]
# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
# use "cfg:default.paths.data" to specified via command line
data = /data/applications/prometheus/grafana/data
#
# Directory where grafana can store logs
# use "cfg:default.paths.logs" to specified via command line
logs = /data/applications/prometheus/grafana/logs
#
# Directory where grafana will automatically scan and look for plugins
# use "cfg:default.paths.plugins" to specified via command line
plugins = /data/applications/prometheus/grafana/plugins

#################################### Server ####################################
[server]
# Protocol (http or https)
;protocol = http

;The ip address to bind to, empty will bind to all interfaces
;http_addr = 192.168.70.133

# The http port  to use, defaults to 3000
http_port = 3000

# The public facing domain name used to access grafana from a browser
domain = 192.168.70.133

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
;enforce_domain = false

# The full public facing url
;root_url = http://localhost:3000/grafana/
root_url = %(protocol)s://%(domain)s/grafana/

# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
serve_from_sub_path = true

创建run_grafana.sh启动文件

cd /data/applications/prometheus/grafana/script

vim run_grafana.sh

#!/bin/bash
set -e

DEPLOY_DIR=/data/applications/prometheus/grafana/
cd "${DEPLOY_DIR}" || exit 1

exec /data/applications/prometheus/grafana/bin/grafana-server --config=/data/applications/prometheus/grafana/conf/grafana.ini 2>&1 &

登录grafana

http://192.167.70.133:3000/grafana

默认用户名与密码都是admin,首次登陆后,需要对admin的密码进行修改

选择您的配置选项

Grafana后端在其配置文件中定义了许多配置选项(通常在Linux系统上位于/etc/grafana/grafana.ini中)。

在此配置文件中,您可以更改默认管理员密码,http端口,grafana数据库(sqlite3,mysql,postgres),身份验证选项(google,github,ldap,auth proxy)以及许多其他选项。

启动您的grafana服务器。用您的管理员用户登录(默认为admin / admin)。打开侧面菜单(单击顶部菜单中的Grafana图标),转到数据源,然后添加数据源。

添加Prometheus的数据源。

第一步:添加数据源

第二步:设置数据源、数据源名称、类型、IP地址、端口号…

在grafana中导入相关json文件

导入的是MySQL_Overview.json

其他的json文件导入也是类似的。

界面展示: