public override void ExecuteCommand() { TableErrorLog log = new TableErrorLog(string.Format(ElmahAccountCredentials)); List<ErrorLogEntry> entities = new List<ErrorLogEntry>(); log.GetErrors(0, 500, entities); //retrieve n * LastNHours errors assuming a max of 500 errors per hour. int count = entities.Where(entity => entity.Error.Time.ToUniversalTime() > DateTime.UtcNow.AddHours(-1) && entity.Error.Time.ToUniversalTime() < DateTime.UtcNow).ToList().Count; ReportHelpers.AppendDatatoBlob(StorageAccount, "ErrorRate" + string.Format("{0:MMdd}", DateTime.Now) + ".json", new Tuple<string, string>(String.Format("{0:HH:mm}", DateTime.Now), count.ToString()), 50, ContainerName); }
public override void ExecuteCommand() { TableErrorLog log = new TableErrorLog(string.Format(ElmahAccountCredentials)); List <ErrorLogEntry> entities = new List <ErrorLogEntry>(); log.GetErrors(0, 500, entities); //retrieve n * LastNHours errors assuming a max of 500 errors per hour. int count = entities.Where(entity => entity.Error.Time.ToUniversalTime() > DateTime.UtcNow.AddHours(-1) && entity.Error.Time.ToUniversalTime() < DateTime.UtcNow).ToList().Count; ReportHelpers.AppendDatatoBlob(StorageAccount, "ErrorRate" + string.Format("{0:MMdd}", DateTime.Now) + ".json", new Tuple <string, string>(String.Format("{0:HH:mm}", DateTime.Now), count.ToString()), 50, ContainerName); }
public static void CleanAssembly() { TableErrorLog log = new TableErrorLog(@"DefaultEndpointsProtocol=https;AccountName=" + Environment.GetEnvironmentVariable("StorageAccount") + @";AccountKey=""" + Environment.GetEnvironmentVariable("StorageAccessKey") + @""""); List<ErrorLogEntry> entities = new List<ErrorLogEntry>(); log.GetErrors(0, 1000, entities); //this gets the error logs in the last ten minutes entities = entities.FindAll(entity => DateTime.Now.Subtract(entity.Error.Time) > new TimeSpan(0, 10, 0)); if (entities != null) { foreach (ErrorLogEntry entity in entities) { Assert.Inconclusive(String.Format("ELMAH log error found: {0}, {1}, {2}", entity.Error.Message, entity.Error.Time.ToString(), entity.Error.StatusCode)); } } }
public static void CleanAssembly() { TableErrorLog log = new TableErrorLog(@"DefaultEndpointsProtocol=https;AccountName=" + Environment.GetEnvironmentVariable("StorageAccount") + @";AccountKey=""" + Environment.GetEnvironmentVariable("StorageAccessKey") + @""""); List <ErrorLogEntry> entities = new List <ErrorLogEntry>(); log.GetErrors(0, 1000, entities); //this gets the error logs in the last ten minutes entities = entities.FindAll(entity => DateTime.Now.Subtract(entity.Error.Time) > new TimeSpan(0, 10, 0)); if (entities != null) { foreach (ErrorLogEntry entity in entities) { Assert.Inconclusive(String.Format("ELMAH log error found: {0}, {1}, {2}", entity.Error.Message, entity.Error.Time.ToString(), entity.Error.StatusCode)); } } }
public List <ElmahError> GetElmahError(DateTime start, DateTime end) { if (StorageAccount == null) { StorageAccount = CloudStorageAccount.Parse(ConnectionString); } List <string> nonCriticalErrorDictionary = new JavaScriptSerializer().Deserialize <List <string> >(Load(StorageAccount, "Configuration.ElmahNonCriticalErrors.json", ContainerName)); TableErrorLog log = new TableErrorLog(string.Format(ElmahAccountCredentials)); List <ErrorLogEntry> entities = new List <ErrorLogEntry>(); int lasthours = DateTime.Now.Subtract(start).Hours + 1; log.GetErrors(0, 500 * lasthours, entities); //retrieve n * LastNHours errors assuming a max of 500 errors per hour. List <ElmahError> listOfErrors = new List <ElmahError>(); //Get the error from Last N hours. if (entities.Any(entity => entity.Error.Time.ToUniversalTime() > start.ToUniversalTime() && entity.Error.Time.ToUniversalTime() < end.ToUniversalTime())) { entities = entities.Where(entity => entity.Error.Time.ToUniversalTime() > start.ToUniversalTime() && entity.Error.Time.ToUniversalTime() < end.ToUniversalTime()).ToList(); var elmahGroups = entities.GroupBy(item => item.Error.Message); //Group the error based on exception and send alerts if critical errors exceed the thresold values. foreach (IGrouping <string, ErrorLogEntry> errorGroups in elmahGroups) { Console.WriteLine(errorGroups.Key.ToString() + " " + errorGroups.Count()); int severity = 0; if (nonCriticalErrorDictionary.Any(item => errorGroups.Key.ToString().Contains(item))) { severity = 1; //sev 1 is low pri and sev 0 is high pri. } string link = "https://www.nuget.org/Admin/Errors.axd/detail?id={0}"; if (ContainerName.Contains("qa")) { link = "https://int.nugettest.org/Admin/Errors.axd/detail?id={0}"; } //for severity, assume all refresh error, severity = 0 listOfErrors.Add(new ElmahError(errorGroups.Key.ToString(), errorGroups.Count(), errorGroups.Min(item => item.Error.Time.ToLocalTime()), errorGroups.Max(item => item.Error.Time.ToLocalTime()), string.Format(link, errorGroups.First().Id), errorGroups.First().Error.Detail, severity)); } } return(listOfErrors); }
public List<ElmahError> GetElmahError(DateTime start, DateTime end) { if (StorageAccount == null) StorageAccount = CloudStorageAccount.Parse(ConnectionString); List<string> nonCriticalErrorDictionary = new JavaScriptSerializer().Deserialize<List<string>>(Load(StorageAccount, "Configuration.ElmahNonCriticalErrors.json", ContainerName)); TableErrorLog log = new TableErrorLog(string.Format(ElmahAccountCredentials)); List<ErrorLogEntry> entities = new List<ErrorLogEntry>(); int lasthours = DateTime.Now.Subtract(start).Hours + 1; log.GetErrors(0, 500 * lasthours, entities); //retrieve n * LastNHours errors assuming a max of 500 errors per hour. List<ElmahError> listOfErrors = new List<ElmahError>(); //Get the error from Last N hours. if (entities.Any(entity => entity.Error.Time.ToUniversalTime() > start.ToUniversalTime() && entity.Error.Time.ToUniversalTime() < end.ToUniversalTime())) { entities = entities.Where(entity => entity.Error.Time.ToUniversalTime() > start.ToUniversalTime() && entity.Error.Time.ToUniversalTime() < end.ToUniversalTime()).ToList(); var elmahGroups = entities.GroupBy(item => item.Error.Message); //Group the error based on exception and send alerts if critical errors exceed the thresold values. foreach (IGrouping<string, ErrorLogEntry> errorGroups in elmahGroups) { Console.WriteLine(errorGroups.Key.ToString() + " " + errorGroups.Count()); int severity = 0; if (nonCriticalErrorDictionary.Any(item => errorGroups.Key.ToString().Contains(item))) { severity = 1; //sev 1 is low pri and sev 0 is high pri. } string link = "https://www.nuget.org/Admin/Errors.axd/detail?id={0}"; if (ContainerName.Contains("qa")) { link = "https://int.nugettest.org/Admin/Errors.axd/detail?id={0}"; } //for severity, assume all refresh error, severity = 0 listOfErrors.Add(new ElmahError(errorGroups.Key.ToString(), errorGroups.Count(), errorGroups.Min(item => item.Error.Time.ToLocalTime()), errorGroups.Max(item => item.Error.Time.ToLocalTime()), string.Format(link, errorGroups.First().Id), errorGroups.First().Error.Detail, severity)); } } return listOfErrors; }