본문 바로가기

개발이야기/open source

[Telegraf + influxDB + Grafana]Setup DevOps monitoring system in 10min

 

 

 

The role of each solution

 

 

What you'll build

Beautiful system metric monitoring  system for own computer(localhost).

 

What you'll need

* About 10 minutes

* Macbook

* Homebrew

 

 

Install & setup apps(3min)

1. install telegraf

$ brew install telegraf

 

2. setup telegraf

$ cd /usr/local/Cellar/telegraf/1.5.1/bin
$ telegraf config > telegraf.conf
$ vi telegraf.conf

###############################################################################
#                            OUTPUT PLUGINS                                   #
###############################################################################

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
  ## The full HTTP or UDP URL for your InfluxDB instance.
  ##
  ## Multiple urls can be specified as part of the same cluster,
  ## this means that only ONE of the urls will be written to each interval.
  # urls = ["udp://127.0.0.1:8089"] # UDP endpoint example
  urls = ["http://127.0.0.1:8086"] # required
  ## The target database for metrics (telegraf will create it if not exists).
  database = "telegraf" # required

3. install influxdb

$ brew install influxdb

 

4. install grafana

$ brew install grafana

 

Start apps(1min)

1. start influxdb

$ ln -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist
 

2. create database which name is telegraf

$ influx
Connected to http://localhost:8086 version v1.4.2
InfluxDB shell version: v1.4.2
> create database telegraf
> use telegraf
Using database telegraf
 

3. start grafana

$ brew tap homebrew/services
$ brew services start grafana

 

4. start telegraf

$ telegraf --config telegraf.conf
 

 

 

 

Configure dashboard (6min)

User : admin / Password : admin

InfluxDB details / User : admin / Password : admin

If you want to show fields?

 

$ influx
Connected to http://localhost:8086 version v1.4.2
InfluxDB shell version: v1.4.2
> SHOW FIELD KEYS
name: cpu
---------
fieldKey                fieldType
usage_guest             float
usage_guest_nice           float
usage_idle                    float
usage_iowait                  float
usage_irq                     float
usage_nice                    float
usage_softirq                 float
usage_steal                   float
usage_system                  float
usage_user                    float

name: mem
---------
fieldKey                fieldType
active                           integer
available                     integer
available_percent          float
buffered                      integer
cached                           integer
free                             integer
inactive                      integer
total                            integer
used                             integer
used_percent                  float

 

CPU usage query

select usage_user from cpu

Memory usage query

available_percent from mem

used_percent from mem

select Stack mode 

 

Done

 

You can also customize graphs with plugin

 

 

End of Documents

반응형