Press enter to see results or esc to cancel.

Application Insights: The tool that will help get you back your weekends.

Reading Time: 4 minutes

Its Saturday 10 am, you wake up and plan to spend your day leisurely. Maybe take a walk outside or watch 1 or 2 movies or go meet couple of your friends.

Next, your phone starts buzzing and yes it’s your boss whose calling you. He is calling you letting you know that something is gone wrong with your e-commerce application. Customer’s are complaining all over your company social media. He needs your help to find out what’s going on. Its now your job now to Detect, Triage, and fix the bug.

What’s your first thought? Gone – another weekend.

Weekdays and Weekends:

How do we make sure what we do on weekdays — don’t breakdown on weekends?

Applications don’t know the difference between weekdays or weekends. They can go down any day or worst anytime. Unfortunately, we cannot stop them from breaking down on weekends. However, we can alteast setup some more tools that will help us during the fires. Say a tool that will alert you before you boss comes to know.

Fortunately, somebody already had same problems and developed tools for everybody. Its called Application Insights.

What is Application Insight?

Application Insights is a Application Performance Management (APM) service from Microsoft Azure.

It is used for applications health monitoring and analytics. Provisioning monitoring and alerting tools is important to gauge and react faster to issues.

Once deployed — Application Insights is constantly looking out for peaks, failures, exceptions, and faults on your behalf. It provides rich visual graphics to easily understand and analyze the collected data.

Screen Shot 2017-04-30 at 8.38.35 PM.png
CPU Usage and Http Requests information available in dashboard.

Thought Experiment:

Say you are working in Microservices architecture for an e-commerce company. Your company generates a Quote, and converts it to a Order. Order is then fulfilled and sent to Shipping. Quote, Order, Product, Customer, Fulfillment, and Shipping are the various departments. Each department services through a Microservices and they all work together to complete an Order.

Now, how would you maintain sanity in such scenarios ?

How will you find out if there is a new bug in your workflow? What if this bug was introduced recently by a another team? What if this team member is in another country? What if it’s a national holiday today? Who do you need to call to fix it? Or would you Download their repository, and start debugging? What is your reaction time? What is your fix? Well, these are the questions in the minds developers when starting to work on issues.

When to setup Application Insights?

ASAP! As soon as we create an application, we can setup App Insights to start capturing data for analytics. More the data, better the analysis.

How Application Insights works?

ASP.Net web applications can install basic libraries from Nuget, and supply the instrumentation key in the web.config. That’s it. Instrumentation will automatically start running, and upload telemetry data to Azure services.

Screen Shot 2017-04-29 at 9.41.03 PM.pngThis data is available (per setup) in Azure portal. You can analyze data in tables or charts. All conveniently facilitated in one central place.

Infact the code that runs outside of Azure will still do telemetry upload — not necessarily in Azure.

What does Application Insights exactly Monitor?

Everything! Pretty much everything you want it to monitor.

  1. Http Requests & Responses:
    1. How many requests were successful, and
    2. How many failed.
    3. Why they failed.
    4. When they failed.
  2. Dependency calls.
    1. How many SQL Server calls.
    2. What may be the exceptions from SQL server etc.
  3. Server Exceptions.
    1. What exceptions were thrown by your application.
    2. Which class.
    3. Which method.
    4. Which line.
    5. What exception.
    6. What time.
    7. How many times this exception happened.
  4. Page views.
    1. How many views per page.
    2. Highest viewed page.
    3. Slowest loading page.
  5. Performance counters.
    1. Server CPU usage.
    2. Server RAM usage.
    3. Server storage usage.
  6. User session counts.
    1. How many users are currently logged.
    2. How many failed login.
  7. Custom events.
    1. Custom metrics through code.
    2. Like how many orders processed.
    3. How many still processing.
    4. How many payment confirmed.
    5. How many fulfilled.
    6. How many shipped.

Analytics:

Application Insight is also a analytics engine that can learn the behavior of code and suggest changes. Like Application Insights can suggest Indexes on SQL Server tables based on queries we run.

Top 10 countries by traffic in the past 24 hours
Top 10 countries by traffic in the past 24 hours

You can analyze the usage patterns for resources and pages from App Insights. Like how many people are currently logged into a website. How many times a particular page was viewed. How many web api requests return 500 http status code. Best of all, you can setup custom alerts for these metrics.

Proactive monitoring:

What if we could catch a bug before our prestigious customer notices it?

What if we could scale up out applications before our website starts slowing down?

Such pro-active measures can help us improve credibility with customers. It will also lessen embarrassment for management. Looking out for changes in behavior pre and post deployments will reduce the severity of damages – if any.

application-insights-slowest-requests.png
Application requests can show the top slowest requests in your website. This sort of the information can understand the load times, and improve if any.

When is as important as How you detect an issue.

Payload:

How many times have you reported a bug without evidence? None.

Especially in Web API world — bugs are considered rumors if you don’t provide evidence (payload).

Payloads lets team to identify, and reproduce a bug. Without payload, they have simulate the bug using production data elsewhere. Every team is busy working for their sprint. Without payload, they won’t investigate bugs and provision your request. You are bound to provide evidence as much as the detection itself.

Application Insights can be setup to save incoming and outgoing requests — especially the failed ones. You can pull payload from logs and send out to the responsible team. That’s it — now it is a someone else problem. Defects can be triaged accordingly.

Conclusion:

In conclusion, to serve our customers well we should also give importance to building dev tools around the actual system. Doing so, will help developers react faster to catastrophic failures and indirectly improving the customer experience.

Comments

Leave a Comment

Leave a Reply