Jinja2: Check If Variable – Empty | Exists | Defined | True

In Jinja2 templates, it is often a good practice to test if a variable exists and what value does it carry.

There are several useful tests that you can make using Jinja2 builtin tests and filers.

In this article, i’ll show how to test if a variable exists or not, if it is empty or not and if it is set to True.

I’ll also give two examples of how to combine these checks. (more…)

Prometheus Monitoring: Install using Docker – Ubuntu, CentOS

What is Prometheus? Prometheus is an open-source monitoring and alerting software written in Go.

It collects metrics from configured targets and stores them in a local time series database.

Prometheus can run rules over collected data to either aggregate and record new time series from existing data or generate alerts.

To visualize the collected data Prometheus can be integrated with Grafana.

In the following article i will show how to install Prometheus using Docker on Ubuntu and CentOS. (more…)

Install Docker Compose – Ubuntu, CentOS, MacOS

What is Docker Compose? The docker-compose is a tool for defining and running complex multi-container Docker applications.

With docker-compose you can define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.

In this note i’ll show how to install, upgrade or uninstall docker-compose on Ubuntu, CentOS or MacOS using pip. (more…)

Redis: SET/GET Key:Value – Redis-CLI

Redis is a key-value database (also known as a key-value store) that uses a simple key/value method to store data.

Strings are the simplest data type in Redis and are simple key/value entries.

To save or fetch string data there are Redis SET and GET commands.

Redis SET command creates a key and assigns it some value (if the key already exists it just updates the value).

Redis GET command returns a value assigned to a key. (more…)

Redis: Get All Keys – Redis-CLI

There are two ways to get all keys from the all databases in Redis.

The first way is to list keys using --scan option and the second one is to get all keys using the KEYS command.

Note that the first way of getting all keys is preferable as it doesn’t require the client to load all the keys into memory despite of the KEYS command.

Use KEYS command only when the key space is reasonably sized. (more…)