<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create alert which contains data from log previous to trigger in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Create-alert-which-contains-data-from-log-previous-to-trigger/m-p/437153#M7882</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm trying to create an alert which will be triggered by a field in a log file and extract the data earlier in the log to assist with troubleshooting.&lt;/P&gt;

&lt;P&gt;Extract of log with error below. I have highlighted the error I need to identify and the data previous to the error which I need to send.&lt;/P&gt;

&lt;P&gt;I've created a field for Invoice number which I want to be the trigger for the alert and then return the rows I need but having trouble how to do this.&lt;/P&gt;

&lt;P&gt;2018-10-08 05:12:28,564|INFO |Application|api/v{api-version:apiVersion}/invoices/CreateInvoice POST : request : {&lt;BR /&gt;
  &lt;STRONG&gt;"ApprovalCode": "1112_23",&lt;BR /&gt;
  "BailmentDealerCode": "1112",&lt;BR /&gt;
  "InvoiceNumber": "0090328322",&lt;BR /&gt;
  "InvoiceDate": "2018-10-03",&lt;BR /&gt;
  "BailmentLoanModelCode": "HN270",&lt;BR /&gt;
  "Condition": "New",&lt;BR /&gt;
  "DivisionCode": "MC",&lt;BR /&gt;
  "AssetDetails": {&lt;BR /&gt;
    "Description": "CRF150FJU232 RED",&lt;BR /&gt;
    "Model": "CRF150FJUR1998923",&lt;BR /&gt;
    "VINHIN": "12380238104191",&lt;BR /&gt;
    "Colour": "EXTREME RED",&lt;BR /&gt;
    "EngineNumber": "J700635",&lt;BR /&gt;
    "Registration": "",&lt;BR /&gt;
    "YearOfManufacture": 2018,&lt;BR /&gt;
    "SecurityMake": "H"&lt;BR /&gt;
  },&lt;BR /&gt;
  "GrossAmount": 4552.9,&lt;BR /&gt;
  "TaxAmount": 413.9&lt;/STRONG&gt;&lt;BR /&gt;
}|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:28,611|INFO |Application|wu authenticated|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:29,408|INFO |Application|Start Bailment Acct creation|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:29,454|INFO |Application|Start persist new Bailment Acct TR38656|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:29,486|ERROR|NHibernate.AdoNet.AbstractBatcher|Could not execute query: INSERT INTO &lt;A href="https://community.splunk.com/Version,%20RecordState,%20Description,%20ModelNumber,%20VINHIN,%20EngineNumber,%20Registration,%20YearOfManufacture,%20DistributorInvoiceNumber,%20Color,%20SecurityMakeId" target="_blank"&gt;BailmentAsset&lt;/A&gt; VALUES (@p0, @p1, @Anonymous, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10); select SCOPE_IDENTITY()|(null)|18|&lt;BR /&gt;
System.Data.SqlClient.SqlException (0x80131904): BailmentAsset with matching Engine Number already exists!&lt;BR /&gt;
The transaction ended in the trigger. The batch has been aborted.&lt;BR /&gt;
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action&lt;CODE&gt;1 wrapCloseInAction)&lt;BR /&gt;
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action&lt;/CODE&gt;1 wrapCloseInAction)&lt;BR /&gt;
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)&lt;BR /&gt;
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp;amp; dataReady)&lt;BR /&gt;
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()&lt;BR /&gt;
   at System.Data.SqlClient.SqlDataReader.get_MetaData()&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp;amp; task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp;amp; task, Boolean&amp;amp; usedCache, Boolean asyncWrite, Boolean inRetry)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)&lt;BR /&gt;
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()&lt;BR /&gt;
   at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)&lt;BR /&gt;
ClientConnectionId:8e49ad53-df84-494a-a067-b1a443a562ec&lt;BR /&gt;
Error Number:50000,State:1,Class:16&lt;BR /&gt;
2018-10-08 05:12:29,486|ERROR|NHibernate.Util.ADOExceptionReporter|BailmentAsset with matching Engine Number already exists!&lt;BR /&gt;
The transaction ended in the trigger. The batch has been aborted.|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:29,486|INFO |Application|api/v{api-version:apiVersion}/invoices/CreateInvoice POST : response : {&lt;BR /&gt;
  "Success": false,&lt;BR /&gt;
  &lt;STRONG&gt;"ErrorMessage": "Account could not be created for Invoice number: 0090328322; Reason: The Bailment Asset could not be saved as it has the same Engine Number as an existing bailment asset; VIN/HIN: 12380238104191; Asset value: $4,139.00\r\n",&lt;/STRONG&gt;&lt;BR /&gt;
  "DocumentNumber": null&lt;BR /&gt;
}|(null)|18|&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 21:42:29 GMT</pubDate>
    <dc:creator>huu_huynh</dc:creator>
    <dc:date>2020-09-29T21:42:29Z</dc:date>
    <item>
      <title>Create alert which contains data from log previous to trigger</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Create-alert-which-contains-data-from-log-previous-to-trigger/m-p/437153#M7882</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm trying to create an alert which will be triggered by a field in a log file and extract the data earlier in the log to assist with troubleshooting.&lt;/P&gt;

