Row vs Column-Oriented Databases | SentinelOne

Application Insights at the Speed of Scalyr

Introduction

Application Insights (Microsoft Azure) is a powerful Application Performance Management (APM) system for web developers on multiple platforms. It is versatile and can be used for many of the following use cases:

 

  • Monitor your live web application.
  • Automatically detect performance anomalies.
  • Gather telemetry data.
  • Continuously improve web performance and extensibility

 

Azure scalyr data knowledge learning information

It extends to applications on a wide array of platforms including .NET, Node.js and Java EE, hosted on-premises, hybrid, or any public cloud. It works with Visual Studio to collect telemetry data, can connect to many of your DevOps tools to collect data and can be used to detect anomalies.

When used in conjunction with Scalyr, you can get the unmatched performance and speed of Scalyr, with the powerful monitoring features of Application Insights. 

Prerequisites

  1. Azure Account
  2. Scalyr Account
  3. Azure CLI

Overview

Using this method, we will create an Application Insights instance and export the contents to a blob store. We will sync the storage location to a mounted drive and have the agent poll that drive for changes. A summary of the steps is shown below.

  1. Setup Infrastructure
    • Create resources
      • Resource Group
      • App Service plan
      • Web App
      • Application Insights
      • Storage
        • container
      • Virtual Machine (Scalyr Agent)
  2. Setup app in Visual Studio
  3. Setup Application Insights
    • Install Application Insights SDK
    • Configure Continuous Export to Blob
  4. Setup Scalyr Agent
    • Install BlobFuse
    • Install Scalyr Agent
    • Configure Agent
    • Setup Parser

Setup your Infrastructure

First, let’s create some environment variables. This will make managing our names a bit easier.

export app_name=<your_app_name>
export resource_group=<your_resource_group>
export plan_name=<your_plan_name>
export location=westus
export storage=<blob_name>
export container=<container_name>

Create a Resource Group

az group create
--location $location
--name $resource_group

Create WebApp

az appservice plan create -g $resource_group -n $plan_name
az webapp create
--resource-group $resource_group
--plan $plan_name
--name $app_name

Create Application Insights Resource

az extension add --name application-insights
az monitor app-insights component create
--app $app_name
--location $location
--kind web
--resource-group $resource_group
--application-type web

Create Storage

#create storage account
az storage account create
--name $storage
--resource-group $resource_group
--location $location
--sku Standard_LRS
#list account keys - used in final section as well
az storage account keys list --account-name $storage
#(optional) save key to variable
export key=$(sudo az storage account keys list --account-name $storage | jq '.[1].value')
#create container
az storage container create
--name $container
--account-key $key
--account-name $storage

Create a Virtual Machine

az vm create
--resource-group $resource_group
--name "scalyr"
--image "UbuntuLTS"
--admin-username "ubuntu"
--admin-password "Tjmgh3i2Rghfb2r1"
--location $location

Connect the local development environment to the cloud infrastructure

Install the Required Workloads

Create our .NET web app.

Publish
Link the local App to the infrastructure we created in step 1.

Select “Publish to existing”
Select the infrastructure we created in Step 1 for me that is “Scalyr-Blog” Select a deployment slot if you are using Azure CI/CD Services.

View your WebApp
This should take a few minutes to link and you should see a url in your console – <app-name>.azurewebsites.net

Install Application Insights SDK

Setup the SDK on your App
Navigate to your solution > Right Click > Add > Application Insights
Select Get Started
Select the Application Insights instance we created above

Locate the resource you just created.

 

Once you have installed and connected Application Insights SDK your console should display the following.

[6/6/2019 9:34:04.678 PM] Adding Application Insights to the project.
[6/6/2019 9:34:04.698 PM] Adding package 'Microsoft.ApplicationInsights.AspNetCore.2.5.1' to project 'WebApplication1'…
[6/6/2019 9:34:18.828 PM] Updating appsettings.json file…
[6/6/2019 9:34:19.660 PM] Updating project…
[6/6/2019 9:34:28.784 PM] Successfully added Application Insights to the project.

