Navigating InfluxDB CLI

I’ve demonstrated a few InfluxDB commands in my Getting to know InfluxDB and InfluxDB: Retention Policies & Shard Groups posts but though it would be a good idea to write a post completely dedicated to useful CLI commands – so here it is.

SHOW DATABASES

This command is self explanatory. It lists all of your InfluxDB databases:

USE <DATBASE_NAME>

Enters a database so that subsequent commands will be run against it:

Continue reading

InfluxDB: Retention Policies & Shard Groups

Note: This is a continuation of the Getting to know InfluxDB post. If you haven’t read it yet, I suggest you do before reading this post.

I found InfluxDB’s documentation around Retention Policies (RP) and Shard Groups quite unclear in parts and am therefore writing this post to assist others who find themselves feeling the same way.

What is a Retention Policy?

As the documentation says:

The part of InfluxDB’s data structure that describes for how long InfluxDB keeps data (duration), how many copies of those data are stored in the cluster (replication factor), and the time range covered by shard groups (shard group duration). RPs are unique per database and along with the measurement and tag set define a series.

When you create a database, InfluxDB automatically creates a retention policy called autogen with an infinite duration, a replication factor set to one, and a shard group duration set to seven days. See Database Management for retention policy management.

Continue reading

Getting to know InfluxDB

I touched on InfluxDB in the My Monitoring Journey: Cacti, Graphite, Grafana & Chronograf post and then covered its installation and setup in the Installing & Setting up InfluxDB, Telegraf & Grafana post. Now it’s time to look at how the database actually works and commands we can use to integrate it.

InfluxDB Structure

In the latter mentioned post above we saw that Telegraf had created a telegraf  database in InfluxDB. Let’s now jump into InfluxDB and take a look at this database:

To view a list of all of the databases, issue the following show databases  command:

Continue reading

Installing & Setting up InfluxDB, Telegraf & Grafana

I mentioned these tools in the My Monitoring Journey: Cacti, Graphite, Grafana & Chronograf post and thought now would be a good time to cover their installation and setup. Let’s get started.

Installing InfluxDB & Telegraf

Instructions on how to install all of the TICK stack components can be found here. As I’m running Ubuntu, I’ll need to run these commands:

wget https://dl.influxdata.com/influxdb/releases/influxdb_1.2.4_amd64.deb
sudo dpkg -i influxdb_1.2.4_amd64.deb
wget https://dl.influxdata.com/telegraf/releases/telegraf_1.3.1-1_amd64.deb
sudo dpkg -i telegraf_1.3.1-1_amd64.deb

Note that after running the last command, the Telegraf service automatically starts:

will@ubuntu:/tmp$ sudo dpkg -i telegraf_1.3.1-1_amd64.deb
Selecting previously unselected package telegraf.
(Reading database ... 177117 files and directories currently installed.)
Preparing to unpack telegraf_1.3.1-1_amd64.deb ...
Unpacking telegraf (1.3.1-1) ...
Setting up telegraf (1.3.1-1) ...
Created symlink from /etc/systemd/system/multi-user.target.wants/telegraf.service to /lib/systemd/system/telegraf.service.

Continue reading

Looping through Dictionaries in Ansible

Note that this post uses NTC-Ansible. Installation instructions can be found here.

In the Understanding Ansible Output Structure post we saw how to extract a single entry out of a dictionary. We saw that it’s possible to do it using the map() filter too. However, what if we want to extract all entries in the dictionary, how would we go about that? The answer is simple – use with_dict . For example, this Playbook:

Continue reading

Understanding Ansible Output Structure

Note that this post uses NTC-Ansible. Installation instructions can be found here.

In the Ansible –extra-vars post we saw just how out of control outputs can be. The Cleaning Up Ansible Loop Outputs post then demonstrated how we can remove all of the unnecessary information.

This post is aimed at answering the question, “How do we navigate through the output in order to extract the information we need?”. For example, how would we extract the management_ip information from the output below (which was generated as a result of running this Playbook):

Continue reading

Cleaning Up Ansible Loop Outputs

Note that this post uses NTC-Ansible. Installation instructions can be found here.

As we saw in the –extra-vars post, the first Playbook produces a very clean, succinct output. However, after making a minor alteration to the Playbook (I added a single loop and one additional show command), the output went from just 43 lines to over 260 lines!

While there is nothing functionally wrong with the way that Ansible displays its loop output, it is distracting and difficult to find the information you’re looking for. We can resolve this “issue” by using the default()  Jinja2 template, like so:

Continue reading

Ansible –extra-vars

Note that this post uses NTC-Ansible. Installation instructions can be found here.

Often you will see variables defined in a Playbook, a Task and/or a variables file such as group_vars or host_vars, as shown below:

Continue reading