Search This Blog

Wednesday, 26 June 2019

Getting started with NewRelic

Introduction to New Relic APM

New Relic's software analytics product for application performance monitoring (APM) delivers real-time and trending data about your web application's performance and the level of satisfaction that your end users experience. With end to end transaction tracing and a variety of color-coded charts and reports, APM visualizes your data, down to the deepest code levels.


Get started with the .NET Core agent
Before installing the New Relic .NET Core agent:
  • .NET agent configuration - Required environment variables.

Steps as below
  1. Signup on https://newrelic.com/
  2. Get the "service licenseKey"
  3. Create Sample Application for .Net / .Net Core
  4. From the Package Manager command prompt, type Install-Package NewRelic.Agent and press Enter. When you build your project, the .NET agent folder will be copied to your build output directory
  5. Set environment variables.
  6. update newrelic.config file content for service licenseKey="key from new relic portal"
  7. update newrelic.config file content for SampleWebApplication

Screen shot

Source Code: NewRelic Sample code

Screen Shot 1: You will get New relic dashboard link in logs
Screen Shot 2:
Screen Shot 3:

Solution for Common Mistake

  • Monitor whole system.
  • Monitoring important things about system.
  • Monitor early enough.

Thursday, 31 August 2017

Export unique event log in text file using Microsoft.PowerShell

Example 1: Get event logs on the local computer

In the below give below result

  • Get the ten most recent entries from a specific event log on the local computer, This command gets the ten most recent entries from the Application event log.
  • Get error, warning events from a specific event log. E.g. "Error"
  • Get all errors in an event log that occurred during a specific time frame
  • Get the unique entries from a specific event log on the local computer.
  • Get the MachineName, Source, EntryType, Message properties from entries from a specific event log on the local computer.
  • Export the EventLog in text file to specific server location.

Script

$AfterDate = (Get-Date -Date '26/8/2017');
$Message = Get-EventLog  -LogName "Application" -EntryType Error, Warning -Newest 10  -Source "BizTalk Server" -After $AfterDate -ComputerName "localhost" 
$Message = $Message | Format-List -Property MachineName, Source, EntryType, Message 
$Message = $Message | select -uniq;
$Message >> \\ServerName\c$\Users\harshal.chaudhari\SystemErrors.txt

Result


MachineName : ServerName
Source      : BizTalk Server
EntryType   : Warning
Message     : An error occurred that requires the BizTalk service to terminate. The most common causes are the 
              following:
               1) An unexpected out of memory error.
               OR
               2) An inability to connect or a loss of connectivity to one of the BizTalk databases. 
               The service will shutdown and auto-restart in 1 minute. If the problematic database remains 
              unavailable, this cycle will repeat.

Rerefence



Thursday, 17 August 2017

Identify if IIS is Running on a Server

PowerShell Script

Identify IIS is running on Remote server.

$vm = "localhost"
$iis = get-wmiobject Win32_Service -ComputerName $vm -Filter "name='IISADMIN'"
if($iis.State -eq "Running")
{
 Write-Host "IIS is running on $vm"
}
else
{
 Write-Host "IIS is not running on $vm"
}

Friday, 11 August 2017

Bad Smells in Code

  • Duplicate code If you see the same code structure in more than one place.

  • Long Method The longer a procedure is, the more difficult it is to understand.

  • Large Class When a class is trying to do too much.

  • Long Parameter List Don't pass in everything the method needs; instead you pass enough so that the method can get to everything it needs.

  • Divergent Change When one class is commonly changed in different ways for different reasons. (You likely have a situation in which two objects are better than one.)

Heads up! When you feel the need to write a comment, first try to refactor the code .so that any comment becomes superfluous.

C# Code Review CheckList

  1. https://azure-blaze.blogspot.com/2017/08/is-renaming-worth-effort.html

  2. https://azure-blaze.blogspot.com/2017/08/bad-smells-in-code.html


Heads up! Any fool can write code that a computer can understand. Good Programmers write code that humans can understand.

Is renaming worth the effort?

  • Good code should communicate what it is doing clearly.

  • Never be afraid to change the name of things to improve clarity.

  • Code that communicates its purpose is very important.

Heads up! Any fool can write code that a computer can understand. Good Programmers write code that humans can understand.

ASP.Net Web API vs WCF, which one should I choose?

  • Choose WCF when you want to create a service that should support special scenarios such as one way messaging, message queues, duplex communication etc.

  • Choose WCF when you want to create a service that can use fast transport channels when available, such as TCP, Named Pipes, or maybe even UDP (in WCF 4.5), and you also want to support HTTP when all other transport channels are unavailable.

  • Choose Web API when you want to create a resource-oriented services over HTTP that can use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats).

  • Choose Web API when you want to expose your service to a broad range of clients including browsers, mobiles and tablets.

API Authentication

Reference · Identity & Access API Authentication Methods Four common ways a client proves who it is to a server, ord...

Recent Post