2018年5月28日 星期一

InfluxDB on Windows

https://www.jianshu.com/p/a1344ca86e9b

cd C:\d\TICK\influxdb-1.5.2-1
influxd.exe --config influxdb.conf
influx.exe
C:\d\TICK\influxdb-1.5.2-1>influx
Connected to http://localhost:8086 version 1.5.2
InfluxDB shell version: 1.5.2

show databases
drop database telegraf
create database cadvisor
create user testuser with password 'testpwd'
grant all privileges on cadvisor to testuser
create retention policy "cadvisor_retention" on "cadvisor" duration 30d replication 1 default ## keep 30 days

Database
Database contains multiple measurements, one set of shared retention policy, continuous queries, many users. InfluxDB prohibits update and delete to cater for insert and read.

Fields vs Tags
Both fields and tags are key-value pair that associate to a point of a measurement. Fields are not indexed but field value can be any type not only string but also integer, float and boolean, whereas tags are indexed but tag value must be string type. Using indexed string tags in query is much more faster than the non-indexed heterogeneous fields. Typically field values have high variation and tag values have very low variation.

Series
A tag is a key-value pair and a tag set has tags having unique key-value. Number of series is the number of unique tag key-value. A series is a unique way to view the unique indexed points.


2018年5月18日 星期五

Compile Telegraf on Windows 7



Install

Install https://dl.google.com/go/go1.10.2.windows-amd64.msi
Install Git-2.17.1.2-64-bit.exe (for go get)
Install make-3.81.exe (for make Telegraf)
Add C:\Program Files (x86)\GnuWin32\bin to PATH


C:\Users\User\go>go version
go version go1.10.2 windows/amd64

C:\Users\User\go>echo %GOPATH%
C:\Users\User\go

go get -u github.com/golang/lint/golint
go get github.com/sparrc/gdm
go get -d github.com/influxdata/telegraf

gdm restore --parallel=true copy C:\Users\User\go\src\github.com\influxdata\telegraf\Godeps to C:\Users\User\go\Godeps
gdm restore --parallel=true

cd %GOPATH%/src/github.com/influxdata/telegraf
make


C:\Users\User\go\src\github.com\influxdata\telegraf


Input Plugin

cd /home/ricky/go/src/github.com/influxdata/telegraf/plugins/inputs
grep -nr "Start(acc telegraf.Accumulator)"

It shows below plugins use Start()

amqp_consumer
cassandra
http_listener
jti_openconfig_telemetry
kafka_consumer
kafka_consumer_legacy
logparser
mqtt_consumer
nats_consumer
nsq_consumer
socket_listener
tail
tcp_listener
udp_listener
webhooks
zipkin

Plugin

input.go

type Input interface {

SampleConfig() string

Description() string

Gather(Accumulator) error

}


Add Input Plugin

telegraf/plugins/inputs/all/all.go
_ "github.com/influxdata/telegraf/plugins/inputs/sin"

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...