PostgreSQL数据库——Pigsty grafana Ansible
配置grafana
Remove grafana provisioning config删除grafana配置文件(/etc/grafana/provisioning/dashboards/pigsty.yml和/etc/grafana/provisioning/datasources/pigsty.yml)
Remake grafana resource dir重做grafana资源文件夹(/etc/grafana/、/etc/dashboards、/etc/grafana/provisioning/dashboards、/etc/grafana/provisioning/datasources)
Templating /etc/grafana/grafana.ini、Templating datasources provisioning config、Templating dashboards provisioning config模板化配置文件(grafana.ini、datasources-pigsty.yml、dashboards-pigsty.yml)
---
#--------------------------------------------------------------#
# Config grafana
#--------------------------------------------------------------#
#---------------------------#
# Cleanup existing config #
#---------------------------#
- name: Remove grafana provisioning configfile: path={{ item }} state=absentwith_items:- /etc/grafana/provisioning/dashboards/pigsty.yml- /etc/grafana/provisioning/datasources/pigsty.yml- name: Remake grafana resource dirfile: path={{ item }} state=directory owner=grafana group=root mode=0775with_items:- /etc/grafana/- /etc/dashboards # default dashboards dir- /etc/grafana/provisioning/dashboards- /etc/grafana/provisioning/datasources#---------------------------#
# Templating new config #
#---------------------------#
- name: Templating /etc/grafana/grafana.initemplate: src=grafana.ini dest=/etc/grafana/grafana.ini owner=grafana group=grafana- name: Templating datasources provisioning configtemplate: src=datasources-pigsty.yml dest=/etc/grafana/provisioning/datasources/pigsty.yml owner=grafana group=grafana- name: Templating dashboards provisioning configtemplate: src=dashboards-pigsty.yml dest=/etc/grafana/provisioning/dashboards/pigsty.yml owner=grafana group=grafana...
启动
Launch grafana service使用systemd模块启动grafana-server,使用wait_for模块等待grafana上线
---
#--------------------------------------------------------------#
# Launch grafana
#--------------------------------------------------------------#
- name: Launch grafana servicesystemd: name=grafana-server state=restarted enabled=yes daemon_reload=yes- name: Wait for grafana onlinewait_for: host=127.0.0.1 port=3000 state=started...
Provisioning
Sync grafana home and core dashboards同步所有的dashboards到/etc/pigsty/dashboards/
Provisioning grafana with grafana.py调用shell模块export相关变量,并执行 /etc/pigsty/dashboards/grafana.py init /etc/pigsty/dashboards/
---
#--------------------------------------------------------------#
# Copy base dashboards (home dashboard & core application)
#--------------------------------------------------------------#
# Note that dashboards dir are located @ pigsty home files/
- name: Sync grafana home and core dashboardstags: [ dashboard, dashboard_sync ]synchronize:src: dashboards/dest: /etc/pigsty/dashboards/#--------------------------------------------------------------#
# Provisioning
#--------------------------------------------------------------#
- name: Provisioning grafana with grafana.pytags: [ dashboard, dashboard_init ]ignore_errors: trueshell: |#!/bin/bash# grafana access infoexport GRAFANA_ENDPOINT={{ grafana_endpoint }}export GRAFANA_USERNAME={{ grafana_admin_username }}export GRAFANA_PASSWORD={{ grafana_admin_password }}# external access infoexport NGINX_UPSTREAM_YUMREPO={{ repo_address }}export NGINX_UPSTREAM_CONSUL={{ nginx_upstream | json_query('[?name==`consul`].host') | first }}export NGINX_UPSTREAM_PROMETHEUS={{ nginx_upstream | json_query('[?name==`prometheus`].host') | first }}export NGINX_UPSTREAM_ALERTMANAGER={{ nginx_upstream | json_query('[?name==`alertmanager`].host') | first }}export NGINX_UPSTREAM_GRAFANA={{ nginx_upstream | json_query('[?name==`grafana`].host') | first }}export NGINX_UPSTREAM_HAPROXY={{ nginx_upstream | json_query('[?name==`haproxy`].host') | first }}# run provisinoing logic/etc/pigsty/dashboards/grafana.py init /etc/pigsty/dashboards/...
注册Grafana Service
Register Grafana Service调用template模块模板化svc-grafana.json.j2到目标配置文件/etc/consul.d/svc-grafana.json
Reload consul重载Reload consul,使用systemd模块
---#--------------------------------------------------------------#
# Register Grafana Service
# Only consul|none are currently available
#--------------------------------------------------------------#
- name: Register grafana service to consulwhen: service_registry == 'consul'block:- name: Register consul grafana servicetemplate: src=svc-grafana.json.j2 dest=/etc/consul.d/svc-grafana.json owner=consul group=admin mode=0660- name: Reload consulsystemd: name=consul state=reloaded enabled=yes daemon_reload=yes...
加载grafana插件
#--------------------------------------------------------------#
# Extract plugins cache if applicable
#--------------------------------------------------------------#
- name: Check grafana plugin cache existsstat: path={{ grafana_cache }}register: grafana_plugins_cache- name: Provision grafana plugins via cache if existstags: grafana_plugins_unzipwhen: grafana_plugins_cache.stat.existsshell: |[[ -a "{{ grafana_cache }}" ]] && rm -rf /var/lib/grafana/plugins && tar -xf {{ grafana_cache }} -C /var/lib/grafanachown -R grafana /var/lib/grafana#--------------------------------------------------------------#
# download plugins from internet if
# 1. cache not exists
# 2. grafana_plugin = install (default)
# if grafana_plugin != install , skip plugin download
#--------------------------------------------------------------#
- name: Download grafana plugins via internetwhen: not grafana_plugins_cache.stat.exists or grafana_plugin == 'install'ignore_errors: trueenvironment: "{{ proxy_env | default({}) }}"grafana_plugin: name={{ item }}with_items: "{{ grafana_plugins }}"- name: Download grafana plugins via gitwhen: not grafana_plugins_cache.stat.exists or grafana_plugin == 'install'ignore_errors: trueenvironment: "{{ proxy_env | default({}) }}"git:repo: '{{ item }}'dest: /var/lib/grafana/plugins/{{ item | basename }}update: yeswith_items: "{{ grafana_git_plugins }}"
PostgreSQL数据库——Pigsty grafana Ansible相关推荐
- 高手过招,精彩纷呈:PostgreSQL数据库人才与业务生态应用论坛圆满落幕
经过数月紧密筹备,第二届长沙·中国1024程序员节于2021年10月23日在湖南省长沙市重磅开幕.本次大会聚焦行业内的多个领域,如果你最感兴趣的领域是数据库,那你一定不能错过10月23日下午的Post ...
- 云原生丨手把手教你使用zabbix监控postgresql数据库(超详细讲解)
文章目录 一.前言 二.什么是zabbix 三.zabbix安装步骤 四.监控postgresql实现步骤 一.前言 对于运维人员来说,监控是非常重要的,因为如果想要保证线上业务整体能够稳定运行,那么 ...
- pg数据库开启远程连接_如何运行远程客户端连接postgresql数据库
如何运行远程客户端连接 postgresql 数据库 前提条件是 2 个: 1 , pg_hba.conf 里面配置了运行远程客户机连接 pg_hba.conf 配置后需要重新加载 reload 生效 ...
- 数据库服务器 之 PostgreSQL数据库的日常维护工作
来自:LinuxSir.Org 摘要:为了保持所安装的 PostgreSQL 服务器平稳运行, 我们必须做一些日常性的维护工作.我们在这里讨论的这些工作都是经常重复的事情, 可以很容易地使用标准的 U ...
- Centos 7环境下源码安装PostgreSQL数据库
马上就要去实习了,工作内容是搞数据仓库方面的,用的是postgresql关系型数据库,于是自己先来了解下这种数据的用法,之后说说这个数据库和MySQL的关系和区别. 1.Postgresql简介 看了 ...
- Ubuntu安装、使用postgresql数据库
Ubuntu安装.使用postgresql数据库 $ sudo apt-get install postgresql (端口为5432) $ sudo apt-get install postgre ...
- [原创]Silverlight与PostgreSQL数据库的互操作(CURD完全解析)
今天将为大家介绍如何让Silverlight使用PostgreSQL作为后台数据库以及CURD操作. 准备工作 1)建立起测试项目 细节详情请见强大的DataGrid组件[2]_数据交互之ADO.NE ...
- postgresql数据库的数据导出
一.pg_dump的用法: 数据库的导入导出是最常用的功能之一,每种数据库都提供有这方面的工具,例如Oracle的exp/imp,Informix的dbexp/dbimp,MySQL的mysqldum ...
- 解决postgresql数据库localhost可以连接,ip连接不了的问题
解决postgresql数据库localhost可以连接,ip连接不了的问题 参考文章: (1)解决postgresql数据库localhost可以连接,ip连接不了的问题 (2)https://ww ...
- 忘了PostgreSQL数据库的密码的解决方案
问题:忘了PostgreSQL数据库的密码应该如何解决? 解决方法: 首先打开data目录下的pg_hba.conf配置文件, 找到: # IPv4 local connections: host a ...
最新文章
- 关于python使用cv画矩形并填充颜色同时填充文字
- 标准情况下的最优方案与魔鬼赛道
- 为无LIB的DLL制作LIB函数符号输入库zz
- html5家谱资源网,免费家谱系统(ASP,Access,CSS,html5)
- mybatis generator逆向工程使用
- matlab 定义一个有自变量的方程_Eviews、Stata、Python、Matlab、R描述+相关+回归分析教程汇总...
- 核心期刊 计算机应用与软件,计算机应用与软件 统计源期刊北大核心期刊
- 苹果Mac强大的采样器音源软件:Native Instruments Kontakt
- paip.验证码识别---使用字符集的选取
- FFT中频谱泄露的两种理解
- android版自动点击器,自动点击器安卓低配版
- 如何使用Java以编程方式在Excel中创建数据透视表?
- 随机矩阵理论_随机PWM可降低噪声并减少三相逆变器应用中的辐射
- CISSP-OSG-每章小结梳理
- 同花顺l2接口使用体验感怎么样?
- 2020双十一,阿里云GRTN拉开直播和RTC技术下半场的序幕
- unity复现中的错误
- Chrome打开网页不慢,但是卡顿,滚动滚轮卡顿,打开b站等特定网址卡顿问题解决
- Java 泛型方法/接口、泛型限定
- 【PS实例】轻松打造梦幻的照片
热门文章
- OpenCV-Python+Moviepy 结合进行视频特效处理
- 6目摄像头照片球面投影变换拼接全景图片
- timeroc 最优最佳截断值特异度(specificity)与灵敏度(sensitivity)
- 寄存器的七种寻址方式
- 水晶报表java_JAVA水晶报表从环境搭建到创建动态水晶报表
- 测试内存条是否兼容软件,18款内存条兼容性测试
- FileOpen 及相关文件读写
- [CVE-2021-45105] Apache Log4j2 漏洞复现与原理详细分析
- 商鞅的APP运营之道
- [转]用Excel制作甘特图并管理项目