2018年5月16日 星期三

InfluxDB + Telegraf + Chronograf + Go + RabbitMQ on CentOS 7.5



Telegraf

https://www.linuxdaxue.com/series/influxdb-series/

Install InfluxDB
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.5.2.x86_64.rpm
sudo yum localinstall influxdb-1.5.2.x86_64.rpm

Start Service
CentOS 6 sudo service influxdb start
CentOS 7 sudo systemctl start influxdb

Start Console
cd /usr/bin
influx
[ricky@centos75 bin]$ influx
Connected to http://localhost:8086 version 1.5.2
InfluxDB shell version: 1.5.2
>

Show Database

> show databases

name: databases

name

----

_internal



> create database test
> use test
> drop database test

InfluxDB has Point, time, tags, fields

A point has a time, tags, fields
A tag is indexable
A field is non-indexable

measurement (table)

drop measurement disk_free
> show measurements
> insert disk_free,hostname=server01 value=442221834240i 1435362189575692182
> insert disk_free,os=10 value=123i 1435362189575692111
> insert disk_free,os=11 value=222i 1435362189575692222
> insert disk_free,hostname=server02,os=10 value=000i 1435362189575692000
> show measurements --will see disk_free




> select * from disk_free
name: disk_free
time                hostname os value
----                -------- -- -----
1435362189575692000 server02 10 0
1435362189575692111          10 123
1435362189575692182 server01    442221834240
1435362189575692222          11 222


Think of having every attribute is a hashmap with time as key of indexable object key and non-indexable value pair.

InfluxDB has no modify and delete!

Series

> show series from disk_free
key
---
disk_free,hostname=server01
disk_free,hostname=server02,os=10
disk_free,os=10
disk_free,os=11

Think of combination of tag

HTTP API

curl -POST http://localhost:8086/query --data-urlencode "q=DROP DATABASE mydb"
curl -POST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'

Retention Policies


> show retention policies on mydb
name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 0s       168h0m0s           1        true

Study more about policies


Continuous Query

HTTP Query

1 Query

curl -GET 'http://localhost:8086/query?pretty=true' --data-urlencode "db=mydb"  --data-urlencode "q=SELECT value FROM cpu_load_short WHERE region='us-west'"

2 Queries ; separated

curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=mydb" --data-urlencode "q=SELECT value FROM cpu_load_short WHERE region='us-west'; SELECT count(value) FROM cpu_load_short WHERE region='us-west'"

With epoch in second

curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=mydb"  --data-urlencode "epoch=s" --data-urlencode "q=SELECT value FROM cpu_load_short WHERE region='us-west'"

Number of records by chunk size

curl -G 'http://localhost:8086/query?pretty=true
' --data-urlencode "db=mydb" --data-urlencode "chunk_size=200" --data-urlencode "q=SELECT value FROM cpu_load_short WHERE region='us-west'"


Telegraf

Installation

wget https://dl.influxdata.com/telegraf/releases/telegraf-1.6.2-1.x86_64.rpm

sudo yum localinstall telegraf-1.6.2-1.x86_64.rpm



Start

sudo service telegraf start
sudo systemctl start telegraf

Check Data

influx
show databases
show measurements
use cpu
show field keys
SELECT usage_idle FROM cpu WHERE cpu = 'cpu-total' LIMIT 5


Chronograf

Installation

wget https://dl.influxdata.com/chronograf/releases/chronograf-1.4.4.2.x86_64.rpm

sudo yum localinstall chronograf-1.4.4.2.x86_64.rpm


Start

sudo systemctl start chronograf

Setup TCP port 8888

sudo firewall-cmd --get-active-zones
sudo firewall-cmd --zone=public --add-port=8888/tcp --permanent
sudo firewall-cmd --reload


Go

wget https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz
sudo tar -C /usr/local -zxvf go1.10.2.linux-amd64.tar.gz


Export Path

/etc/profile (for a system-wide installation) or $HOME/.profile

export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/go

Test Go

mkdir -p $GOPATH/src/hello
cd $GOPATH/src/hello
vi hello.go
    package main
    import "fmt"
    func main() { fmt.Printf("hello, world\n") }
go run hello.go
go build
./hello

Install GDM

sudo yum install -y gdm

Download Telegraf

go get -d github.com/influxdata/telegraf
cd $GOPATH/src/github.com/influxdata/telegraf
make 

Run Telegraf

./telegraf config > telegraf.conf
./telegraf --input-filter cpu --output-filter influxdb config > telegraf.cpu.conf

./telegraf --config telegraf.cpu.conf --test
./telegraf --config telegraf.cpu.conf 
Now Chronograf shows CPU Usage only


RabbitMQ

https://www.howtoforge.com/tutorial/how-to-install-rabbitmq-server-on-centos-7/



NSQ

https://github.com/etoricky/NsqDemo



Continue


Continue





沒有留言:

張貼留言

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...