企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 部署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的数据源。 第一步:添加数据源 ![](https://img.kancloud.cn/7d/d7/7dd7f44c7eab09eac77eb29e87b53f52_1920x920.png) 第二步:设置数据源、数据源名称、类型、IP地址、端口号… ![](https://img.kancloud.cn/91/72/91726e53d77ff0bfb9d998c6d2059787_1825x932.png) 在grafana中导入相关json文件 ![](https://img.kancloud.cn/ee/97/ee9773dad010d01ceabcbee50482e90e_1137x559.png) ![](https://img.kancloud.cn/ec/77/ec77c05996d1ea39aa234c3693c48574_1138x548.png) 导入的是MySQL\_Overview.json ![](https://img.kancloud.cn/a4/1a/a41a804ea55c1c410d8a05bd6b852431_1187x650.png) 其他的json文件导入也是类似的。 **界面展示:** ![](https://img.kancloud.cn/f3/87/f387f62837135eb52104e50682a8fe25_1917x946.png)