Setup Continuous Export

Enable Application Insights
Connect your Webapp instance to your Application Insights instance.
Navigate to portal.azure.com > App Services > “The instance we created earlier”
(In my example it is Scalyr-Blog)

Navigate to Application Insights
portal.azure.com > Application Insights > “The instance we created earlier” (In my example it is Blog-App)

Verify the SDK is installed and the WebApp is configured properly
You should see the request we made earlier on the graph

Configure Continuous Export
Navigate to Configure > Continuous Export > Add > Container

Select your datatypes and add the storage location you just created. (NOTE: Location is important here)

Once this is pointed to the correct location, the UI will look something like this.

Setup Scalyr Agent and BlobFuse

SSH into VM

#get the IP Address
az vm list-ip-addresses --name scalyr
#ssh into the public IP Address
ssh ubuntu@<publicIpAddress>
<enter password created in previous step>

Install BlobFuse

wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install blobfuse

Configure Temporary Storage

sudo mkdir /mnt/ramdisk
sudo mount -t tmpfs -o size=16g tmpfs /mnt/ramdisk
sudo mkdir /mnt/ramdisk/blobfusetmp
sudo chown ubuntu /mnt/ramdisk/blobfusetmp

Configure Mount Path

mkdir ~/mycontainer

Configure BlobFuse Path and Key

touch /mnt/ubuntu/fuse_connection.cfg
chmod 600 fuse_connection.cfg
sudo vim /mnt/ubuntu/fuse_connection.cfg
#values from step 1
accountName <storage>
accountKey <key>
containerName <container>

Run BlobFuse

sudo blobfuse ~/mycontainer --tmp-path=/mnt/resource/blobfusetmp  --config-file=~/fuse_connection.cfg -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120

Install the Scalyr Agent
(If you don’t have access to Scalyr, sign up for a completely free trial.)

curl -sO https://www.scalyr.com/install-agent.sh
sudo bash ./install-agent.sh --set-api-key "Your-API-Key"
sudo scalyr-agent-2 start

Configure the Scalyr Agent

https://www.scalyr.com/help/scalyr-agent#logUpload

sudo vim /etc/scalyr-agent-2/agent.json

Add the stanza to look at the mount paths

{
    path: "/home/ubuntu/mycontainer/*/Event/*/*/*",
    attributes: {parser: "appinsights"}
    rename_logfile: "/scalyr/Event.log"
},
{
    path: "/home/ubuntu/mycontainer/*/Metrics/*/*/*",
    attributes: {parser: "appinsights"}
    rename_logfile: "/scalyr/Metrics.log"
},
{
    path: "/home/ubuntu/mycontainer/*/PageViewPerformance/*/*/*",
    attributes: {parser: "appinsights"}
    rename_logfile: "/scalyr/PageViewPerformance.log"
},
{
    path: "/home/ubuntu/mycontainer/*/PageViews/*/*/*",
    attributes: {parser: "appinsights"}
    rename_logfile: "/scalyr/appinsights.log"
},
{
    path: "/home/ubuntu/mycontainer/*/PerformanceCounters/*/*/*",
    attributes: {parser: "appinsights"}
    rename_logfile: "/scalyr/appinsights.log"
},
{
    path: "/home/ubuntu/mycontainer/*/Requests/*/*/*",
    attributes: {parser: "appinsights"}
    rename_logfile: "/scalyr/Requests.log"
},

Edit the parser

{
  formats: [
    {
      id: "format1",
      format: ".*$=json{parse=json}$.*",
      repeat: true
    }
  ]
}

And that is it! You should have Application Insight logs in Scalyr!

Enjoy trying out the speed and simplicity that Scalyr offers in conjunction with Azure Application Insights. Feel free to ask questions and visit the Scalyr community, LogRunners.