grafana安装部署、自定义主题、dashboard模板导入 |
您所在的位置:网站首页 › 模板导入不了 › grafana安装部署、自定义主题、dashboard模板导入 |
介绍
Grafana 是一个跨平台的开源的度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知。 官网地址: 它主要有以下六大特点: 展示方式:快速灵活的客户端图表,面板插件有许多不同方式的可视化指标和日志,官方库中具有丰富的仪表盘插件,比如热图、折线图、图表等多种展示方式; 数据源:Graphite,InfluxDB,OpenTSDB,Prometheus,Elasticsearch,CloudWatch和KairosDB等; 告警:以可视方式定义最重要指标的告警规则,Grafana将不断计算并发送通知,在数据达到阈值时通过Slack、PagerDuty等获得通知; 混合展示:在同一图表中混合使用不同的数据源,可以基于每个查询指定数据源,甚至自定义数据源; 注释:使用来自不同数据源的丰富事件注释图表,将鼠标悬停在事件上会显示完整的事件元数据和标记; 过滤器:Ad-hoc过滤器允许动态创建新的键/值过滤器,这些过滤器会自动应用于使用该数据源的所有查询。 安装grafana官方下载地址:https://grafana.com/grafana/download?pg=get&plcmt=selfmanaged-box1-cta1 可以根据自己的服务器的类型选择对应的grafana进行安装,本文介绍Linux CentOS环境v7.5.11版本的安装、部署、配置。 # 下载 [root@localhost ~]# wget https://dl.grafana.com/enterprise/release/grafana-enterprise-7.5.11-1.x86_64.rpm # 安装 [root@localhost ~]# yum install grafana-enterprise-7.5.11-1.x86_64.rpm # 启动 [root@localhost ~]# systemctl start grafana-server # 检查grafana是否启动成功,grafana启动时会占用3000端口 [root@localhost ~]# lsof -i:3000 # 重启 [root@localhost ~]# systemctl restart grafana-server 访问grafana部署成功时,可以http访问,ip就是grafana服务的服务器host 登录地址:http://ip:3000/ 账号:admin/admin 如果检查端口3000已经在不能访问,检查服务器防火墙 # centos7查看防火墙状态 [root@localhost ~]# systemctl status firewalld # 临时关闭防火墙 [root@localhost ~]# systemctl stop firewalld # 永久关闭防火墙 [root@localhost ~]# systemctl disable firewalld 配置grafana 安装成功后,会在/etc/grafana目录生成配置文件grafana.ini [root@localhost ~]# cd /etc/grafana1.如果需要开启匿名访问,需要修改如下参数 [root@localhost ~]# vim /etc/grafana/grafana.ini # 开启匿名访问 enabled = true # 给匿名访问者一个组织 org_name = Main Org. #给匿名访问者一个访问权限,Viewer表示浏览权限,Editor编辑权限,Admin管理员权限 org_role = Viewer2.如果需要开放浏览器iframe嵌套grafana页面设置,需修改如下参数 [root@localhost ~]# vim /etc/grafana/grafana.ini # 允许浏览器渲染grafana到iframe allow_embedding = true修改了配置之后需要重启grafana [root@localhost grafana]# systemctl restart grafana-server3.隐藏grafana左侧菜单和顶部面包屑 只要在url后面追加 &kiosk 参数 示例:http://192.168.197.136:3000/d/KkAqjsS4z/node-exporter-server-metrics?orgId=1&kiosk 主题设置部署成功后默认只有dark和light两种主题,light白色主题比较刺眼,dark主题看久了有视觉疲劳,grafana可以支持自定义主题设置 a)事前准备1.安装主题面板插件 # 安装插件 [root@localhost grafana]# grafana-cli plugins install yesoreyeram-boomtheme-panel # 重启grafana服务 [root@localhost grafana]# systemctl restart grafana-server2.检查插件是否安装成功 下载主题样式css文件到grafana指定目录 推荐grafana主题样式gitub地址:https://github.com/gilbN/theme.park 1.创建存放css样式的目录 grafana部署成功后,会自动创建/usr/share/grafana目录,这些是存放静态资源的 [root@localhost grafana]# cd /usr/share/grafana/public [root@localhost public]# mkdir css [root@localhost public]# cd css [root@localhost css]# mkdir theme-options [root@localhost css]# pwd /usr/share/grafana/public/css/usr/share/grafana/public/css目录作为存放基础css的目录 /usr/share/grafana/public/css/theme-options是存放主题样式的目录 2.在上述github上找到grafana-base.css和transparent.css 说明: grafana-base.css文件在css/base/grafana目录下 transparent.css文件在css/defaults目录下 3.将上述两个文件下载到/usr/share/grafana/public/css目录下 [root@localhost css]# ll -rw-r--r--. 1 root root 33540 Oct 20 10:10 grafana-base.css drwxr-xr-x. 2 root root 214 Oct 20 10:40 theme-options -rw-r--r--. 1 root root 1388 Oct 19 19:06 transparent.css4.在grafana-base.css文件引入transparent.css文件 编辑grafana-base.css,在文件顶部添加@import url(“transparent.css”);,以相对路径引入transparent.css 例如: [root@localhost css]# vim grafana-base.css @import url("transparent.css"); body { color: var(--text) !important; background: var(--main-bg-color) !important; background-repeat: repeat, no-repeat !important; background-attachment: fixed, fixed !important; background-position: center center, center center !important; background-size: auto, cover !important; -webkit-background-size: auto, cover !important; -moz-background-size: auto, cover !important; -o-background-size: auto, cover !important; } ...5.下载主题样式文件 将github上css/theme-options中所有css文件下载到/usr/share/grafana/public/css/theme-options目录 [root@localhost theme-options]# cd /usr/share/grafana/public/css/theme-options [root@localhost theme-options]# ll total 44 -rw-r--r--. 1 root root 1351 Oct 20 10:09 aquamarine.css -rw-r--r--. 1 root root 1442 Oct 20 10:21 dark.css -rw-r--r--. 1 root root 980 Oct 20 10:29 dracula.css -rw-r--r--. 1 root root 1413 Oct 20 10:12 hotline.css -rw-r--r--. 1 root root 1336 Oct 20 10:21 hotpink.css -rw-r--r--. 1 root root 1455 Oct 20 10:22 maroon.css -rw-r--r--. 1 root root 990 Oct 20 10:22 nord.css -rw-r--r--. 1 root root 967 Oct 20 10:22 organizr.css -rw-r--r--. 1 root root 1036 Oct 20 10:22 overseerr.css -rw-r--r--. 1 root root 1748 Oct 20 10:24 plex.css -rw-r--r--. 1 root root 1451 Oct 20 10:24 space-gray.css6.为样式css文件引入grafana-base.css theme-options目录中所有的css文件头部添加@import url(“…/grafana-base.css”);,以相对路径引入grafana-base.css 例如: [root@localhost theme-options]# vim aquamarine.css @import url("../grafana-base.css"); :root { --main-bg-color: radial-gradient(ellipse at center, #47918a 0%, #0b3161 100%) center center/cover no-repeat fixed; --modal-bg-color: linear-gradient(-90deg, #47918a 0%, #0b3161 100%) center center/cover no-repeat fixed; --modal-header-color: linear-gradient(-90deg, #47918a 0%, #0b3161 100%) center center/cover no-repeat fixed; --modal-footer-color: linear-gradient(-90deg, #47918a 0%, #0b3161 100%) center center/cover no-repeat fixed; /*以下代码省略*/ ... } b)启用主题登录grafana > + > dashboard 创建panel panel > visualization > boom panel > themes > Add New Theme 主题参数 主题效果 主题panel标题下拉 > More > Copy 选择要应用新主题的dashboard > Add panel > Paste panel from clipboard > Save 效果 对于常用的服务监控,例如主机节点监控,elasticsearch等等常见的服务,grafana官方有已经建好的dashboard面板模板,只要去grafana官网导入模板即可。 常用dashboard模板地址: https://grafana.com/grafana/dashboards/ 例如:要为prometheus监控elasticsearch导入一个dashboard模板 模板搜索datasource 选择prometheus 注意:你要导入的dashboard模板要与自己安装的elasticsearch_exporter插件要匹配,不然数据可能不会展示 粘贴模板id到load栏 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |