opentsdb+grafana监控系按使用总结,opentsdbgrafana
opentsdb+grafana监控系按使用总结,opentsdbgrafana
一、OpenTSDB简介
开源监控系统OpenTSDB,用hbase存储所有的时序(无须 采样)来构建一个分布式、可伸缩的时间序列数据库。它支持秒级数据采集所有metrics,支持永久存储,可以做容量规划,并很容易的接入到现有的报警系 统里。OpenTSDB可以从大规模的集群(包括集群中的网络设备、操作系统、应用程序)中获取相应的metrics并进行存储、索引以及服务,从而使得这些数据更容易让人理解,如web化,图形化等。 对于运维工程师而言,OpenTSDB可以获取基础设施和服务的实时状态信息,展示集群的各种软硬件错误,性能变化以及性能瓶颈。对于管理者而言,OpenTSDB可以衡量系统的SLA,理解复杂系统间的相互作用,展示资源消耗情况。集群的整体 作业情况,可以用以辅助预算和集群资源协调。对于开发者而言,OpenTSDB可以展示集群的主要性能瓶颈,经常出现的错误,从而可以着力重点解决重要问题。 这里有几篇文字对于OpenTSDB的介绍非常详细: http://liubin.org/blog/2016/03/05/tsdb-opentsdb/ http://www.jianshu.com/p/0bafd0168647 https://yq.aliyun.com/articles/54785 这个是对表结构的详细介绍 https://zhengheng.me/2016/03/07/opentsdb-hbase-tuning/ 优化二、OpenTSDB的安装配置
1、基本环境搭建 首先确保你的系统有以下条件满足: jdk 1.6 以上 并配置好环境变量 hbase 0.92 或更高版本 gnuplot 4.2 或更高(yum安装吧) autotools(好像只需要其中的autoconf和automake即可)#1. 重新安装新版本autoconf/automake #删除旧版本 yum erase autoconf #安装新版本autoconf wget http://mirrors.ustc.edu.cn/gnu/autoconf/autoconf-2.68.tar.gz tar -zxvf autoconf-2.68.tar.gz cd autoconf-2.68 ./configure make make install ln -s /usr/local/bin/autoconf /usr/bin/autoconf #安装新版本automake wget http://mirrors.ustc.edu.cn/gnu/automake/automake-1.11.2.tar.gz tar -zxvf automake-1.11.2.tar.gz cd automake-1.11.2 ./configure make make install ln -s /usr/local/bin/automake /usr/bin/automake ln -s /usr/local/bin/aclocal /usr/bin/aclocal #2.安装gnuplot-4.4.0 wget http://nchc.dl.sourceforge.net/project/gnuplot/gnuplot/4.4.0/gnuplot-4.4.0.tar.gz tar -zxvf gnuplot-4.4.0.tar.gz cd gnuplot-4.4.0 ./configure make make install ln -s /usr/local/bin/gnuplot /usr/bin/gnuplot2、OpenTSDB的安装 然后下面是我通过源码安装的过程,希望能够有借鉴意义:
1 git clone https://github.com/OpenTSDB/opentsdb.git 2 cd opentsdb 3 ./build.sh 4 #当build.sh运行完毕的时候 你应该在opentsdb/build文件夹下看到opentsdb.jar最后安装成功了,这里总结一下: 首先,java要安装好,各变量也要配置好; 其次,autotools的那几个工具也要安装好; opentsdb必须的gnuplot也要安装好; 额外:因为OpenTSDB的后端是hbase,所以这里也加上我配置的hbase的简单介绍: 1、hbase的安装配置,解压完后,在/etc/profile中加上 HBASE_HOME=path/to/hbase-0.94.X 不加的话,后面命令需要自己手动加上 完成后source /etc/profile生效; 然后,配置hbase的zookeeper属性,这与 hbase-env.sh 文件相关,文件中 HBASE_MANAGES_ZK 环境变量用来设置是使用hbase默认自带的 Zookeeper还是使用独立的ZooKeeper。HBASE_MANAGES_ZK=false 时使用独立的,为true时使用默认自带的。 手动启动hbase: ./start-hbase cd opentsdb的build目录 && HBASE_HOME=/home/xxx/hbase-1.2.5 ./src/create_table.sh ./tsdb tsd
3、配置文件
配置文件及参数:
zookeeper(hbase依赖于zookeeper所以保证有hbase的同时就保证了有zookeeper)在opentsdb/src文件夹下有一个opentsdb.conf的配置文件,内有3个主要属性需要配置: tsd.http.cachedir opentsdb的缓存数据存放目录,找个路径配置好 tsd.http.staticroot opentsdb web 静态文件的root路径,一般在opentsdb/build/staticroot tsd.network.port 绑定的端口 下面配置为常用可选配置 tsd.network.bind = 0.0.0.0 web 页面绑定IP,一般配置为0.0.0.0 保证其他IP可以访问opentsdb的web页面。 tsd.storage.hbase.zk_quorum = localhost 这个为zookeeper的地址。一般单机版hbase不需要配置 默认在本机。如果zookeeper是独立的或者分布式在其他机器上请指定IP 多个IP逗号分隔. 还有一些其他配置,请参见官网文档: http://opentsdb.net/docs/build/html/user_guide/configuration.html 配置文件填写好了之后将其复制至/etc/下 启动opentsdb会从以下几个地方搜索配置文件: ./opentsdb.conf /etc/opentsdb.conf /etc/opentsdb/opentsdb.conf /opt/opentsdb/opentsdb.conf 如果你多个地方都有配置文件,请确保这些多个配置文件的内容一致。也就是说修改一个要同步所有,不然根据你启动命令执行的路径不同可能会搜索到不同的配置文件。 建议只弄一个 放在/etc/下就好了。 注意! 若要将opentsdb的tag_values()函数获得的结果自动更新,需要设置四个参数在配置文件中
- tsd.core.meta.enable_realtime_uid
- tsd.core.meta.enable_tsuid_tracking
- tsd.core.meta.enable_tsuid_incrementing
- tsd.core.meta.enable_realtime_ts
参数名 | 类型 | 是否必选 | 默认值 | 详细介绍 |
tsd.core.auto_create_metrics | Boolean | Optional | false | 新metric的数据点是否被指定UID。 当为false时,数据库中不具有metric的数据点将被拒绝并将抛出异常。 |
tsd.core.auto_create_tagks (2.1) | Boolean | Optional | true | 带有新标签名称的数据点是否会将一个UID分配给tagk。 当为false时,具有不在数据库中的标签名称的数据点将被拒绝并将抛出异常。 |
tsd.core.auto_create_tagvs (2.1) | Boolean | Optional | true | 是否具有新标签值的数据点将分配给tagv的UID。 当为false时,具有不在数据库中的标记值的数据点将被拒绝并将抛出异常。 |
Name | Data Type | Required | Description | QS |
metric | String | Required | The name of the metric you are storing | sys.cpu.nice |
timestamp | Integer | Required | A Unix epoch style timestamp in seconds or milliseconds. The timestamp must not contain non-numeric characters. | 1365465600 |
value | Integer, Float, String | Required | The value to record for this data point. It may be quoted or not quoted and must conform to the OpenTSDB value rules: Writing Data |
42.5 |
tags | Map | Required | A map of tag name/tag value pairs. At least one pair must be supplied. | {"host":"web01"} |
Name | Data Type | Description | Default | Example |
--delete | Flag | Optional flag that deletes data in any row that matches the query. See warning below. 可选标记,用于删除与查询匹配的任何行中的数据。 |
Not set | --delete |
--import | flag | Optional flag that outputs results in a text format useful for importing or storing as a backup. | Not set | --import |
START-DATE | String or Integer | Starting time for the query. This may be an absolute or relative time. See Dates and Times for details | 1h-ago | |
END-DATE | String or Integer | Optional end time for the query. If not provided, the current time is used. This may be an absolute or relative time. See Dates and Times for details | Current timestamp | 2014/01/01-00:00:00 |
query | String | One or more command line queries | sum tsd.hbase.rpcs type=put |
评论暂时关闭