Extracting data from Azure Data Factory Logs
I'm retrieving Azure Data Factory logs for analysis using Powershell.
I am successfully retrieving the top level log (the pipeline) and the log nested inside that (activities) and writing to a text file.
However I'm having issues flattening the activities file, which consists of a mix of flat records and fields containing json
Here is my abridged script. The issue is with the last cmdlet call. I need to work out how to flatten it out to what I need
$DateFrom = (new-object System.DateTime 2018, 07, 01)
$DateTo = Get-Date
$Pipeline="MyPipeline"
$Outputfile="C:SRCADF$Pipeline.TXT"
$OutputSubfile="C:SRCADF$Pipeline.Sub.TXT"
$DFname ="MyDataFactory"
$RG="MyRG"
$TenantId="a16xxxx-xxx-xxx"
$Subscription="d8xxx-xxx-xxx"
$Credential = Get-Credential
Connect-AzureRmAccount `
-TenantId $TenantId `
-Subscription $Subscription `
-Credential $Credential
$oADFLog = Get-AzureRmDataFactoryV2PipelineRun `
-ResourceGroupName $RG `
-DataFactoryName $DFname `
-LastUpdatedAfter $DateFrom `
-LastUpdatedBefore $DateTo `
-PipelineName $Pipeline
# This is the pipeline log - it works as required
$oADFLog | Export-Csv -Path $Outputfile -Delimiter "`t" -NoTypeInformation
# Delete the subtask file
Remove-Item -Path $oADFSubLog -Force -Recurse -ErrorAction Ignore
Foreach ($PipelineRun IN $oADFLog)
{
# For each parent run ID, check the child tasks
# File results in thispart need to be cleaned up
$oADFSubLog = Get-AzureRmDataFactoryV2ActivityRun `
-PipelineRunId $PipelineRun.RunId `
-ResourceGroupName $PipelineRun.ResourceGroupName `
-DataFactoryName $PipelineRun.DataFactoryName `
-RunStartedAfter $DateFrom `
-RunStartedBefore $DateTo
# This is the activity log - it has nested data types and is ugly
# I need to flatten the Json inside the message
$oADFSubLog | Export-Csv -Append -Path $OutputSubfile -Delimiter "`t" -NoTypeInformation
}
Given $oADFSubLog
in the above script, I've discovered that I can pull out some piece that I need like this:
(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
This pulls the property that I need out of the Json
But I'm not sure how to easily push that out to a file in conjunction with the other flat attributes
I've tried this, which is really just a stab in the dark
$oADFSubLog | Select-Object -Property ActivityName,@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
But I get
Select-Object : Cannot convert System.Management.Automation.PSObject
to one of the following types {System.String,
System.Management.Automation.ScriptBlock}.
I've seen a few examples of custom cmdlets and scripts that can be added but I don't want to go there just yet - I just want to understand how to do this.
azure-data-factory-2 powershell-v5.1
|
show 2 more comments
I'm retrieving Azure Data Factory logs for analysis using Powershell.
I am successfully retrieving the top level log (the pipeline) and the log nested inside that (activities) and writing to a text file.
However I'm having issues flattening the activities file, which consists of a mix of flat records and fields containing json
Here is my abridged script. The issue is with the last cmdlet call. I need to work out how to flatten it out to what I need
$DateFrom = (new-object System.DateTime 2018, 07, 01)
$DateTo = Get-Date
$Pipeline="MyPipeline"
$Outputfile="C:SRCADF$Pipeline.TXT"
$OutputSubfile="C:SRCADF$Pipeline.Sub.TXT"
$DFname ="MyDataFactory"
$RG="MyRG"
$TenantId="a16xxxx-xxx-xxx"
$Subscription="d8xxx-xxx-xxx"
$Credential = Get-Credential
Connect-AzureRmAccount `
-TenantId $TenantId `
-Subscription $Subscription `
-Credential $Credential
$oADFLog = Get-AzureRmDataFactoryV2PipelineRun `
-ResourceGroupName $RG `
-DataFactoryName $DFname `
-LastUpdatedAfter $DateFrom `
-LastUpdatedBefore $DateTo `
-PipelineName $Pipeline
# This is the pipeline log - it works as required
$oADFLog | Export-Csv -Path $Outputfile -Delimiter "`t" -NoTypeInformation
# Delete the subtask file
Remove-Item -Path $oADFSubLog -Force -Recurse -ErrorAction Ignore
Foreach ($PipelineRun IN $oADFLog)
{
# For each parent run ID, check the child tasks
# File results in thispart need to be cleaned up
$oADFSubLog = Get-AzureRmDataFactoryV2ActivityRun `
-PipelineRunId $PipelineRun.RunId `
-ResourceGroupName $PipelineRun.ResourceGroupName `
-DataFactoryName $PipelineRun.DataFactoryName `
-RunStartedAfter $DateFrom `
-RunStartedBefore $DateTo
# This is the activity log - it has nested data types and is ugly
# I need to flatten the Json inside the message
$oADFSubLog | Export-Csv -Append -Path $OutputSubfile -Delimiter "`t" -NoTypeInformation
}
Given $oADFSubLog
in the above script, I've discovered that I can pull out some piece that I need like this:
(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
This pulls the property that I need out of the Json
But I'm not sure how to easily push that out to a file in conjunction with the other flat attributes
I've tried this, which is really just a stab in the dark
$oADFSubLog | Select-Object -Property ActivityName,@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
But I get
Select-Object : Cannot convert System.Management.Automation.PSObject
to one of the following types {System.String,
System.Management.Automation.ScriptBlock}.
I've seen a few examples of custom cmdlets and scripts that can be added but I don't want to go there just yet - I just want to understand how to do this.
azure-data-factory-2 powershell-v5.1
What does the log file look like? Providing a sample could help
– mykeels
Nov 29 at 9:20
Can you confirm that the value of@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
is a string?
– mykeels
Nov 29 at 9:34
Phew I've had a huge day and I'm knocking off now. I understand that sample log would be helpful but I didn't want to take the time to sanitise it if no one was going to answer. I'll try to find some time to do this tomorrow. I thought I would quickly check the value of packageLocation but just reailsed our ADF has been completely deleted and recreated so my script doesn't work anymore
– Nick.McDermaid
Nov 29 at 9:57
When I type@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
into the console it returns something that looks like a string to me
– Nick.McDermaid
Nov 29 at 9:59
When I put .GetType() on to the end it says it's aSystem.Object
– Nick.McDermaid
Nov 29 at 10:00
|
show 2 more comments
I'm retrieving Azure Data Factory logs for analysis using Powershell.
I am successfully retrieving the top level log (the pipeline) and the log nested inside that (activities) and writing to a text file.
However I'm having issues flattening the activities file, which consists of a mix of flat records and fields containing json
Here is my abridged script. The issue is with the last cmdlet call. I need to work out how to flatten it out to what I need
$DateFrom = (new-object System.DateTime 2018, 07, 01)
$DateTo = Get-Date
$Pipeline="MyPipeline"
$Outputfile="C:SRCADF$Pipeline.TXT"
$OutputSubfile="C:SRCADF$Pipeline.Sub.TXT"
$DFname ="MyDataFactory"
$RG="MyRG"
$TenantId="a16xxxx-xxx-xxx"
$Subscription="d8xxx-xxx-xxx"
$Credential = Get-Credential
Connect-AzureRmAccount `
-TenantId $TenantId `
-Subscription $Subscription `
-Credential $Credential
$oADFLog = Get-AzureRmDataFactoryV2PipelineRun `
-ResourceGroupName $RG `
-DataFactoryName $DFname `
-LastUpdatedAfter $DateFrom `
-LastUpdatedBefore $DateTo `
-PipelineName $Pipeline
# This is the pipeline log - it works as required
$oADFLog | Export-Csv -Path $Outputfile -Delimiter "`t" -NoTypeInformation
# Delete the subtask file
Remove-Item -Path $oADFSubLog -Force -Recurse -ErrorAction Ignore
Foreach ($PipelineRun IN $oADFLog)
{
# For each parent run ID, check the child tasks
# File results in thispart need to be cleaned up
$oADFSubLog = Get-AzureRmDataFactoryV2ActivityRun `
-PipelineRunId $PipelineRun.RunId `
-ResourceGroupName $PipelineRun.ResourceGroupName `
-DataFactoryName $PipelineRun.DataFactoryName `
-RunStartedAfter $DateFrom `
-RunStartedBefore $DateTo
# This is the activity log - it has nested data types and is ugly
# I need to flatten the Json inside the message
$oADFSubLog | Export-Csv -Append -Path $OutputSubfile -Delimiter "`t" -NoTypeInformation
}
Given $oADFSubLog
in the above script, I've discovered that I can pull out some piece that I need like this:
(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
This pulls the property that I need out of the Json
But I'm not sure how to easily push that out to a file in conjunction with the other flat attributes
I've tried this, which is really just a stab in the dark
$oADFSubLog | Select-Object -Property ActivityName,@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
But I get
Select-Object : Cannot convert System.Management.Automation.PSObject
to one of the following types {System.String,
System.Management.Automation.ScriptBlock}.
I've seen a few examples of custom cmdlets and scripts that can be added but I don't want to go there just yet - I just want to understand how to do this.
azure-data-factory-2 powershell-v5.1
I'm retrieving Azure Data Factory logs for analysis using Powershell.
I am successfully retrieving the top level log (the pipeline) and the log nested inside that (activities) and writing to a text file.
However I'm having issues flattening the activities file, which consists of a mix of flat records and fields containing json
Here is my abridged script. The issue is with the last cmdlet call. I need to work out how to flatten it out to what I need
$DateFrom = (new-object System.DateTime 2018, 07, 01)
$DateTo = Get-Date
$Pipeline="MyPipeline"
$Outputfile="C:SRCADF$Pipeline.TXT"
$OutputSubfile="C:SRCADF$Pipeline.Sub.TXT"
$DFname ="MyDataFactory"
$RG="MyRG"
$TenantId="a16xxxx-xxx-xxx"
$Subscription="d8xxx-xxx-xxx"
$Credential = Get-Credential
Connect-AzureRmAccount `
-TenantId $TenantId `
-Subscription $Subscription `
-Credential $Credential
$oADFLog = Get-AzureRmDataFactoryV2PipelineRun `
-ResourceGroupName $RG `
-DataFactoryName $DFname `
-LastUpdatedAfter $DateFrom `
-LastUpdatedBefore $DateTo `
-PipelineName $Pipeline
# This is the pipeline log - it works as required
$oADFLog | Export-Csv -Path $Outputfile -Delimiter "`t" -NoTypeInformation
# Delete the subtask file
Remove-Item -Path $oADFSubLog -Force -Recurse -ErrorAction Ignore
Foreach ($PipelineRun IN $oADFLog)
{
# For each parent run ID, check the child tasks
# File results in thispart need to be cleaned up
$oADFSubLog = Get-AzureRmDataFactoryV2ActivityRun `
-PipelineRunId $PipelineRun.RunId `
-ResourceGroupName $PipelineRun.ResourceGroupName `
-DataFactoryName $PipelineRun.DataFactoryName `
-RunStartedAfter $DateFrom `
-RunStartedBefore $DateTo
# This is the activity log - it has nested data types and is ugly
# I need to flatten the Json inside the message
$oADFSubLog | Export-Csv -Append -Path $OutputSubfile -Delimiter "`t" -NoTypeInformation
}
Given $oADFSubLog
in the above script, I've discovered that I can pull out some piece that I need like this:
(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
This pulls the property that I need out of the Json
But I'm not sure how to easily push that out to a file in conjunction with the other flat attributes
I've tried this, which is really just a stab in the dark
$oADFSubLog | Select-Object -Property ActivityName,@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
But I get
Select-Object : Cannot convert System.Management.Automation.PSObject
to one of the following types {System.String,
System.Management.Automation.ScriptBlock}.
I've seen a few examples of custom cmdlets and scripts that can be added but I don't want to go there just yet - I just want to understand how to do this.
azure-data-factory-2 powershell-v5.1
azure-data-factory-2 powershell-v5.1
asked Nov 12 at 4:28
Nick.McDermaid
11.5k32554
11.5k32554
What does the log file look like? Providing a sample could help
– mykeels
Nov 29 at 9:20
Can you confirm that the value of@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
is a string?
– mykeels
Nov 29 at 9:34
Phew I've had a huge day and I'm knocking off now. I understand that sample log would be helpful but I didn't want to take the time to sanitise it if no one was going to answer. I'll try to find some time to do this tomorrow. I thought I would quickly check the value of packageLocation but just reailsed our ADF has been completely deleted and recreated so my script doesn't work anymore
– Nick.McDermaid
Nov 29 at 9:57
When I type@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
into the console it returns something that looks like a string to me
– Nick.McDermaid
Nov 29 at 9:59
When I put .GetType() on to the end it says it's aSystem.Object
– Nick.McDermaid
Nov 29 at 10:00
|
show 2 more comments
What does the log file look like? Providing a sample could help
– mykeels
Nov 29 at 9:20
Can you confirm that the value of@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
is a string?
– mykeels
Nov 29 at 9:34
Phew I've had a huge day and I'm knocking off now. I understand that sample log would be helpful but I didn't want to take the time to sanitise it if no one was going to answer. I'll try to find some time to do this tomorrow. I thought I would quickly check the value of packageLocation but just reailsed our ADF has been completely deleted and recreated so my script doesn't work anymore
– Nick.McDermaid
Nov 29 at 9:57
When I type@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
into the console it returns something that looks like a string to me
– Nick.McDermaid
Nov 29 at 9:59
When I put .GetType() on to the end it says it's aSystem.Object
– Nick.McDermaid
Nov 29 at 10:00
What does the log file look like? Providing a sample could help
– mykeels
Nov 29 at 9:20
What does the log file look like? Providing a sample could help
– mykeels
Nov 29 at 9:20
Can you confirm that the value of
@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
is a string?– mykeels
Nov 29 at 9:34
Can you confirm that the value of
@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
is a string?– mykeels
Nov 29 at 9:34
Phew I've had a huge day and I'm knocking off now. I understand that sample log would be helpful but I didn't want to take the time to sanitise it if no one was going to answer. I'll try to find some time to do this tomorrow. I thought I would quickly check the value of packageLocation but just reailsed our ADF has been completely deleted and recreated so my script doesn't work anymore
– Nick.McDermaid
Nov 29 at 9:57
Phew I've had a huge day and I'm knocking off now. I understand that sample log would be helpful but I didn't want to take the time to sanitise it if no one was going to answer. I'll try to find some time to do this tomorrow. I thought I would quickly check the value of packageLocation but just reailsed our ADF has been completely deleted and recreated so my script doesn't work anymore
– Nick.McDermaid
Nov 29 at 9:57
When I type
@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
into the console it returns something that looks like a string to me– Nick.McDermaid
Nov 29 at 9:59
When I type
@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
into the console it returns something that looks like a string to me– Nick.McDermaid
Nov 29 at 9:59
When I put .GetType() on to the end it says it's a
System.Object
– Nick.McDermaid
Nov 29 at 10:00
When I put .GetType() on to the end it says it's a
System.Object
– Nick.McDermaid
Nov 29 at 10:00
|
show 2 more comments
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255973%2fextracting-data-from-azure-data-factory-logs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255973%2fextracting-data-from-azure-data-factory-logs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What does the log file look like? Providing a sample could help
– mykeels
Nov 29 at 9:20
Can you confirm that the value of
@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
is a string?– mykeels
Nov 29 at 9:34
Phew I've had a huge day and I'm knocking off now. I understand that sample log would be helpful but I didn't want to take the time to sanitise it if no one was going to answer. I'll try to find some time to do this tomorrow. I thought I would quickly check the value of packageLocation but just reailsed our ADF has been completely deleted and recreated so my script doesn't work anymore
– Nick.McDermaid
Nov 29 at 9:57
When I type
@(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
into the console it returns something that looks like a string to me– Nick.McDermaid
Nov 29 at 9:59
When I put .GetType() on to the end it says it's a
System.Object
– Nick.McDermaid
Nov 29 at 10:00