09 Sep 2025
06:19 PM
- last edited on
10 Sep 2025
07:39 AM
by
MaciejNeumann
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:
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)
09 Sep 2025 09:31 PM
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?
10 Sep 2025 08:28 AM
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);
});
10 Sep 2025 08:35 AM
@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.
10 Sep 2025 08:38 AM
Yes, that would be better.
No idea why we didn't add the save option to BMs. I'll ask.
11 Sep 2025 02:03 PM
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.