cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynatrace Business Events Extractions of Json Array

keekos
Frequent Guest

I'm having trouble extracting array attributes when there isn't a top level name for the array.

For example, given the following json request body payload:

 

 

 

[{"Account":"f2fafaf3a","Name":"John Doe","MediumID":"a9fjah"}]

 

 

 

How do I extract the value for Account or Name in the Business Analytics capture rules?  The documentation here doesn't seem to cover this use case.

https://www.dynatrace.com/support/help/platform-modules/business-analytics/ba-events-capturing#repor...

6 REPLIES 6

AntonPineiro
DynaMight Guru
DynaMight Guru

Hi,

Are you using DQL Array ?

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

isidre
Dynatrace Helper
Dynatrace Helper

An example of capturing a JSON with nested array (with a JSON element inside of it in position 0):

{
    "id2": "json_with_array_json_nested",
    "accountData":
    [
        {
            "Account": "f2fafaf3a",
            "Name": "John Doe",
            "MediumID": "a9fjah"
        }
    ]
}

 

Path to capture account name:

accountData.0.Account


This works to get the first position of the array "0" and the value inside the nested JSON. This works on single value arrays.

keekos
Frequent Guest

Thanks, that unfortunately doesn't cover the use case when your data sample omits accountData key for the array.

I ended up using DQL parse and was able to retrieve the correct value.

PARSE(requestbody, "DATA 'Account'LD SPACE?':' SPACE? DQS:Account ") 

isidre
Dynatrace Helper
Dynatrace Helper

Ok, so the request body is an array containing a single JSON. Understood.
A processing rule works fine then. great!

mtomlinson_not
Observer

Linked here from our good friend @KlausEnzenhofer - with a second question for ya: what about extracting an array into a bizevent field?

{
    "id2": "json_with_array_json_nested",
    "accountData":
    [
        {
            "Account": "f2fafaf3a",
            "Name": "John Doe",
            "MediumID": "a9fjah"
        },
        {
            "Account": "gkahfkgjnv",
            "Name": "Andreas Grabner",
            "MediumID": "03u6n9"
        },
        {
            "Account": "5j2nngov8bn",
            "Name": "Brian Wilson",
            "MediumID": "03u5nvov94n"
        }
    ]
}


And I wanted to grab just the Name and MediumID fields.

Using this matcher: $.accountData.[Name,MediumID] would return an array and not a string.

Would we need to just JSONParse() that field then similar to the DPL above?

@victoria has a similar question: https://community.dynatrace.com/t5/Open-Q-A/How-to-Get-Specific-Properties-from-All-Elements-in-an-A...

 

Yeah my only specific concern is that I do not want to capture the entire complex object into the biz event since some of it contains sensitive information. So I do not even want it to get to the point where I can parse it with DQL.

Featured Posts