MattLestock.com

Thoughts from your friendly neighborhood technologist.

Category: Misc Thoughts (page 1 of 2)

Installing & Configuring Grafana with InfluxDB – Part 1

What’s all this about?

Having a home lab is great as I’m sure most of you are aware.  But when you want to start running things that are more or less “production”, often we have the need to start tracking historical data.  During my quest to begin graphing statistics associated with my homelab I started my journey first by looking at some of the more popular options for infrastructure visualization by exploring options like the 100 monitor license for PRTG, and LibreNMS.

While these would work in a majority of lab scenarios, I operate a few things that required a custom graphing and data collection solution.

You see I run a few community game-servers, mumble server, share a plex system with friends and family, and also all of the automation components that go along with it (CouchPotato, Sonarr, NZBGet, qBittorrent). While PRTG and LibreNMS are great for SNMP polling and logging, the type of systems I’m looking to monitor don’t have SNMP on them, thus it was time to explore other options.

For reference, here’s a look at what I’m running for my always on services.

IMG_0489

The hardware you see there is as follows.

Other components that make up the total solution.

Enough Hardware, what about the Software!?

Now that we’ve got the hardware out of the way, what about the software? Well originally I had planned on using Graphite, which includes Carbon, Whisper and the Web Frontend. However, it’s a fairly long pain in the ass process to setup so I opted for an alternative running Grafana and InfluxDB.

Unlike a traditional relational database, InfluxDB is a TSDB or Time Series Database. In our example here we’re using InfluxDB to store 3 things, the Measurement Name, the Measurement Value, and the Time which that measurement happened.  Let’s have a look at an example.

homelab.servers.nanoserver.cpu.0.processortime, 8, 1454794445

Simple right? The first value is that of our Measurement Name, which can be anything we want.  There’s no need to prepopulate the database with these measurement names, as anything fed into InfluxDB with the correct structure will create the measurement name and associate a measurement with it.  Bitchin’ I know!  The second value is the actual measurement itself, in this case 8% utilization of CPU core 0.  The third and final value is the time this measurement was taken in UNIX time.

Once we’ve got data in an InfluxDB, we need a way to easily digest it.  This is where Grafana comes in. Luckally Grafana (as of 2.1.0) has support for InfluxDB 0.8 and InfluxDB 0.9 out of the box. Note: There are two profiles because the query language changed between InfluxDB 0.8 and 0.9.

Now that we’ve gotten the what out of the way, it’s time to dive into the how. Or put more simply, how are we going to actually measure datapoints and get them into InfluxDB for Grafana to ya know, graph?

In my case my “Nanoserver” is running Windows 7 on the bare metal, and a few virtual machines under VMware Workstation 12. One of those machines is my general purpose Ubuntu 14 box that I run utilities on which don’t have native Windows support.  This is where we’ll be installing InfluxDB, Grafana, an NMP stack (Nginx, MariaDB, Php).  Now I mentioned previously that the Nanoserver is running Windows which I certainly want to retrieve and report performance statistics from, but I couldn’t find a script that would easily allow me to get performance data out of Windows and into InfluxDB.  However I did find Matt Hodge’s excellent powershell script for getting performance data from windows and inserting it into Graphite. “BUT MATT! I thought you said we were working with InfluxDB?!”  And you’re right, it turns out one of the great things about InfluxDB is that it has a Carbon Protocol Listener that while disabled by default, is easily activated with a config change, and allows us to receive data originally meant for a Graphite, Carbon, Whisper stack!

Alright I get it, InfluxDB and Grafana are awesome, but how do we set them up?

Ok ok.  I promised you that this would be a how to and if you’ve made it this far, it’s time to actually show you how we’re going to accomplish this stuff.  Ready? Here we go.

First we’ll start with the fact that this tutorial is based on the notion that we’re installing these components on Ubuntu 14, so that’s our first prerequisite.

Time to Install InfluxDB

Now lets go ahead and create an admin user.

