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

Scheduling Synthetics in Dynatrace Managed

GilesDay
Advisor

I have a client asking to schedule different synthetic tests at different times, otherwise we may be flagged by their fraud system. (can't have the same user logging into multiple apps at once...), and due to what the username is linked to, we can't generate additional test accounts.

ie:

  • SynthTest 1 runs at 11:01, 11:11, 11:21, etc.
  • SyntTest 2 runs at 11:03, 11:13, 11:23, etc.

I've asked them if they can allowlist (the other word that'd normally be used was blocked by the forum system) the username, by header, by IP, or by combination; however, I'm not sure they can do that, so I thought I'd check here.

Other than setting up a bunch of maintenance windows, is there a way to schedule them? (This is a capability of another tool they are using that we are trying to migrate off of).

We run a Dynatrace Managed cluster so workflows are not an option (unless I missed an announcement)

Why do App Developers have high insurance rates? (gnihsarc peek yehT)
5 REPLIES 5

Julius_Loman
DynaMight Legend
DynaMight Legend

First of all, you don't schedule synthetic at exact times, but you provide intervals between runs.

I'd use the JavaScript steps (or pre/post JavaScript actions if this should be an HTTP test) to wait. The challenge is to know if the other test has finished execution. There is no option to "communicate" between tests using Dynatrace means. The only way I can think of is a kind of "lock" through an external system or through a credential vault. Unfortunately, browser synthetic tests do not have api.saveCredential method, while http tests do. 
Can you determine if the user is logged on in your application?

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

If you would like to use the Credential Vault for this for Browser monitors, you can write to the CV using a fetch in a JavaScript event

api.startAsyncSyntheticEvent(); 

let cv = "CREDENTIALS_VAULT-XXX";  // Your pre-existing credential vault entry 
let at = "dt0c01.whatever your token value";  // access token
let url = "https://xxx/api/v2/credentials/" + cv; // Your tenant api url
let pw = "added"; 
let putObj = { 
    "name": "XXX", // Credential name 
    "scopes": ["SYNTHETIC"], // Same scopes as current CV, so you'll need to check
    "type": "USERNAME_PASSWORD", 
    "password": pw, // Password field value 
    "user": usernameFld // Username field value 
} 

fetch(url, { 
    headers: { 
        "Authorization": "Api-Token " + at, 
        "Content-Type": "application/json" 
    }, 
    method: "PUT", 
    body: JSON.stringify(putObj) 
}).then(reply => { 
    if (reply.status == 201) { 
        return reply.json(); 
    } else 
        return {} 
}).then(obj => { 
    api.info("Success!\n" + JSON.stringify(obj)); 
api.finish(); 
}).catch(err => { 
    api.fail("fetch fail: " + err); 
});
Synthetic SME and community advocate.

@HannahM I'd update it and store the api token in (another) CV.

Still wondering why HTTP monitors have an API to store values in CV, and Browser monitors do not.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Yes, that would be better. 

No idea why we didn't add the save option to BMs. I'll ask. 

Synthetic SME and community advocate.

Yeah, that's what I figured. I just wanted to make sure I wasn't missing something. 

These would be both http and browser checks.

Why do App Developers have high insurance rates? (gnihsarc peek yehT)

Featured Posts