&lt;P&gt;Extract of log with error below. I have highlighted the error I need to identify and the data previous to the error which I need to send.&lt;/P&gt;

&lt;P&gt;I've created a field for Invoice number which I want to be the trigger for the alert and then return the rows I need but having trouble how to do this.&lt;/P&gt;

&lt;P&gt;2018-10-08 05:12:28,564|INFO |Application|api/v{api-version:apiVersion}/invoices/CreateInvoice POST : request : {&lt;BR /&gt;
  &lt;STRONG&gt;"ApprovalCode": "1112_23",&lt;BR /&gt;
  "BailmentDealerCode": "1112",&lt;BR /&gt;
  "InvoiceNumber": "0090328322",&lt;BR /&gt;
  "InvoiceDate": "2018-10-03",&lt;BR /&gt;
  "BailmentLoanModelCode": "HN270",&lt;BR /&gt;
  "Condition": "New",&lt;BR /&gt;
  "DivisionCode": "MC",&lt;BR /&gt;
  "AssetDetails": {&lt;BR /&gt;
    "Description": "CRF150FJU232 RED",&lt;BR /&gt;
    "Model": "CRF150FJUR1998923",&lt;BR /&gt;
    "VINHIN": "12380238104191",&lt;BR /&gt;
    "Colour": "EXTREME RED",&lt;BR /&gt;
    "EngineNumber": "J700635",&lt;BR /&gt;
    "Registration": "",&lt;BR /&gt;
    "YearOfManufacture": 2018,&lt;BR /&gt;
    "SecurityMake": "H"&lt;BR /&gt;
  },&lt;BR /&gt;
  "GrossAmount": 4552.9,&lt;BR /&gt;
  "TaxAmount": 413.9&lt;/STRONG&gt;&lt;BR /&gt;
}|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:28,611|INFO |Application|wu authenticated|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:29,408|INFO |Application|Start Bailment Acct creation|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:29,454|INFO |Application|Start persist new Bailment Acct TR38656|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:29,486|ERROR|NHibernate.AdoNet.AbstractBatcher|Could not execute query: INSERT INTO &lt;A href="https://community.splunk.com/Version,%20RecordState,%20Description,%20ModelNumber,%20VINHIN,%20EngineNumber,%20Registration,%20YearOfManufacture,%20DistributorInvoiceNumber,%20Color,%20SecurityMakeId" target="_blank"&gt;BailmentAsset&lt;/A&gt; VALUES (@p0, @p1, @Anonymous, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10); select SCOPE_IDENTITY()|(null)|18|&lt;BR /&gt;
System.Data.SqlClient.SqlException (0x80131904): BailmentAsset with matching Engine Number already exists!&lt;BR /&gt;
The transaction ended in the trigger. The batch has been aborted.&lt;BR /&gt;
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action&lt;CODE&gt;1 wrapCloseInAction)&lt;BR /&gt;
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action&lt;/CODE&gt;1 wrapCloseInAction)&lt;BR /&gt;
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)&lt;BR /&gt;
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp;amp; dataReady)&lt;BR /&gt;
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()&lt;BR /&gt;
   at System.Data.SqlClient.SqlDataReader.get_MetaData()&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp;amp; task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp;amp; task, Boolean&amp;amp; usedCache, Boolean asyncWrite, Boolean inRetry)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)&lt;BR /&gt;
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)&lt;BR /&gt;
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()&lt;BR /&gt;
   at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)&lt;BR /&gt;
ClientConnectionId:8e49ad53-df84-494a-a067-b1a443a562ec&lt;BR /&gt;
Error Number:50000,State:1,Class:16&lt;BR /&gt;
2018-10-08 05:12:29,486|ERROR|NHibernate.Util.ADOExceptionReporter|BailmentAsset with matching Engine Number already exists!&lt;BR /&gt;
The transaction ended in the trigger. The batch has been aborted.|(null)|18|&lt;BR /&gt;
2018-10-08 05:12:29,486|INFO |Application|api/v{api-version:apiVersion}/invoices/CreateInvoice POST : response : {&lt;BR /&gt;
  "Success": false,&lt;BR /&gt;
  &lt;STRONG&gt;"ErrorMessage": "Account could not be created for Invoice number: 0090328322; Reason: The Bailment Asset could not be saved as it has the same Engine Number as an existing bailment asset; VIN/HIN: 12380238104191; Asset value: $4,139.00\r\n",&lt;/STRONG&gt;&lt;BR /&gt;
  "DocumentNumber": null&lt;BR /&gt;
}|(null)|18|&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:42:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Create-alert-which-contains-data-from-log-previous-to-trigger/m-p/437153#M7882</guid>
      <dc:creator>huu_huynh</dc:creator>
      <dc:date>2020-09-29T21:42:29Z</dc:date>
    </item>
  </channel>
</rss>

