Skip to content

Commit

Permalink
[WIP] New Relic I/O lab
Browse files Browse the repository at this point in the history
  • Loading branch information
mehreentahir16 committed Sep 20, 2021
1 parent c655638 commit c33d451
Show file tree
Hide file tree
Showing 40 changed files with 1,325 additions and 1,861 deletions.
16 changes: 16 additions & 0 deletions src/data/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@
url: '/build-apps/ab-test/subscribe'
- title: See all open source apps
url: https://opensource.newrelic.com/nerdpacks/

- title: Instant observability
icon: nr-build-apps
url: '/instant-observability'
pages:
- title: Build a quickstart
url: '/instant-observability/build-a-quickstart'
pages:
- title: Send data to New Relic
url: /instant-observability/build-a-quickstart/send-data-to-newrelic
- title: Create dashboard in New Relic One
url: /instant-observability/build-a-quickstart/create-dashboard
- title: Create alerts
url: /instant-observability/build-a-quickstart/create-alerts
- title: Add related documentation
url: /instant-observability/build-a-quickstart/add-documentation
- title: Try our APIs
icon: nr-share
url: '/try-our-apis'
Expand Down
Binary file added src/images/instant-observability/add-a-chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/instant-observability/alerts-main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/instant-observability/cache-hits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/instant-observability/dashboard2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/instant-observability/errors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/instant-observability/fdb-methods.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/instant-observability/keys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/instant-observability/lab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/instant-observability/more-charts.png
Binary file added src/images/instant-observability/piechart.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
path: '/instant-observability/build-a-quickstart/add-documentation'
title: 'Add related documentation'
template: 'GuideTemplate'
description: 'Add related documentation to the quickstart that explains its purpose'
duration: '5 min'
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
path: '/instant-observability/build-a-quickstart/create-alerts'
title: 'Create Alerts'
template: 'GuideTemplate'
description: 'create alerts in New Relic One'
duration: '15 min'
---

New Relic alerts allow you to create robust and customizable alert policies for anything that you want to monitor.
When you set up alert conditions, you can get notified about the problems that you're interested in and you can troubleshoot and resolve problems faster.

<Callout variant='important'>

This lesson is a part of a lab that teaches you to build quickstart. Before you proceed with the lesson, make sure your demo services are up and running.
It is assumed that you are already familiar with alerts basics. If you're just getting started then visit the [alert documentation](https://docs.newrelic.com/docs/alerts-applied-intelligence/) to familiarize yourself with the basics before proceeding.

</Callout>

### Create alert policy

Before you could set alert conditions, you must create a policy. For example, you want to get an alert whenever your database takes longer to respond. You can create a policy for high response rate.
Move to _Policies_ under Alerts section of Alert & AI and click **New alert policy**.

![alert](../../../images/instant-observability/alerts-main.png)

Give a meaningful name to your policy such as **FlashDB alert policy**. Use the default values for the rest of the fields and click **Create alert policy**.

![alert policy](../../../images/instant-observability/create-alert-policy.png)

The next step is to add alert conditions to the alert policy. Click **Create a condition**.

![alert condition](../../../images/instant-observability/create-alert-condition.png)

On the next page, choose the category for which you want to define the alert condition. NRQL category allow you to create alert conditions using NRQL queries. Choose this option and click **Next, define thresholds**.

![alert condition nrql](../../../images/instant-observability/create-alert-condition-nrql.png)

Enter a meaningful name for your alert condition. For example, you want to get notified if the read operation is taking longer than expected then you can create an alert condition _slow read responses_ and enter the following NRQL query for your condition.

