
Installing Telegraf + InfluxDB + Chronograf + Grafana
It's time to give Telegraf a little, I have a few posts pending that I think may be interesting, so if you think it's okay, Today we will see how to assemble the base, InfluxDB to store metrics, Chronograf as your native viewer; and, How could you not, Grafana, 'Cause we all know it's the best metrics visualizer and we'll do magic.
What I said, We will use this document as the initial basis for some posts that we will publish on the blog to exploit our monitoring system. The TICK stack (Telegraf, InfluxDB, Chronograf and Kapacitor) It can come in handy to embrace and extend our monitoring environment, personally for the visualization of certain metrics in real time, and for this purpose the Telegraf agent will collect the data that interests us, it will store them in our InfluxDB and we will be able to view them in Chronograf. Although what has been said, personally I am much more of a fan of Grafana for all its elasticity, but Chronograf can come in handy to learn the Flux language. Since that's good, InfluxDB 1.x used InfluxQL as the query language and since version 2.x Flux has been used, And some of us have a hard time changing 🙂
With Telegraf we will be able to collect metrics from the computer where we install the agent or also from remote computers where it cannot be installed, For example, on a switch, and we consult these types of machines through SNMP. The final idea is to have Grafana dashboards that show us the data we collect, And I insist, For me, the strong point is being able to have data with intervals of 1 second.
Installing InfluxDB
InfluxDB is a TSDB dataseries database (Time Series Database), Open Source, much more efficient at storing and processing this type of data. At the time of publishing the post we had the version 2.1, with the following commands, download the InfluxDB repository and install InfluxDB, in addition to lifting the service and verifying its status (ah, This post is based on an Ubuntu 20.04):
wget -qO- https://repos.influxdata.com/influxdb.key | GPG --Dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null export DISTRIB_ID=$(lsb_release -yes); export DISTRIB_CODENAME=$(lsb_release -sc) ECHO "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list > /dev/null sudo apt-get update && Sudo apt-get install influxdb2 sudo systemctl start influxdb sudo systemctl status influxdb sudo systemctl enable influxdb
Next, we'll install Influx CLI, to later minimally configure InfluxDB and good, as a command-line CLI client for management if needed.
wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-2.2.0-linux-amd64.tar.gz tar xvzf influxdb2-client-2.2.0-linux-amd64.tar.gz sudo cp influxdb2-client-2.2.0-linux-amd64/influx /usr/local/bin/ rm -rf influxdb2-client-2.2.0-linux-amd64/
Vamos a configurar InfluxDB con influx CLI, con ‘sudo influx setup’ crearemos el usuario, contraseña, primera organización, y primer bucket para almacenar, la retención de datos para este bucket, y confirmamos:
sudo influx setup > Welcome to InfluxDB 2.0! ? Please type your primary username influx_user ? Please type your password ************** ? Please type your password again ************** ? Please type your primary organization name Open Services IT ? Please type your primary bucket name Monitor ? Please type your retention period in hours, or 0 for infinite 0 ? Setup with these parameters? Username: influx_user Organization: Open Services IT Bucket: Monitor Retention Period: Infinite (y/N) and
Well, A couple of notes now, to check our organization and its ID, Run:
sudo influx org list ID Name x4473x3a36x4d008 Open Services IT
And if we want to list our Token:
sudo influx auth list
ID Description Token User Name User ID Permissions 08xx775x1706000 influx_user's Token Ts...Q== influx_user 08xx1253x3060 [read:/authorizes...
Installing Chronograf
To install Chronograf, the InfluxDB Visualizer, We'll do it that fast:
wget https://dl.influxdata.com/chronograf/releases/chronograf_1.9.1_amd64.deb sudo dpkg -i chronograf_1.9.1_amd64.deb sudo systemctl status chronograf sudo systemctl enable chronograf
We start the setup wizard, Click on “Get Started”,
And we fill in the following data:
- Connection URL: InfluxDB IP or hostname and port (Default 8086), It could be HTTP://127.0.0.1:8086 if it's the same machine.
- Connection Name: We give the connection a name.
- Organization: We indicate the name of the InfluxDB organization.
- Token: Paste the Access Token.
- Telegraf Database Name: Optional, if we want another BD name, By default it will be called 'Telegraf'.
Click on “Add Connection” and we finish the connection wizard.
Installing Telegraf
Well, obviously it will depend on the OS where we have to install Telegraf, since we can install it on Windows, Mac, Ubuntu, Centos, RedHat, Debian, Containers… So if you need, Check out their Official Website. This example would be for Ubuntu/Debian systems:
wget -qO- https://repos.influxdata.com/influxdb.key | sudo tee /etc/apt/trusted.gpg.d/influxdb.asc >/dev/null source /etc/os-release echo "Deb https://repos.influxdata.com/${ID} ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list sudo apt-get update sudo apt-get install -y telegraf
The Telegraf configuration file will be in '/etc/telegraf/telegraf.conf’ and if we edit it we will have infinite possibilities of obtaining data, Home Team (or from another remote if necessary). And this is what we will see in future posts, So what I leave you here will be the common configuration, which will be telling Telegraf to send the data to our InfluxDB, So the output settings would be at least as follows:
... [[outputs.influxdb_v2]] URLs = ["HTTP://DIRECCION_IP_INFLUXDB:8086"] # required organization = "Open Services IT" bucket = "Monitor" token = "T... Q==" ...
And nothing, Started, enable and view the Telegraf service status with:
Sudo systemctl enable telegraf sudo systemctl restart telegraf sudo systemctl status telegraf
And if we go back to our Chronograf, and explore our bucket metrics, we will be able to start visualizing that this already collects data!
Installing Grafana
And well, Come finishing, it's gerund… if we want, on the same machine we can mount Grafana, and create a connector against InfluxDB to well that, visualise, Processing data and making magic, Viewing the data on maps, stalemate, Cheeses, Bar Graphs. lines…
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 - ECHO "Deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list sudo apt-get update sudo apt-get install -y grafana
And nothing, Started, enable and view the Grafana service status with:
Sudo systemctl start grafana-server sudo systemctl status grafana-server sudo systemctl enable grafana-server
If we access http with a browser://DIRECCION_IP_GRAFANA:3000 We will validate with the default admin username and admin password, that we should please change as we log in.
The next thing will be that, create a connector against InfluxDB to visualize the data that we store there in the future, We're going to “Configuration” > “Data sources” > “Add data source”.
View the listing, it's awesome where we can visualize data from… imagine the internal databases that you have in the company… Come on, I'm messed up, we search for InfluxDB and select it.
And we created the connector, Indicating:
- Name: Connection Name.
- Query Language: Flux
- URL: HTTP://DIRECCION_IP_INFLUXDB:8086
- Organization: The name of the InfluxDB organization
- Token: Paste the Access Token.
- Default bucket: We indicate the bucket we will use.
And we click on “Save & Test”, If we have followed all the steps well, This will connect!
And if we create a new Dashboard, we create a new Panel, we indicate for example a Time Series, that is, The typical line display. And we put the Flux consultation, We will be able to see the data! Now it's time to play with the display options, Other Panel Type… and of course, Start feeding this! If we don't know Flux, the easiest thing will be to copy the queries from Chronograf. Or… directly import Dashboards into Grafana from people who have already worked 🙂 on them And we will see many examples, You'll see how cool it is…
I would tell you many things, But it's too late, It's a long post and we're going to see in future posts many ideas that will surely catch your attention. If you are bored take a look at stuff that can be added to Grafana…
What I said, Thank you very much if you have come this far, Thank you for sharing on social media, for the likes and stuff, that you have to 🙂 be grateful
¡Successes!