Possible to Script Values in Synthetics?

Hi All,

I have a use case where I want to use synthetics to monitor a page, however this page has a URL which requires it to be updated daily with the days date. Kind of like: http://url/<today's_day(2021-10-25)>. Since it appears that synthetics accepts .js files for its sources. Does that mean regular JS can also be used within synthetics to do things like generate and modify values are run time, or is this not possible?

Hi Ben. You absolute can include custom logic in your synthetic scripts to suit your needs.

For example, you can write a step to navigate to a page with dynamic values.

step('Navigate to page', async () => {
    const date = new Date();
    await page.goto(`http://${date.getMonth()}-${date.getDay()}-${date.getFullYear()}`);

We know that many production synthetics scripts will require this type of dynamic logic. Hope this helps.

@Dominique_Clarke great thanks for the information, while I saw stuff like: synthetics-demo/demo.journey.js at main · elastic/synthetics-demo · GitHub, I didn't see anything mention it in the docs, so wasn't sure if it was an intended feature.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.