influxdb mysql_prometheus + influxdb + grafana + mysql

前言本文介绍使用influxdb 作为prometheus持久化存储和使用mysql 作为grafana 持久化存储的安装方法一 安装go环境如果自己有go环境可以自主编译remote_storage_adapter插件,安装go环境目的就是为了获得此插件,如果没有go环境可以使用我分享的连接下载。链接: https://pan.baidu.com/s/1DJpoYDOIfCeAFC6UGY22X...
摘要由CSDN通过智能技术生成

前言

本文介绍使用influxdb 作为prometheus持久化存储和使用mysql 作为grafana 持久化存储的安装方法

一 安装go环境

如果自己有go环境可以自主编译remote_storage_adapter插件,安装go环境目的就是为了获得此插件,如果没有go环境可以使用我分享的连接下载。

链接: https://pan.baidu.com/s/1DJpoYDOIfCeAFC6UGY22Xg 提取码: uj42

1 下载

wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz

2 安装

tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz

添加环境变量

vim /etc/profile

export GOROOT=/usr/local/go

export GOBIN=$GOROOT/bin

export GOPKG=$GOROOT/pkg/tool/linux_amd64

export GOARCH=amd64

export GOOS=linux

export GOPATH=/go

export PATH=$PATH:$GOBIN:$GOPKG:$GOPATH/bin

vim /etc/profile

go get -d -v

二  安装  influxdb

1 下载并安装

wget https://dl.influxdata.com/influxdb/releases/influxdb-1.5.2.x86_64.rpm

sudo yum localinstall influxdb-1.5.2.x86_64.rpm

2 启动influxdb

systemctl start influxdb

systemctl enable influxdb

以非服务方式启动

influxd

需要指定配置文件的话,可以使用 --config 选项,具体可以help下看看

3 查看相关配置

安装后, 在/usr/bin下面有如下文件

influxd influxdb服务器

influx influxdb命令行客户端

influx_inspect 查看工具

influx_stress 压力测试工具

influx_tsm 数据库转换工具(将数据库从b1或bz1格式转换为tsm1格式)

在 /var/lib/influxdb/下面会有如下文件夹

data 存放最终存储的数据,文件以.tsm结尾

meta 存放数据库元数据

wal 存放预写日志文件

配置文件路径 :/etc/influxdb/influxdb.conf

4 创建http接口用于普罗米修斯

如何进入到db中

influx

如何创建一个prometheus库http 接口

curl -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE prometheus"

三 安装prometheus

1 下载

https://prometheus.io/download/

2 解压安装

tar xf prometheus-2.8.0.linux-amd64.tar.gz

mv prometheus-2.8.0.linux-amd64 /usr/local/prometheus

cd /usr/local/prometheus

./prometheus --version

四 准备remote_storage_adapter

在github上准备一个 remote_storage_adapter 的可执行文件,然后启动它,如果想获取相应的帮助可以使用:./remote_storage_adapter -h来获取相应帮助(修改绑定的端口,influxdb的设置等..),现在我们启动一个remote_storage_adapter来对接influxdb和prometheus:

./remote_storage_adapter -influxdb-url=http://localhost:8086/ -influxdb.database=prometheus -influxdb.retention-policy=autogen,influxdb默认绑定的端口为9201

1 build 插件

/usr/local/go/bin/go get github.com/prometheus/documentation/examples/remote_storage/remote_storage_adapter/

2 使用插件

./remote_storage_adapter --influxdb-url=http://127.0.0.1:8086/ --influxdb.database="prometheus" --influxdb.retention-policy=autogen

3 修改prometheus文件

vim prometheus.yml

添加:

#Remote write configuration (for Graphite, OpenTSDB, or InfluxDB).

remote_write:

- url: "http://localhost:9201/write"

#Remote read configuration (for InfluxDB only at the moment).

remote_read:

- url: "http://localhost:9201/read"

4 启动 prometheus

./prometheus

5 查看有无数据上报

此时只监控了server本身

82bf4bd498e09f122fec2d96d0465c65.png

6 查看 influxdb 数据库内容

>show databases;

name: databases

name

----

_internal

mydb

prometheus

>use prometheus

Using database prometheus

>SHOW MEASUREMENTS

name: measurements

name

----

go_gc_duration_seconds

go_gc_duration_seconds_count

go_gc_duration_seconds_sum

go_goroutines

go_info

go_memstats_alloc_bytes

go_memstats_alloc_bytes_total

go_memstats_buck_hash_sys_bytes

go_memstats_frees_total

go_mems

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值