In this article, we’re going to look at how to Monitor a Linux System with Grafana and Telegraf. Telegraf metrics will be stored on InfluxDB, then we can visualize them on Grafana using a system dashboard.
A prerequisite for this setup is a Linux system and InfluxDB server. You can check our previous guide on How to Install InfluxDB on CentOS 7. On the same guide, we defined what telegraf and InfluxDB are before demonstrating the installation steps.
Installing Telegraf on CentOS 7
Influxdata provides the repository for installing telegraf on CentOS 7. To add the repository to your system, use the commands:
# vim /etc/yum.repos.d/influxdb.repo
Add the following content:
[influxdb] name = InfluxDB Repository - RHEL \$releasever baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable enabled = 1 gpgcheck = 1 gpgkey = https://repos.influxdata.com/influxdb.key
Update cache to confirm that the repository is working fine:
$ sudo yum makecache fast
Then install telegraf:
# yum -y install telegraf
Configure telegraf on Linux
A basic telegraf configuration with InfluxDB output and basic inputs to collect system metrics can look like below:
For a comprehensive list of inputs supported by Telegraf, visit Telegraf inputs Githubpage.
Replace:
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.
Once all changes have been made, you can then start and enable the telegraf service:
# systemctl start telegraf && systemctl enable telegraf
This will automatically create the InfluxDB database if it doesn’t exist.
Add an InfluxDB data source to Grafana
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
Under InfluxDB Details, provide:
- Database name as defined on telegraf configuration file
- HTTP authentication username and password as configured on telegraf.
Importing Grafana Dashboard
Once the data source has been added, the next thing is to import the dashboard. I customized one of the dashboards initially created by a user on the community and uploaded it.
Download the dashboard from https://grafana.com/dashboards/5955, it is in JSON format. The head over to Grafana > Import
Select Upload .json and upload downloaded file. Alternatively, 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.
You should see Metrics being visualized immediately.
출처 : https://computingforgeeks.com/monitor-linux-system-with-grafana-and-telegraf/
'운영체제 > 리눅스' 카테고리의 다른 글
[Centos6 & 7] 방화벽 설정 (0) | 2018.08.15 |
---|---|
[Centos7] ELK 설치 -스크랩 (ElasticSearch, Logstash, Kibana) (0) | 2018.08.14 |
[Centos7] 시스템 모니터링 1 - influxDB, Grafana, telegraf (0) | 2018.08.05 |
[CentOS7] 시스템 모니터링 서버 이해 0 - InfluxDB, Grafana , Telegraf 프로세스 이해 (0) | 2018.08.05 |
[Centos7] Java 설치 (0) | 2018.08.04 |