{"id":2883,"date":"2019-05-08T23:43:38","date_gmt":"2019-05-08T20:43:38","guid":{"rendered":"https:\/\/kifarunix.com\/?p=2883"},"modified":"2020-05-31T09:30:31","modified_gmt":"2020-05-31T06:30:31","slug":"install-and-setup-tig-stack-on-fedora-30","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-setup-tig-stack-on-fedora-30\/","title":{"rendered":"Install and Setup TIG Stack on Fedora 30"},"content":{"rendered":"\n
In this guide, we are going to learn how to install and setup TIG stack on Fedora 30 for monitoring system metrics such as memory, disk, logged in users, system load, swap usage, system uptime, system processes. TIG stack is a group of powerful open-source monitoring tools, Telegraf, InfluxDB and Grafana where;<\/p>\n\n\n\n
In order to setup TIG stack on Fedora 30, you need to install and configure each component of the stack. We have already covered the installation of Telegraf and InfluxDB on Fedora 30 in our previous guides. See the links below for the installation procedure.<\/p>\n\n\n\n
Install Telegraf on Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n Install InfluxDB on Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n Grafana can be installed on Fedora 30 using the RPM binary package or directly via Grafana repository using DNF package manager. To install using an RPM binary package, <\/p>\n\n\n\n To install Grafana from Grafana repository, you need to create the repository as shown below;<\/p>\n\n\n\n Then install Grafana via the Start the Grafana server and enable it to run on boot.<\/p>\n\n\n\n Open Grafana port on firewalld to allow external access.<\/p>\n\n\n\n You can now access Grafana via the address http:\/\/server-IP:3000<\/strong>. The default credentials for username and password are admin. Reset the password when prompted and proceed to Grafana dashboard.<\/p>\n\n\n\n Learn how to Install Grafana on Fedora 29, Debian 9, Ubuntu 18.04 by following the links below;<\/p>\n\n\n\n Once you have installed InfluxDB, you need to create a database that will used to store the time series metrics collected by the Telegraf agent. Hence, connect to InfluxDB and create a database and databaseas shown below;<\/p>\n\n\n\n You can verify this by running the commands below;<\/p>\n\n\n\n Test connection to the database using the username and password created.<\/p>\n\n\n\n Once the installation of Telegraf is done, proceed with configuration. Telegraf is plugin-driven with 4 distinct plugin types:<\/p>\n\n\n\n Well, in this guide, we are going to configure TIG stack to monitor system memory usage, system processes, disk usage, system load, system uptime and logged in users.<\/p>\n\n\n\n The default configuration file for Telegraf is \/etc\/telegraf\/telegraf.conf<\/strong>. Before we can continue, we will make a backup of the default configuration.<\/p>\n\n\n\n Next, create a new configuration with your specific metrics. To generate a configuration file, Telegraf provides a command line tool, telegraf<\/strong>, that can be used to define specific input plugins, output plugins.<\/p>\n\n\n\n For example to to generate a configuration file with input plugins such as system memory usage, cpu, swap, load, logged in users, processes and define output as InfluxDB, run the command below;<\/p>\n\n\n\n Next, edit the configuration file to define the URL for InfluxDB, the metrics database, the user and password to connect to metrics database such that your Telegraf configuration file looks like below without comment lines.<\/p>\n\n\n\n To learn more options used, check Telegraf administration configuration<\/a> page.<\/p>\n\n\n\n Once you are done with Telegraf configuration, restart it.<\/p>\n\n\n\n Telegraf enables you to run configuration tests outputing metrics to stdout. To run a general test for all metrics defined;<\/p>\n\n\n\n To run configuration test for a specific metric for example, system input plugin;<\/p>\n\n\n\n Login to Grafana dashboard as admin with your new password.<\/p>\n\n\n\n Next, you need to add the data source. In this case, our data source is InfluxDB, hence click on Add data source<\/strong> and select InfluxDB.<\/p>\n\n\n\n Set the Name and URL of the InfuxDB data source (Leave it as http:\/\/localhost:8086 for local connection).<\/p>\n\n\n\n Scroll down and set the InfluxDB database connection details defined above.<\/p>\n\n\n\n Next, click on Save & Test<\/strong> to test the connection to the InfluxDB database.<\/p>\n\n\n\n You can either create your own dashboards or import an already customized dashboard from Grafana community<\/a>. In this guide, we are going to download a dashboard that a user jmutai has customized<\/a>. All credit goes back to him.<\/p>\n\n\n\n Hence, click the plus (+<\/strong>) on the left panel and select import. After that, copy the ID of the dashboard and paste it as shown in the screenshot below.<\/p>\n\n\n\n After a few, location of the Grafana dashboard to import is updated. Next, select the InfluxDB data source and import the dashboard.<\/p>\n\n\n\n Immediately your dashboard is imported, you should be able to see your dashboards.<\/p>\n\n\n\n You have successfully installed and setup TIG Stack on Fedora 30 for collecting and monitoring system metrics. Feel free to explore this awesome monitoring tools.<\/p>\n\n\n\n You can also check how to install and setup TIG stack on Ubuntu 20.04 by following the link below;<\/p>\n\n\n\nInstall Grafana on Fedora 30<\/h2>\n\n\n\n
dnf install https:\/\/dl.grafana.com\/oss\/release\/grafana-5.4.2-1.x86_64.rpm<\/code><\/pre>\n\n\n\n
cat > \/etc\/yum.repos.d\/grafana.repo << EOF\n[grafana]\nname=grafana\nbaseurl=https:\/\/packages.grafana.com\/oss\/rpm\nrepo_gpgcheck=1\nenabled=1\ngpgcheck=1\ngpgkey=https:\/\/packages.grafana.com\/gpg.key\nsslverify=1\nsslcacert=\/etc\/pki\/tls\/certs\/ca-bundle.crt\nEOF<\/code><\/pre>\n\n\n\n
dnf<\/code> command.<\/p>\n\n\n\n
dnf install grafana<\/code><\/pre>\n\n\n\n
systemctl status grafana-server
systemctl enable grafana-server<\/code><\/pre>\n\n\n\nfirewall-cmd --add-port=3000\/tcp --permanent
firewall-cmd --reload<\/code><\/pre>\n\n\n\nConfigure TIG Stack on Fedora 30<\/h2>\n\n\n\n
Create InfluxDB Database and User<\/h3>\n\n\n\n
influx<\/code><\/pre>\n\n\n\n
Connected to http:\/\/localhost:8086 version 1.7.6\nInfluxDB shell version: 1.7.6\nEnter an InfluxQL query\n> create database telegraf\n> use telegraf\nUsing database telegraf\n> create user telegraf with password 'StrongP@SS'<\/code><\/pre>\n\n\n\n
> show databases\nname: databases\nname\n----\n_internal\ntelegraf\n> show users\nuser admin\n---- -----\ntelegraf false\n><\/code><\/pre>\n\n\n\n
influx -username 'telegraf' -password 'StrongP@SS' -database telegraf<\/code><\/pre>\n\n\n\n
Connected to http:\/\/localhost:8086 version 1.7.6\nInfluxDB shell version: 1.7.6\nEnter an InfluxQL query\n> <\/code><\/pre>\n\n\n\n
Configuring Telegraf<\/h3>\n\n\n\n
mv \/etc\/telegraf\/telegraf.conf \/etc\/telegraf\/telegraf.conf.bak<\/code><\/pre>\n\n\n\n
telegraf config -input-filter cpu:mem:swap:system:processes -output-filter influxdb > \/etc\/telegraf\/telegraf.conf<\/code><\/pre>\n\n\n\n
[global_tags]\n[agent]\n interval = \"10s\"\n round_interval = true\n metric_batch_size = 1000\n metric_buffer_limit = 10000\n collection_jitter = \"0s\"\n flush_interval = \"10s\"\n flush_jitter = \"0s\"\n precision = \"\"\n debug = false\n quiet = false\n logfile = \"\"\n hostname = \"\"\n omit_hostname = false\n[[outputs.influxdb]]\n urls = [\"http:\/\/127.0.0.1:8086\"]\n database = \"telegraf\"\n username = \"telegraf\"\n password = \"StrongP@SS\"\n[[inputs.cpu]]\n percpu = true\n totalcpu = true\n collect_cpu_time = false\n report_active = false\n[[inputs.disk]]\n ignore_fs = [\"tmpfs\", \"devtmpfs\", \"devfs\", \"overlay\", \"aufs\", \"squashfs\"]\n[[inputs.diskio]]\n[[inputs.kernel]]\n[[inputs.mem]]\n[[inputs.processes]]\n[[inputs.swap]]\n[[inputs.system]]<\/code><\/pre>\n\n\n\n
systemctl restart telegraf<\/code><\/pre>\n\n\n\n
Telegraf configuration tests<\/h3>\n\n\n\n
telegraf --config telegraf.conf --test<\/code><\/pre>\n\n\n\n
telegraf -test -config \/etc\/telegraf\/telegraf.conf --input-filter system<\/code><\/pre>\n\n\n\n
2019-05-08T03:01:29Z I! Starting Telegraf 1.10.3\n> system,host=fedora30.example.com load1=0,load15=0,load5=0,n_cpus=1i,n_users=2i 1557284489000000000\n> system,host=fedora30.example.com uptime=33495i 1557284489000000000\n> system,host=fedora30.example.com uptime_format=\" 9:18\" 1557284489000000000<\/code><\/pre>\n\n\n\n
Configure Grafana<\/h3>\n\n\n\n
Add Data source<\/h4>\n\n\n\n
<\/a><\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n
Setup Grafana Dashboard<\/h4>\n\n\n\n
<\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n