>```bash
> SELECT average(fdb_read_responses) FROM Metric
>```
![slow read response nrql](../../../images/instant-observability/slow-read-response-nrql.png)
Here, you just selected the average read response for FlashDB. Scroll down on the same page to define threshold. Select **Static** as the threshold type. It is the simplest threshold type and creates a condition based on the numeric value returned by the query.
Now, set the critical threshold value at 0.9 as follow:
![slow read response critical threshold](../../../images/instant-observability/critical-threshold.png)
Here, you define the alert condition that will open violation whenever read response time is above 0.9 for at least 5 minutes. You can also add a warning threshold by clicking **Add warning threshold**.
![add warning threshold](../../../images/instant-observability/add-warning-threshold.png)
Now, specify a threshold value for warning. Say, you want the alert condition to warn you when the read response is above 0.8 for at least 5 minutes. Enter the threshold value as 0.8 and click **Save condition**.
![slow read response warning threshold](../../../images/instant-observability/warning-threshold.png)
You can see your alert consition under your FlashDB alert policy now.
![flashdb slow response alert](../../../images/instant-observability/flashdb-alert-slow-response.png)
Since you claimed that your database is fastest in the space, you also want to observe cache hit ratio and get a notification if it is low. You can add another alert condition under the same policy by clicking **Add a condition**.
![add more alert conditions](../../../images/instant-observability/add-more-alert-conditions.png)
You are familiar with the next page where you choose the category for your alert condition. Choose NRQL and click **Next, define threshold**.
![add more alert conditions nrql](../../../images/instant-observability/add-more-alert-conditions-nrql.png)
Enter the name _low cache hit ratio_ for your conditiona and the following NRQL query.
>```bash
> SELECT sum(fdb_cache_hits)/sum(fdb_read_responses) FROM Metric
>```
![low cache hit ratio nrql](../../../images/instant-observability/low-cache-hit-ratio-nrql.png)
The next step is adding threshold values for critical violation as well as warning. The procedure is same as we did before. The only difference is that we want to get warning notification if the query returns a value _below_ 0.85 and a critical violation notification is the value falls _below_ 0.75 for at least 5 minutes.
![low cache hit ratio threshold](../../../images/instant-observability/low-cache-hit-ratio-threshold.png)
Save condition to add it to previoulsy defined FlashDB alert policy. Your policy will look something like the following.
![alert policy conditions](../../../images/instant-observability/alert-conditions.png)
<Callout variant='important'>
This lesson is a part of lab that teaches you to build a quickstart. Continue on to next lesson: [_Add related documentation_](/instant-observability/build-a-quickstart/add-documentation)
</Callout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
path: '/instant-observability/build-a-quickstart/create-dashboard'
title: 'Create dashboard in New Relic One'
template: 'GuideTemplate'
description: 'create dashboard to observe your data in New Relic'
duration: '15 min'
---


New Relic One dashboards allow you to quickly observe and make meaning of the information that you collect. You can gather and chart the specific data you want to see and customize it the way you want to see.

Throughout this lesson, you're going to create different charts in New Relic One dashboard to get insights from database transactions.

<Callout variant='important'>

This lesson is a part of lab that teaches you to build quickstart. Before you proceed with this lesson, make sure you have your demo services up and running.

</Callout>

You're going to create dashboard in New Relic One. Navigate to https://one.newrelic.com/ and sign in with your account. Here, you can see different tabs such as *Browse Data*, *Dashboards*, *Alerts & AI* etc.
Move to *Dashboards* and click **Create a dashboard** in the top right corner.

![create dashboard](../../../images/instant-observability/create-dashboard.png)

Name your dashboard and click create.

![name your dashboard](../../../images/instant-observability/name-dashboard.png)

## Add charts to your dashboard

Once the dashboard is in place, you can start creating charts. Hover over the dashboard and click **Add a new chart** where you want to add the chart.

![add new chart](../../../images/instant-observability/add-new-chart.png)

New Relic One allow you to add chart using query builder as well as text, images or links using Markdown. Click **Add a chart**.

![add chart](../../../images/instant-observability/add-a-chart.png)

It will take you to a query builder option. Edit the query as follow:

>```bash
>SELECT count(*) FROM fdb_method FACET method
>```
![database methods](../../../images/instant-observability/fdb-methods.png)
Here, you group your results of fdb_method by attribute values. You can choose to present your results in different formats such as table, billboard, pie chart etc.
![chart formats](../../../images/instant-observability/chart-formats.png)
Change the chart type to pie, name your chart and click save.
![pie chart](../../../images/instant-observability/piechart.png)
The chart is now visible on your dashboard.
![dashboard](../../../images/instant-observability/piechart-dashboard.png)
You can add more charts to your dashboard following the same pattern. To add more charts to your dashboard, click **+** in upper right hand corner.
![add more charts](../../../images/instant-observability/add-more-charts.png)
![more charts](../../../images/instant-observability/more-charts.png)
#### Average response time
Run the following query to observe the **average response time** of database transactions.
>```bash
> SELECT average(fdb_create_responses), average(fdb_read_responses), average(fdb_update_responses), average(fdb_delete_responses) FROM Metric SINCE 30 MINUTES AGO TIMESERIES
>```
![average response time](../../../images/instant-observability/average-response-time.png )
>**Note:** Make sure to click **Run** for the results to be visible.
Click save to add this chart to your dashboard as well. Your dashboard will look similar to the following:
![dashboard with charts](../../../images/instant-observability/dashboard2.png )
Add few more charts to your dashboard as follow:
#### Errors
>```bash
> SELECT sum(fdb_create_errors), sum(fdb_read_errors), sum(fdb_update_errors), sum(fdb_delete_errors) FROM Metric SINCE 60 MINUTES AGO TIMESERIES
>```
Here, you observe total errors for all database transactions for past one hour.
![errors](../../../images/instant-observability/errors.png )
#### Database size
>```bash
> SELECT sum(mdb_size) FROM Metric
>```
![database size](../../../images/instant-observability/database-size.png )
#### Cache hits
>```bash
> SELECT sum(fdb_cache_hits) FROM Metric SINCE 30 MINUTES AGO TIMESERIES
>```
![cache hits](../../../images/instant-observability/cache-hits.png )
#### Keys
>```bash
> SELECT count(fdb_keys) FROM Metric SINCE 5 MINUTES AGO TIMESERIES
>```
![keys](../../../images/instant-observability/keys.png )
Your final dashboard will look similar to the following:
![dashboard final](../../../images/instant-observability/dashboard-final.png )
<Callout variant='important'>
This lesson is a part of lab that teaches you to build quickstart. Continue on to next lesson: [_Create New Relic Alerts_](/instant-observability/build-a-quickstart/create-alerts).
</Callout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
path: '/instant-observability/build-a-quickstart'
title: 'Build a quickstart'
template: 'GuideTemplate'
description: ''
---