Head to a web browser and enter the IP of your InfluxDB Server followed by port 8083 (http://INFLUXDB_IP:8083), then in the query textbox enter the following command.

Now we need to edit the InfluxDB config file to enable user authentication.

First we’ll enable authentication for InfluxDB by setting “auth-enabled = true” under [http] from it’s default of false.
Now let’s enable the Graphite protocol listener by setting “enabled = true” under the [[graphite]] config section from it’s default of false.

Note : InfluxDB by default does not require user authentication and is happy to allow anyone to just write measurement data to it, however the Grafana Data Source interface requires user credentials, so that’s why we enabled basic user authentication for the Graphite database.

Restart InfluxDB

Now Let’s Install Grafana

Visit your newly installed Grafana instance at http://IPADDRESS:3000
the default username and password is admin / admin

Time to add the InfluxDB Data Source

Click on the Data Sources link on the left menu, and then select add new from the top menu.
Give your Data Source a name, in this case we’re going with InfluxDB Graphite
Select InfluxDB 0.9.x (even if version 0.10.x was installed) as your Data Source Type, and optionally select the Default checkbox to have this Data Source selected each time you want to add a new panel.
In the Http settings section enter your InfluxDB IP address followed by port 8086, (In this case because InfluxDB and Grafana are located on the same server go ahead and enter http://localhost:8086), your access mode should be proxy.
Now in the InfluxDB Details section we’ll enter our database (graphite) followed by our username and password (graphite / graphite)
Click Add and then click Test Connection, you should get a green box with “Success: Data source is working”

grafana_data_source
That’s it! Simple right?

You deserve a medal if you’ve made it this far, but in the next post we’ll actually show you how to get data into InfluxDB from various different sources, and then the all important step of actually graphing it! So stay tuned!

Crap… where does the time go?

As you can see I haven’t really been very thorough in making some updates to the site, and I’m getting the urge to get back into the  swing of things.  

Since I’ve been gone, I’ve gone through a couple of different jobs in the Hampton Roads area, primarily because each position I accepted pretty much had me sitting at a desk waiting for something to do.  Which is exactly the opposite of what I told them I wanted to be doing. That being said I’ve found a position with a great new company in central Virginia as a VMware Solutions Architect.  Getting to meet new customers and help them along their journey to a more streamlined and automated infrastructure environment is what I love to do.

I’m going to start posting regularly here on what I’m seeing customers struggling with in addition to some VMware product updates and how-to’s.

In addition to the new activity going on here, make sure you check out all of the new websites that we’ve got up and running at The New Tech.

If you have any suggestions for content here, please don’t hesitate to shoot me an email.  See you guys soon!

 

VMware ESXi NTP Time Servers

Just a little reminder to those of you who are setting up ESXi servers.

REMEMBER TO SETUP TIME SYNCING!

Easiest way to do this is if your ESXi hosts can get to the internet, goto your host configuration tab, select time and date, then enter the following addresses for the NTP servers.

0.vmware.pool.ntp.org
1.vmware.pool.ntp.org
2.vmware.pool.ntp.org

Or any standard time server should do, but those are easiest for me to remember.

I’ll post on how to use Windows as a time server for hosts that don’t have internet access in a later article, that one’s going to require some screen shots.

ESX/i 4.1 – Welcome back PVSCSI Driver!

As I keep digging into documents and KB articles I keep finding more and more things to like about vSphere 4.1. Today’s find has to do with the PVSCSI driver.

With the release of vSphere 4.0, VMware added a new paravirtualized SCSI driver into the VMware Tools that provides better virtual disk performance than the standard LSI driver. The PVSCSI driver promised to deliver better performance and lower overall CPU utilization for workloads that had high I/O demands. Unfortunately the PVSCSI driver wasn’t supported on virtual machine boot volumes, so folks held off on making this the default SCSI driver for all virtual machines.

After vSphere 4 Update 1 was released, VMware lifted the restriction and now supported the PVSCSI driver on boot volumes. Folks began considering adopting the PVSCSI driver in all virtual machines similar to how the VMXNET driver is a standard for nearly all virtual NICs. Soon afterwards VMware came out with a knowledgebase article stating that virtual machines that did not have heavy I/O demands could actually experience worse performance using the PVSCSI driver. YIKES!!! They recommended only using the driver for workloads that had I/O demands in excess of 2,000 IOPS.

With the release of vSphere 4.1 that is no longer a problem and you can use the PVSCSI driver in all circumstances.
Want details? Read on!

Continue reading

How to use a Western Digital MyBook on Windows 2003 Server

How to use a Western Digital “My Book” drive (Home Edition, but I don’t think that matters) in Windows 2003 Server:

  1. Follow instructions for normal connection using USB, then:
  2. Start -> My Computer -> (right-click) Manage Open Storage -> Disk Management  External drive will appear in list of partitions, but it will be inactive and will not have a drive letter assigned.
  3. Right-click on the partition, select Mark Partition as Active
  4. Right-click on the partition again,
  5. select Change Drive Letter and Paths,
  6. click Add.  Assign a drive letter.
  7. The drive should now be accessible.

This procedure should only be necessary the first time the drive is plugged in.

Older posts

© 2016 MattLestock.com

Theme by Anders NorenUp ↑