/// <summary> /// Processes a full logset from end-to-end. /// </summary> /// <param name="request">The user's processing request.</param> /// <returns>Run context containing the run outcome and details of what happened during the run.</returns> public LogsharkRunContext ProcessRequest(LogsharkRequest request) { // Clear any cached event timing data. GlobalEventTimingData.Clear(); // Update log4net to contain the CustomId and RunId properties for any consumers which wish to log them. LogicalThreadContext.Properties["CustomId"] = request.CustomId; LogicalThreadContext.Properties["RunId"] = request.RunId; try { using (new LocalMongoDatabaseManager(request)) { // Verify all external dependencies are up and available. var serviceDependencyValidator = new ServiceDependencyValidator(request.Configuration); serviceDependencyValidator.ValidateAllDependencies(); var metadataWriter = new LogsharkRunMetadataPostgresWriter(request.Configuration.PostgresConnectionInfo); return(ExecuteLogsharkRun(request, metadataWriter)); } } catch (Exception ex) { Log.FatalFormat("Logshark run failed: {0}", ex.Message); if (!String.IsNullOrWhiteSpace(ex.StackTrace)) { Log.Debug(ex.StackTrace); } throw; } }
private DateTime GetPluginExecutionTimestamp(string pluginName) { var timeStamp = GlobalEventTimingData.GetStartTime("Executed Plugin", pluginName); if (timeStamp == null) { return(default(DateTime)); } return(timeStamp.Value); }
public LogProcessingMetadata(LogsetParsingRequest request) { Id = request.LogsetHash; Target = request.Target; TargetSize = request.Target.Size; LogsetType = request.ArtifactProcessor.ArtifactType; ProcessedSuccessfully = false; ProcessingTimestamp = request.CreationTimestamp; ProcessingTime = GlobalEventTimingData.GetElapsedTime("Parsed Files", request.LogsetHash); User = Environment.UserName; Machine = Environment.MachineName; LogsharkVersion = typeof(LogsharkRequestProcessor).Assembly.GetName().Version.ToString(); ArtifactProcessorType = request.ArtifactProcessor.GetType().Name; ArtifactProcessorVersion = request.ArtifactProcessor.GetType().Assembly.GetName().Version; CollectionsParsed = new SortedSet <string>(request.CollectionsToParse); }
public LogsharkRunMetadata(LogsharkRunContext run, int?id = null) { // Update record id if it was passed in. if (id.HasValue) { Id = id.Value; } // Request & target metadata. CustomId = run.Request.CustomId; DatabaseName = run.Request.PostgresDatabaseName; RunId = run.Request.RunId; RunByUser = Environment.UserName; RunByMachine = Environment.MachineName; Source = run.Request.Source; Target = run.Request.Target; TargetSize = run.Request.Target.Size; VersionLogshark = typeof(LogsharkRequestProcessor).Assembly.GetName().Version.ToString(); // Timing metadata. FullRunStartTime = run.Request.RequestCreationDate; FullRunElapsedSeconds = (DateTime.UtcNow - run.Request.RequestCreationDate).TotalSeconds; LastMetadataUpdateTime = DateTime.UtcNow; LogsetExtractionStartTime = GlobalEventTimingData.GetStartTime("Unpack Archives"); LogsetExtractionElapsedSeconds = GlobalEventTimingData.GetElapsedTime("Unpack Archives"); LogParsingStartTime = GlobalEventTimingData.GetStartTime("Parsed Files"); LogParsingElapsedSeconds = GlobalEventTimingData.GetElapsedTime("Parsed Files"); PluginExecutionStartTime = GlobalEventTimingData.GetStartTime("Executed Plugins"); PluginExecutionElapsedSeconds = GlobalEventTimingData.GetElapsedTime("Executed Plugins"); // Context metadata. CurrentProcessingPhase = run.CurrentPhase.ToString(); CustomMetadataRecords = GetCustomMetadataRecords(run.Request); IsValidLogset = run.IsValidLogset; // Initialization metadata. if (run.InitializationResult != null) { LogsetHash = run.InitializationResult.LogsetHash; LogsetType = run.InitializationResult.ArtifactProcessor.ArtifactType; PluginsExecuted = GetExecutedPluginsString(run.InitializationResult); } // Parsing metadata. if (run.ParsingResult != null) { TargetProcessedSize = run.ParsingResult.ParsedDataVolumeBytes; UtilizedExistingLogsetHash = run.ParsingResult.UtilizedExistingProcessedLogset; } // Plugin execution metadata. if (run.PluginExecutionResult != null) { ContainsSuccessfulPluginExecution = run.PluginExecutionResult.PluginResponses.Any(pluginResponse => pluginResponse.SuccessfulExecution); PluginExecutionMetadataRecords = GetPluginExecutionMetadataRecords(run.PluginExecutionResult); PluginsFailed = String.Join(",", run.PluginExecutionResult.PluginResponses.Where(pluginResponse => !pluginResponse.SuccessfulExecution)); PublishedWorkbookMetadataRecords = GetPublishedWorkbookMetadataRecords(run.PluginExecutionResult, run.Request.Configuration.TableauConnectionInfo); } // Outcome metadata. IsRunSuccessful = run.IsRunSuccessful; if (run.CurrentPhase == ProcessingPhase.Complete) { IsRunComplete = true; } RunFailureExceptionType = run.RunFailureExceptionType; if (run.RunFailurePhase.HasValue) { RunFailurePhase = run.RunFailurePhase.ToString(); } RunFailureReason = run.RunFailureReason; }