Prerequisites:
- Debian OS installed
- OS updates and upgrades must be installed.
- Network must be configured(192.168.138.222)
InfluxDB server configurations:
If you're working on large infrastructure you must have these configuration on separate server. For Lab work I have installed it on same server 192.168.138.222.
Installation(Debian Buster):
sudo apt update
sudo apt install -y gnupg2 curl wget
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update
sudo apt install -y influxdb
sudo systemctl enable --now influxdb
systemctl status influxdb
Note: If you have configured firewall you must allow 8086/8088 port.
By default, InfluxDB uses the following network ports:
TCP port 8086 is used for client-server communication over InfluxDB’s HTTP API
TCP port 8088 is used for the RPC service for backup and restore
sudo vim /etc/influxdb/influxdb.conf
enable auth-enabled parameter under http
[http]
auth-enabled = true
Set username/password:
curl -XPOST "http://localhost:8086/query" --data-urlencode "q=CREATE USER thenabx WITH PASSWORD 'somepassword' WITH ALL PRIVILEGES"
username:thenabx
password:somepassword
To login in terminal:
influx -username 'thenabx' -password 'somepassword'
Once logged in:
> create database 'grafana'
> use grafana
> show measurements
Telegraf Installation:
Telegraf can be installed on any Linux server you want to monitor stats for. But in my case I have installed on grafana server to monitor its stats first.
sudo apt update
sudo apt install -y gnupg2 curl wget
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update
sudo apt install -y telegraf
cd /etc/telegraf/
mv telegraf.conf telegraf.conf-default
vim telegraf.conf
And add following
#############################################
[global_tags]
# Configuration for telegraf agent
[agent]
interval = "10s"
debug = false
hostname = "server-hostname"
round_interval = true
flush_interval = "10s"
flush_jitter = "0s"
collection_jitter = "0s"
metric_batch_size = 1000
metric_buffer_limit = 10000
quiet = false
logfile = ""
omit_hostname = false
###############################################################################
# OUTPUTS #
###############################################################################
[[outputs.influxdb]]
urls = ["http://influxdb-ip:8086"]
database = "database-name"
timeout = "0s"
username = "auth-username"
password = "auth-password"
retention_policy = ""
###############################################################################
# INPUTS #
###############################################################################
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs"]
[[inputs.io]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.system]]
[[inputs.swap]]
[[inputs.netstat]]
[[inputs.processes]]
[[inputs.kernel]]
########################################
Change Followings in above configs and save/exit vim.
server-hostname: with your valid hostname.
http://influxdb-ip:8086 with your valid InfluxDB URL, IP address, and port.
database-name with InfluxDB database name for this host
auth-username with InfluxDB http authentication username.
auth-password with InfluxDB http authentication password.
systemctl enable telegraf
systemctl start telegraf
systemctl status telegraf
Grafana Installation:
To install the latest Enterprise edition:
sudo apt-get install -y apt-transport-https
sudo apt-get install -y software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
Add this repository for stable releases:
echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
After you add the repository:
sudo apt-get update
sudo apt-get install grafana-enterprise
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl status grafana-server
Enable port 3000 on OS firewall
http://192.168.138.222:3000
Add Data Source:
Before you can add a dashboard to Grafana for Telegraf system metrics, you need to first import the data source. Login to your Grafana and go to Configuration > Data Sources > Add data source
Provide the following details:
- Name – Any valid name
- Type: InfluxDB
- HTTP URL: InfluxDB URL address e.g http://localhost:8086 for local db server
Add Dashboard:
The head over to Grafana > Import
you can use Grafana dashboard URL or ID – 5955. Under Options section, give it a unique name and select data source added earlier from the drop-down menu and click the import button.
MUST SAVE DASHBOARD IN ORDER TO SEE IT IN CASE SERVER REBOOT.
Done! Your questions are welcomed.
References:
https://grafana.com/docs/grafana/latest/installation/debian/
https://computingforgeeks.com/monitor-linux-system-with-grafana-and-telegraf/
https://computingforgeeks.com/install-influxdb-on-debian-10-buster-linux/
No comments:
Post a Comment