Baking Clouds Ltd

Baking Clouds provide tailored IT consultancy services to small and medium-sized companies; we cover all aspects of IT without any hidden costs.

Use Grafana to display vCloud Director stats

If in your environment vRealize Operations is not available, and you want customers to be able to see vCloud Director summary dashboards, or your are having problems with Tenant App for vCD the following post is the right for you!
The original idea comes from Blog “Mycloudrevolution.com”, but we changed it a little bit to make it work in our environment.

List of requirements:

  • Linux machine (we used Ubuntu 18.04.4 LTS)
  • InfluxDB as datasource for Grafana (InfluDB version v1.8.0)
  • Telgraf as collector agent (Telegraf 1.14.5)
  • vCloud Director Organization User Account

Collection Flow

InfluxDB

There are multiple ways to install InfluxDB on Ubuntu. However, the following steps worked for us.

Run the commands below to add its repository key to Ubuntu

sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add 

After adding the key, run the commands below to create a repository file

sudo echo "deb https://repos.influxdata.com/ubuntu bionic stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

After adding the key, run the commands below to create a repository file

sudo echo "deb https://repos.influxdata.com/ubuntu bionic stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

When you’re done adding the repository key and file, run the commands below to update Ubuntu packages index and install InfluxDB

sudo apt update
sudo apt install influxdb

After installing, the commands below can be used to stop, start and enable InfluxDB services to automatically start up when the server boots.

sudo systemctl stop influxdb
sudo systemctl start influxdb
sudo systemctl enable --now influxdb
sudo systemctl is-enabled influxdb

To check and validate that InfluxDB is installed and running, run the status command below:

sudo systemctl status influxdb

Create Influxdb User and Database

Start influx shell first

CREATE USER admin WITH PASSWORD 'Yourpassword' WITH ALL PRIVILEGES  
CREATE DATABASE telegraf 
Exit

Note: To validate Telegraf database was successfully created run “show databases”

Configure connection:

Connection details need to be configured in influxdb.conf : sudo vi /etc/influxdb/influxdb.conf

[http]   
enabled = true 
bind-address = ":8086" 
auth-enabled = true

Restart the service:

sudo systemctl restart influxdb

Telegraf

Install Telegraf and prerequirements:

sudo apt-get install telegraf snmp snmp-mibs-downloader

Use all installed MIBs:

You need to modify the snmp.conf: sudo vi /etc/snmp/snmp.conf

Configure output:

The output setting in telegraf.conf must match the InfluxDB configuration: sudo vi /etc/telegraf/telegraf.conf

[[outputs.influxdb]]
  urls = ["http://127.0.0.1:8086"] # required
  database = "telegraf" # required
  retention_policy = ""
  write_consistency = "any"
  timeout = "5s"
  username = "admin"
  password = "<YourPassword>"

Grafana

Download the Grafana GPG key with wget, then pipe the output to apt-key. This will add the key to your APT installation’s list of trusted keys, which will allow you to download and verify the GPG-signed Grafana package.

wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

Next, add the Grafana repository to your APT sources:

sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"

Refresh your APT cache to update your package lists:

sudo apt update

Next, make sure Grafana will be installed from the Grafana repository:

apt-cache policy grafana

You can now proceed with the installation:

sudo apt install grafana

Once Grafana is installed, use systemctl to start the Grafana server:

sudo systemctl start grafana-server

Next, verify that Grafana is running by checking the service’s status:

sudo systemctl status grafana-server

You will receive output similar to this:

You are now able to access the Grafana site via http://<Yout IP>:3000 and configure the InfluxDB data source

Note: Grafana default user/password is admin/admin. You will be asked to change the password the first time you login

Add the data source

  1. Open the side menu by clicking the Grafana icon in the top header.
  2. In the side menu under the Dashboards link you should find a link named Data Sources.
  3. Click the + Add data source button in the top header.
  4. Search InfluxDB

Powershell

Installation via Package Repository – Ubuntu 18.04 (how to install powershell on other linux distributions please refer to this MS Website)

PowerShell for Linux is published to package repositories for easy installation and updates.
The preferred method is as follows:

Download the Microsoft repository GPG keys

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

Register the Microsoft repository GPG keys

sudo dpkg -i packages-microsoft-prod.deb

Update the list of products

sudo apt-get update

Enable the “universe” repositories

sudo add-apt-repository universe

Install PowerShell

sudo apt-get install -y powershell

Configuration of the Grafana Dashboard for vCloud Director

Telegraf

Append a new section to the telegraf.conf : sudo vi /etc/telegraf/telegraf.conf

[[inputs.exec]]
  commands = ["pwsh /scripts/Grafana-Telegraf-vCloud-PsCore/vCloud.ps1"]
  name_override = "vCloudStats"
  interval = "60s"
  timeout = "60s"
  data_format = "influx"
PowerShell Script

To run the Script a json file for the configuration is needed in addition. Both files (config only as example) are available in GitHub Repository Grafana-Telegraf-vCloud-PsCore. Use git clone https://github.com/bakingclouds/Grafana-Telegraf-vCloud-PsCore/tree/bakingclouds-patch-1 and for updates git pull

The json configuration contains the FQDN of the vCloud Director instance and the Base64 Hash of Username and Password.

{
    "Base": {
            "VcdHost": "<FQDN>",
            "BasicAuth": "<Base64>"
        }
    }

The un-hashed username format needs to be: <User>@<Org>

You have the option to import a pre-configured Grafana dashboards or create your own dashboards using the vCloud stats.

How to import the dashboard?

1.     Go to https://grafana.com/grafana/dashboards/5081/revisions and download the latest version.

2.     Open Grafana and do to “Manage Dashboards”

3.     Select “Import” and upload the json file downloaded in step 1

4.     Dashboards will appear after uploading the json file

To validate your script and telegraf are working fine, run the following Test:

sudo telegraf -test -config-directory /etc/telegraf/telegraf.d/ -input-filter=exec -debug

If the test is successful data will show up in the dashboard

We hope you enjoyed this post! If you need additional information, please send us your comment clicking the below button.

Use Grafana to display vCloud Director stats
Scroll to top