{"id":372,"date":"2018-11-18T19:00:29","date_gmt":"2018-11-18T17:00:29","guid":{"rendered":"https:\/\/www.petersplanet.nl\/?p=372"},"modified":"2018-11-18T19:06:42","modified_gmt":"2018-11-18T17:06:42","slug":"basic-installation-of-grafana-influxdb-and-telegraf-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.petersplanet.nl\/index.php\/2018\/11\/18\/basic-installation-of-grafana-influxdb-and-telegraf-on-centos-7\/","title":{"rendered":"Basic installation of Grafana, InfluxDB and Telegraf on CentOS 7"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>In order to gain some knowledge about Grafana, InfluxDB and Telegraf I did a basic installation. Grafana and InfluxDB were installed on a CentOS 7 server. The Telegraf agent was installed on a separate CentOS 7 server (which also hosts petersplanet.nl by the way).<br \/>\nVersions:<br \/>\nInfluxDB: 1.7.1<br \/>\nGrafana: 5.3.4-1<br \/>\nTelegraf: 1.8.3-1<br \/>\n<!--more--><\/p>\n<h3>InfluxDB<\/h3>\n<p>All installation activities will be done as root.<\/p>\n<pre><span style=\"font-weight: 400;\"># Get the software\r\nwget https:\/\/dl.influxdata.com\/influxdb\/releases\/influxdb-1.7.1.x86_64.rpm\r\n\r\n# and install\r\nyum localinstall influxdb-1.7.1.x86_64.rpm\r\nsystemctl enable influxdb\r\nsystemctl start influxdb\r\nsystemctl status influxd<\/span>\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">TCP port 8086 is used for client-server communication over InfluxDB\u2019s HTTP API<br \/>\n<\/span><span style=\"font-weight: 400;\">TCP port 8088 is used for the RPC service for backup and restore<\/span><\/p>\n<p>You can view the current configuation with:<\/p>\n<pre><span style=\"font-weight: 400;\">influxd config<\/span><\/pre>\n<p>The configuration file can be found in:\u00a0<span style=\"font-size: 0.875rem;\">\/etc\/influxdb\/influxdb.conf<\/span><\/p>\n<p>Let&#8217;s create a database and make it secure. Create an admin user with all the rights and a user used by Telegraf.<\/p>\n<pre><span style=\"font-weight: 400;\">influx -precision rfc3339<\/span>\r\n&gt; CREATE DATABASE \"MONITORDB\"\r\n&gt; SHOW DATABASES\r\n&gt; CREATE USER \"admin\" WITH PASSWORD 'secret' WITH ALL PRIVILEGES\r\n&gt; CREATE USER \"monitor\" WITH PASSWORD 'secret'\r\n&gt; GRANT ALL ON \"MONITORDB\" to \"monitor\"\r\n&gt; SHOW GRANTS FOR \"monitor\"\r\n&gt; SHOW USERS\r\n<\/pre>\n<p>After that set auth-enabled = true in influxdb.conf and restart influxd<br \/>\nFor this demo we will skip the retention policy but usually you will need to set that as well.<\/p>\n<h3>Grafana<\/h3>\n<pre># Get the software\r\nwget https:\/\/s3-us-west-2.amazonaws.com\/grafana-releases\/release\/grafana-5.3.4-1.x86_64.rpm\r\n\r\n# and install\r\nsudo yum localinstall grafana-5.3.4-1.x86_64.rpm\r\nsystemctl enable grafana-server\r\nsystemctl start grafana-server\r\nsystemctl status grafana-server\r\n<\/pre>\n<p>The configuration can be found in:\u00a0<span style=\"font-weight: 400;\">\/etc\/grafana\/grafana.ini<\/span><\/p>\n<p>Now you should be able to login to Grafana with a web browser.<br \/>\nURL: http:\/\/&lt;your-server&gt;:3000\/<br \/>\nusername: admin<br \/>\npassword: admin<\/p>\n<p>Create a datasource after changing the default password.<br \/>\nName: monitords<br \/>\nType: InfluxDB<\/p>\n<p>Database: MONITORDB<br \/>\nusername: secret<br \/>\npassword: secret<\/p>\n<p>Next thing we need to do is to install and configure a Telegraf agent on a server we would like to monitor.<\/p>\n<h3>Telegraf<\/h3>\n<pre># Get the software\r\nwget https:\/\/dl.influxdata.com\/telegraf\/releases\/telegraf-1.8.3-1.x86_64.rpm\r\n\r\n# and install\r\nsudo yum localinstall telegraf-1.8.3-1.x86_64.rpm\r\nsystemctl enable telegraf\r\nsystemctl start telegraf\r\n<\/pre>\n<p>The configuration file can be found in: \/etc\/telegraf\/telegraf.conf<br \/>\nWe will need to change some settings to be able to communicate with the InfluxDB database.<br \/>\nChange in telegraf.conf:<\/p>\n<pre>[[outputs.influxdb]]\r\n\r\nurls = [\"http:\/\/&lt;your-influxdb-server&gt;:8086\"]\r\ndatabase = \"MONITORDB\"\r\nusername = \"monitor\"\r\npassword = \"secret\"<\/pre>\n<p>After that restart influxdb<br \/>\nNow some basic inputs will be send to the Influx database. You can check this in InfluxDB.<\/p>\n<pre>influx -precision rfc3339\r\n&gt; auth\r\n&gt; use MONITORDB\r\n&gt; show MEASUREMENTS\r\n&gt; select * from CPU\r\n&gt; select * from system\r\n&gt; show series<\/pre>\n<h3>Result<\/h3>\n<p>Next thing is to make all of this visible in Grafana.<br \/>\nCreate a new dashboard, add Panels to it and click on the title of a Panel to edit the settings.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-385 size-large\" src=\"https:\/\/www.petersplanet.nl\/wp-content\/uploads\/2018\/11\/grafana-memory-1024x569.jpg\" alt=\"\" width=\"1024\" height=\"569\" srcset=\"https:\/\/www.petersplanet.nl\/wp-content\/uploads\/2018\/11\/grafana-memory-1024x569.jpg 1024w, https:\/\/www.petersplanet.nl\/wp-content\/uploads\/2018\/11\/grafana-memory-300x167.jpg 300w, https:\/\/www.petersplanet.nl\/wp-content\/uploads\/2018\/11\/grafana-memory-768x427.jpg 768w, https:\/\/www.petersplanet.nl\/wp-content\/uploads\/2018\/11\/grafana-memory-1140x633.jpg 1140w, https:\/\/www.petersplanet.nl\/wp-content\/uploads\/2018\/11\/grafana-memory.jpg 1433w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><br \/>\nTo get more information you can check the URLs below.<\/p>\n<h3>References:<\/h3>\n<p><a href=\"https:\/\/docs.influxdata.com\/influxdb\/v1.7\/\">https:\/\/docs.influxdata.com\/influxdb\/v1.7\/<\/a><br \/>\n<a href=\"https:\/\/docs.influxdata.com\/telegraf\/v1.8\/\">https:\/\/docs.influxdata.com\/telegraf\/v1.8\/<\/a><br \/>\n<a href=\"http:\/\/docs.grafana.org\/guides\/getting_started\/\">http:\/\/docs.grafana.org\/guides\/getting_started\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In order to gain some knowledge about Grafana, InfluxDB and Telegraf I did a basic installation. Grafana and InfluxDB were installed on a CentOS 7 server. The Telegraf agent was installed on a separate CentOS 7 server (which also hosts petersplanet.nl by the way). Versions: InfluxDB: 1.7.1 Grafana: 5.3.4-1 Telegraf: 1.8.3-1<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-372","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/comments?post=372"}],"version-history":[{"count":23,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/372\/revisions"}],"predecessor-version":[{"id":400,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/posts\/372\/revisions\/400"}],"wp:attachment":[{"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/media?parent=372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/categories?post=372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.petersplanet.nl\/index.php\/wp-json\/wp\/v2\/tags?post=372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}