Is there a way to see the script's console log on observability uptime monitor

Hi,

Hope you're doing well!

We have written the journey for monitoring the web app using playwright and Typescript. We are facing a difficulty to view the script's console.log written with the step, on the uptime monitor.

Do we need to use any other library or method apart of console.log to view the the script logs.

Your help and inputs would be highly appreciated.

Thanks,
Zaid

Hi Zaid,

Thank you for your post and welcome to the community.

Unfortunately, log statements from journey script aren't captured and reported back, unless if the script throws or breaks due to an error.

What's your use case by the way? If you want to test the journey or test how page behaves against a journey script, you can run the test via @elastic/synthetics package via command line locally and can see the log statements in terminal. I am pasting an example below if it helps:

// sample-inline-journey.ts
step('Go to home page', async () => {
  await page.goto('https://www.elastic.co');
  const titleElement = await page.locator('h1.title').first().elementHandle();
  const title = await titleElement.innerText();
  console.log(`Title: ${title}`);
  expect(title).toBeTruthy();
});

And you can run it in terminal:

cat <path>/sample-inline-journey.js | npx @elastic/synthetics --inline

(you can also append --no-headless to view the running test in browser)

It will log:

Journey: inline
Title: Search. Solve. Succeed.
   ✓  Step: 'Go to home page' succeeded (7663 ms)

 1 passed (9936 ms) 

Thanks much @abdulz for your inputs.

Running and logging the log statements locally isn't a problem. It's works fine.

We have a a set of scenarios that runs every 10 mins which are monitored and in these scenarios we perform a page load or a button click, (at least 5-6 times and we have written the some useful logs in this logic), if a certain content in iframe isn't loaded --> We do this because we fetch the iframe content from 3rd party and to avoid false negatives.

On local we cannot really simulate the scenario where the iframe content isn't loading. We ideally play around with locators to check if the iteration logic works fine, which does. But at the run-time we really wanted to capture/see what's happening.

As you said 'log statements from journey script aren't captured and reported back' there's nothing that could be done about it. Despite that, are there any plans to include the log statements from journey script ?

Thanks,
Zaid

@ZaidMomin1 please try to open an enhancement request in Synthetics
and we will definitely try to consider it on our roadmap.

As you said 'log statements from journey script aren't captured and reported back' there's nothing that could be done about it. Despite that, are there any plans to include the log statements from journey script ?

If you must have to collect the output back using the current version, there could be two ways (or say workarounds):

  1. Create a webpage accessible in synthetics environment running the test, which accepts the data as URL Query string and print the data in its body. Generate the url when you have the data ready and as a separate journey step, visit that url. You can then use the step screenshot to view that data.
  2. Use the request object in journey to post the data to some endpoint (example).

There are currently no requests or roadmap to collect log statements or custom data points back from journeys. As already suggested, do create an enhancement request. Also, in case you use the above, do mention in the enhancement request if it were useful.

Thanks @shahzad31. As suggested opened an enhancement request.

Request Id: Enhancement: Capture and report back the log statements from journey script. · Issue #676 · elastic/synthetics · GitHub

Thanks for the workaround, @abdulz We shall think about it.

Your help and inputs are much appreciated.

Thanks,
Zaid

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