Absolutely Simple Infrastructure Monitoring
Tags: monitoring, observability, infrastructure
Published: 2022-06-21 20:24:46

*(Photo by [sergio  souza]( https://www.pexels.com/photo/lighted-city-at-night-2309579/) )*

Depending on your background, the process of instrumenting your applications, systems, and even your coffee pot makes perfect sense. Requests to "pipe this curl command through BASH" are the kind of thing you do every day.

Or, you know, maybe not.

I hail from a sysadmin and network engineer background. And while I've spent over two decades focusing on installing, configuring, and maintaining monitoring and observability solutions, code-heavy, developer-centric processes still leave me a little in the dark.

It's nice when someone can show me exactly how something works and why it's useful—and then make it dead simple to set up myself. So that's exactly what I'm going to do here. You'll see how to use New Relic to monitor infrastructure like 
 - CPU
 - RAM
 - storage
 - network traffic. 

And then I’ll walk through the steps to install New Relic on a system you control, that’s NOT in production (because we’d NEVER test things in prod, right? RIGHT?) It can be a virtual machine (VM) running locally, a system in the private or public cloud, or even your actual machine sitting under (or on top of) your desk. It can be running on Windows, Linux, MacOS, Docker, or Kubernetes. It doesn’t matter—because you can monitor any of it with New Relic.

##Monitoring your infrastructure with New Relic

First, why would you want to monitor your infrastructure systems with New Relic in the first place? Let’s take a look at some of the key features that are helpful for sysadmins including dashboards and alerts.

After you’ve installed New Relic and instrumented your system, New Relic’s **Hosts** dashboard gives you high-level information about your system’s CPU, RAM, storage, network traffic, and so on. 

![new relic dashboard showing CPU, Memory, storage, and network metrics for a single device](https://newrelic.com/sites/default/files/styles/1200w/public/2022-05/simple-infra-1-5-19-22.webp?itok=4piTOhCc)

You can easily access **Metrics** and **Logs** from the left-hand pane. More on those in a moment. 

Every data point and statistic you see on screen can potentially be used to generate an alert or notification if something goes wrong. That way, you can use automation rather than waiting for a customer to call and ask, “Is the internet down?”

The **Metrics** dashboard has everything from the **Summary** dashboard but more of it, including network inbound and outbound (in bytes and packets) and dropped packets inbound and outbound. That’s alongside more information on CPU, RAM, and disk. 

![New Relic metrics dashboard showing details about CPU, memory, disk, and network usage](https://newrelic.com/sites/default/files/styles/1200w/public/2022-05/simple-infra-2-5-19-22.webp?itok=Ey0jOXkl)

The logs tab, as the name implies, contains log messages.

![New Relic dashboard showing log messages](https://newrelic.com/sites/default/files/styles/1200w/public/2022-05/simple-infra-3-5-19-22.webp?itok=JHcI7Csg)

New Relic’s overall logging capability supports a variety of [inputs and sources](https://docs.newrelic.com/docs/logs/get-started/get-started-log-management/?utm_source=devto&utm_medium=community&utm_campaign=global-fy23-q1-get-started-log-management). While it’s good to know you can instrument “anything,” I think it’s always important to know what the default behavior is going to be. So, here are the logs that will start generating messages in the dashboard right away.

For Linux systems (including MacOS), New Relic will forward all messages appearing in: 
 - /var/log/alternatives.log
 - /var/log/cloud-init.log
 - /var/log/auth.log
 - /var/log/dpkg.log
 - /var/log/syslog
 - /root/.newrelic/newrelic-cli.log

For Windows systems, the New Relic agent will pass along messages from the following locations:
 - Security event log entries with the following event IDs:
  - 4740
  - 4728
  - 4732
  - 4756
  - 4735
  - 4624
  - 4625
  - 4648
 - All events from the Application event log.
 - All messages appearing in newrelic-cli.log in the <home directory>\.newrelic of whichever user ran the infrastructure agent installation in the first place.

You can also access the Events explorer and Metrics explorer from the left-hand pane. If you’re interested in learning more about them, check out [Introduction to the data explorer](https://docs.newrelic.com/docs/query-your-data/explore-query-data/browse-data/introduction-data-explorer/?utm_source=devto&utm_medium=community&utm_campaign=global-fy23-q1-introduction-data-explorer). 

##Setting up New Relic

Now that you have an appreciation for both the ease of navigation and the range of data you’re able to collect and display, you might be wondering how to install New Relic yourself. If the level of difficulty ranges from “connecting my wireless mouse” to “setting up an internet-connected coffee pot,” it’s closer to the mouse side of the scale. You don’t need to compile code, download multiple (possibly conflicting) libraries, or choose between features or modules before you’ve even had a chance to test the system out.

Here’s what you need to get started:
 - An active New Relic account ( [https://newrelic.com/signup](https://newrelic.com/signup?utm_source=devto&utm_medium=community&utm_campaign=global-fy23-q1-new-relic-sign-up) ) 
 - A system you want to instrument.
 - A connection to the system where you can cut and paste commands.
 - A connection from the system to the internet.
 - Optionally, a tool or command to stress test the machine's CPU, RAM, or disk I/O. Stress-ng ( [https://wiki.ubuntu.com/Kernel/Reference/stress-ng](https://wiki.ubuntu.com/Kernel/Reference/stress-ng) ) and Prime95 ( [https://www.mersenne.org/download/](https://www.mersenne.org/download/) ) are two examples of such utilities.

##Installation Steps

1. Log in to your New Relic account. In the left-hand column, select **Add more data**.
![New Relic sidebar with "Add More Data" circled in red](https://newrelic.com/sites/default/files/styles/800w/public/2022-05/simple-infra-4-5-19-22.webp?itok=jIBVjvXd)

2. Choose **Guided install**, which will help you install the main infrastructure agent.
![New Relic add data screen with "Guided Install" circled in red](https://newrelic.com/sites/default/files/styles/1920w/public/2022-05/simple-infra-5-5-19-22.webp?itok=ydsZ43x_)

3. Choose your operating system.
![list of operating systems to install New Relic on](https://newrelic.com/sites/default/files/styles/1920w/public/2022-05/simple-infra-6-5-19-22.webp?itok=mHy-_3Sm)

4. Select **Begin installation**. From the following screen, copy the command and then paste it into the terminal or remote session connected to the system you want to monitor.
![first command needed to install New Relic agent on a device](https://newrelic.com/sites/default/files/styles/1200w/public/2022-05/simple-infra-7-5-19-22.webp?itok=0RnI_akf)

5. After the installation is finished you'll get a link to the New Relic One dashboard in your remote system. Alternatively, you can select **See your data** in New Relic One.
![terminal window showing the New Relic agent install progress, with the New Relic install web page in the background](https://newrelic.com/sites/default/files/styles/1200w/public/2022-05/simple-infra-8-5-19-22.webp?itok=y0o-6hYk)

If any issues come up during the process, the guided install will offer commands, documentation, and suggestions on how to move forward.

##Perturbing the system (but only in test)

There are many utilities that will spike the CPU, fill up RAM, or push the disk I/O to the ceiling, so I'm leaving it to your creativity to choose which one to use.

On my test system, after spiking the CPU for 10 minutes and then letting it cool back down, this is what my dashboard looked like:
![New Relic dashboard showing a CPU and network traffic spike, with a terminal window running stress-ng in the foreground](https://newrelic.com/sites/default/files/styles/1200w/public/2022-05/simple-infra-9-5-19-22.webp?itok=T7sg32iq)

I used the following [stress-ng](https://github.com/ColinIanKing/stress-ng) command for this example:

```
stress-ng --matrix 0 -t 10m
```

Of course, there are many more ways in which a system can break, from single-point-of-failure situations like a disk or RAM to the complex multi-element cascades that you’re more likely to see in real life. There are other [stress-ng commands](https://wiki.ubuntu.com/Kernel/Reference/stress-ng) you can use to stress CPU, RAM, disk I/O, and other subsystems.

Honestly, I had so much fun using stress-ng to play “will it crash” with my system that I’m planning another blog post where I beat up a system and show you what it looks like in New Relic.

Do you want to play with infrastructure monitoring in a risk-free environment (i.e.: “not your stuff”)? This lab uses ephemeral machines and walks you through a more real-world scenario: “[Identify root cause issues in your infrastructure](https://developer.newrelic.com/collect-data/infra/?utm_source=devto&utm_medium=community&utm_campaign=global-fy23-q1-collect-data-infra).” Or maybe you’re ready to dive in! In that case, [sign up here](https://newrelic.com/signup?utm_source=devto&utm_medium=community&utm_campaign=global-fy23-q1-new-relic-sign-up) for a free account that comes with 100GB of data, free for life.