You’ve developed a new database called flashDB, the lightest and fastest database in the space. Your database is already very popular among the developers. Now, you want to help users of flashDB to quickly and easily observe it in New Relic.

![build a quickstart](../../../images/instant-observability/lab.png)

To achieve your goal, contribute a quickstart to New Relic I/O so other users can quickly monitor flashDB.

New Relic One quickstarts provide immediate value for your specific use case. They include:
- Clear instructions for instrumenting your services
- Observbility building blocks like dashboards and alerts

New Relic allow you to collect, monitor, and report data from different sources. While we offer a large variety of open-source integrations for telemetry tools, you can also use Telemetry SDKs to create your own telemetry data solutions. You can use New Relic One dashboards to view, explore, customize, understand, and correlate the data you collect using different user-friendly charts. You can also set alert policies to monitor key performance metrics and receive notification for anomalies.

Until now, you had to custom build these solutions to observe your applications in New Relic but New Relic now allow you to create and contribute **quickstarts** to help you and others quickly and easily observe it in New Relic.

Throughout this lab, you'll build a custom solution to observe flashdb in New Relic, package the solution as quickstart and contribute it to help others observe flashdb.

## Learning Objectives

- Create New Relic dashboards to get insights from Database transactions (response time, errors, cache hits, cache miss, read/write error etc.)
- Create New Relic Alerts ( high response time, high error rate etc.)
- Write related documentation
- Package the dashboard, alerts and related documentation into a quickstart

<Callout variant="important">

This lesson is a part of lab that teaches you to build quickstart. Before you proceed, make sure you have a New Relic Account. Continue on to first lesson: [_Send data to New Relic_](/instant-observability/build-a-quickstart/send-data-to-newrelic)

</Callout>

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
path: '/instant-observability/build-a-quickstart/send-data-to-newrelic'
title: 'Send data to New Relic'
template: 'GuideTemplate'
description: 'Spin up your demo services and send data to New Relic'
duration: '5 min'
---

<Callout variant='important'>

This lesson is a part of lab that teaches you to build quickstart. If you haven't already, checkout the introduction to [_build a quickstart_] (/instant-observability/build-a-quickstart/index)

</Callout>

Before you build a quickstart, you need to spin up demo services. The lab depends on two important services:
- A python program that mimics the database and also provides functions for CRUD operations.
- A simulator service that generates dummy database traffic and performs CRUD operations.
To spin up demo services, you first need to install Docker and also set **NEW_RELIC_INSERT_KEY** environment variable.

> **Note:** **NEW_RELIC_INSERT_KEY** environment variable is your New Relic liscence key. [You can find your New Relic liscence key in your New Relic account](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/).
### Spin up demo services

Clone the lab repository from GitHub:
>```bash
> git clone ......
>```
This repository contains the code for flashdb as well as the simulator for dummy database traffic. Navigate to the demo directory and execute the following commands to build and run docker image.
> ```bash
> docker build -t flashdb .
> docker run flashdb
>```
The above application supply the mock database traffic that we will observe in New Relic with the help of New Relic telemetry sdk. Once the docker image is up and running, you see the following output in your terminal.
![Send-data-to-NewRelic](../../../images/instant-observability/terminal-output.png)
>**Important**
>Make sure you set NEW_RELIC_INSERT_KEY with your actual [license key](https://docs.newrelic.com/docs/accounts/accounts-billing/account-setup/new-relic-license-key/) to see the above output.
The next step is to observe this data in New Relic.
<Callout variant='important'>
This lesson is a part of lab that teaches you to build quickstart. Continue on to next lesson: [_Create New Relic Dashboard_](/instant-observability/build-a-quickstart/create-dashboard.mdx).
</Callout>
Loading

0 comments on commit c33d451

Please sign in to comment.