# Parameters for use in Lightweight and Journey/Browser Monitors

**URL:** <https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716>\
**Category:** Synthetics\
**Created:** [June 22, 2023, 5:18pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716 "2023-06-22T17:18:20Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Berg1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben_berg1/32/78116_2.png) [@Ben\_Berg1](https://discuss.elastic.co/u/Ben_Berg1)\
**Post date:** [June 22, 2023, 5:18pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/1 "2023-06-22T17:18:20Z")

</div>

I am using the new synthetics approach using a Typescript project. All docs indicate that parameters/secrets can be used in both lightweight and journey/browser code. I am not able to do so can do either or.  
Docs indicate having this in the synthetics.config.ts:

```auto
export default (env) => {
  let my_url = "http://localhost:8080";
  if (env === "production") {
    my_url = "https://elastic.github.io/synthetics-demo/"
  }
  return {
    params: {
      my_url,
    },
  };
};

```

But the generated project creates something like this:  
export default env =\> {  
const config: SyntheticsConfig = {

Anyone using lightweight and journey monitors using the same parameters? What am I missing?

---

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [June 23, 2023, 7:22am UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/2 "2023-06-23T07:22:33Z")

</div>

Hello Ben,

I think both is correct, it is just a different style of writing. But I agree, the documentation and generated code should allign.

Personally, I prefer the style that is generated automatically over the docs example.

Best regards  
Wolfram

---

<div class="post-metadata">

**Author:** ![shahzad31](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shahzad31/32/51637_2.png) [@shahzad31](https://discuss.elastic.co/u/shahzad31)\
**Post date:** [June 23, 2023, 7:52am UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/3 "2023-06-23T07:52:30Z")

</div>

Hello @Ben_Berg1 we will certainly discuss the feedback regarding the docs.

How are you trying params in lightweight monitors?

I just tried this syntax and it works for me

```auto

heartbeat.monitors:
- type: http
  name: Todos Lightweight
  id: todos-lightweight
  enabled: true
  urls: "${devUrl}"
  schedule: '@every 3m'
  timeout: 16s
  alert.status.enabled: true

```

and config file as

```auto

export default env => {
  const config: SyntheticsConfig = {
    params: {
      devUrl: 'https://elastic.github.io/synthetics-demo/',
    },

   // rest of the config 

  return config;
};

```

---

<div class="post-metadata">

**Author:** ![Ben\_Berg1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben_berg1/32/78116_2.png) [@Ben\_Berg1](https://discuss.elastic.co/u/Ben_Berg1)\
**Post date:** [June 23, 2023, 1:00pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/4 "2023-06-23T13:00:26Z")

</div>

Thanks for the reply.  
When i push to elastic the parameter is not replaced for lightweight but is for synthetics, here is my monitor code:

```auto
heartbeat.monitors:
- type: http
  name: Manager Login ${environment}
  id: "manager-login-${environment}"
  enabled: true
  urls: "https://${baseUrl}/manager/"
  schedule: '@every 5m'
  timeout: 16s
  alert.status.enabled: false

```

And my config file:

```auto
import type { SyntheticsConfig } from '@elastic/synthetics';
import monitoringConfig from './config.json';

export default env => {
  const config: SyntheticsConfig = {
    params: {
      baseUrl: monitoringConfig.baseUrl,
      managerLoginEmail: monitoringConfig.managerLoginEmail,
      managerLoginPassword: monitoringConfig.managerLoginPassword,
      environment: monitoringConfig.environment
    },
    playwrightOptions: {
      ignoreHTTPSErrors: false
    },
    /**
     * Configure global monitor settings
     */
    monitor: {
      schedule: 10,
      locations: [],
      privateLocations: [monitoringConfig.monitorPrivateLocations]
    },
    /**
     * Project monitors settings
     */
    project: {
      id: `${monitoringConfig.applicationName}-${monitoringConfig.environment}`,
      url: monitoringConfig.elasticCloudUrl,
      space: monitoringConfig.spaceName,
    },
  }
  const params = {
    baseUrl: monitoringConfig.baseUrl,
    managerLoginEmail: monitoringConfig.managerLoginEmail,
    managerLoginPassword: monitoringConfig.managerLoginPassword,
    environment: monitoringConfig.environment

  };
  return config;
};

```

config.json is a simple JSON object with key/values - have a local version and is transformed in CI/CD for different environments and works as expected for synthetics. Note we are still on 8.7.1 so wonder if a bug that we should upgrade? Also running from a private location that is the correct docker image - synthetic monitor runs fine.  
Here is a screenshot of the lightweight monitor deployed to elastic:

 ![Screenshot 2023-06-23 at 8.58.12 AM](https://us1.discourse-cdn.com/elastic/original/3X/8/b/8b00ea5c7b6fcb5318a25238597c8c0eb222476d.png)  
and the journey/synthetic deployed to elastic:  
 ![Screenshot 2023-06-23 at 8.59.54 AM](https://us1.discourse-cdn.com/elastic/original/3X/0/3/03c04b6d5f1f7fb6cd965231cec853049727772d.png)  
Thanks again for the reply/review/comments/validation attempts.  
Ben

---

<div class="post-metadata">

**Author:** ![shahzad31](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shahzad31/32/51637_2.png) [@shahzad31](https://discuss.elastic.co/u/shahzad31)\
**Post date:** [June 23, 2023, 1:52pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/5 "2023-06-23T13:52:52Z")

</div>

@Ben_Berg1 lightweight params support was added in [8.8.0](https://github.com/elastic/kibana/pull/148634) so yeah you will have to upgrade 🙂

---

<div class="post-metadata">

**Author:** ![Ben\_Berg1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben_berg1/32/78116_2.png) [@Ben\_Berg1](https://discuss.elastic.co/u/Ben_Berg1)\
**Post date:** [June 23, 2023, 2:11pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/6 "2023-06-23T14:11:47Z")

</div>

Awesome - thanks for identifying. Will give that a shot. Nice work on this feature - will be a nice win to consolidate heartbeat, synthetics, etc.

---

<div class="post-metadata">

**Author:** ![Ben\_Berg1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben_berg1/32/78116_2.png) [@Ben\_Berg1](https://discuss.elastic.co/u/Ben_Berg1)\
**Post date:** [June 23, 2023, 4:08pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/7 "2023-06-23T16:08:28Z")

</div>

Upgraded to 8.8.1 and deleted and pushed from project again and still not seeing parameters being replaced.

 ![Screenshot 2023-06-23 at 12.06.09 PM](https://us1.discourse-cdn.com/elastic/original/3X/2/4/246f7dadf6a95078b2689388aafa61b57669a80d.png)  
Updated the fleet agent to 8.8.1 as well.  
Anything else I can check? This is blocking hard now as heartbeat monitors appear to be depreciated in 8.8.1 as i not longer see those in uptime.

---

<div class="post-metadata">

**Author:** ![shahzad31](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shahzad31/32/51637_2.png) [@shahzad31](https://discuss.elastic.co/u/shahzad31)\
**Post date:** [June 23, 2023, 4:59pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/8 "2023-06-23T16:59:14Z")

</div>

@Ben_Berg1 can you take a look at the actual document that you are receiving from heartbeat?

We actually discussed this internally and in the UI we don't display the parsed value which i can understand is bit confusing. I will create an issue to discuss this and whether UI should show the parsed value.

You can take a look at the actual result you are receiving in discover by creating a data view with `synthetics-*` pattern.

Another issue that i can think of is migration. Change a config a bit and push the monitor again.

or you can simply test a new monitor.

let me know if you need help with checking data in discover.

Regards

---

<div class="post-metadata">

**Author:** ![Ben\_Berg1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben_berg1/32/78116_2.png) [@Ben\_Berg1](https://discuss.elastic.co/u/Ben_Berg1)\
**Post date:** [June 23, 2023, 5:17pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/9 "2023-06-23T17:17:18Z")

</div>

Thanks @shahzad31 - there was no data in the synthetics index but I have it working now. It appears the id field for the heartbeat.yml cannot contain parameters. Once i removed the parameter there it did go from pending to running the monitor.  
Good to know on the UI. Be interested in hearing others thoughts there, I could see either way being useful. I did notice in the list view the name isn't parsed but within the monitor view the values appear to be parsed which i think is valuable.

I think i will just move some of the metadata i was trying to put in the id to separate and put in tags. I won't have same ID in any monitors in the same project as each environment has own project ID.

On a similar but separate note, can environment variables be defined outside of the config and used by the synthetics? I am using AWS and would like some of the data to come from environment variables defined on the ECS task (env vars for the docker agent) to be used. Is this a good approach? Thinking on how to keep some secure values out of the parameters defined in monitor and we use AWS secrets manager/docker environment variables currently in heartbeat monitors. Assuming it will work same way but thought I'd ask before testing/validating.  
Thanks again for your help.

---

<div class="post-metadata">

**Author:** ![Ben\_Berg1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben_berg1/32/78116_2.png) [@Ben\_Berg1](https://discuss.elastic.co/u/Ben_Berg1)\
**Post date:** [June 23, 2023, 5:35pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/10 "2023-06-23T17:35:51Z")

</div>

Appears the monitor.tags is not working as documented here - i would expect both synthetic and lightweight monitors to be tagged with values.

```auto
 monitor: {
      schedule: 15,
      locations: [],
      privateLocations: [monitoringConfig.monitorPrivateLocations],
      tags: [monitoringConfig.environment,`test`]
    },

```

If i put in the journey it does show up:

```auto
journey(`Buildium Manager Login`, async ({ page, params }) => {

  monitor.use({
    id: `${params.environment} - buildium-manager-login`,
    tags: [params.environment]
  });

```

and in lightweight it works with hardcoded values but parameters are not parsed:

```auto
heartbeat.monitors:
- type: http
  name: "Manager Login Page ${environment}"
  id: "manager-login"
  enabled: true
  urls: "https://${baseUrl}/manager/"
  schedule: '@every 5m'
  timeout: 25s
  alert.status.enabled: false
  tags: 
    - ${environment}

```

Any know issues around tags?

---

<div class="post-metadata">

**Author:** ![shahzad31](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shahzad31/32/51637_2.png) [@shahzad31](https://discuss.elastic.co/u/shahzad31)\
**Post date:** [June 23, 2023, 5:39pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/11 "2023-06-23T17:39:52Z")

</div>

i have created an issue for id field params

> <https://github.com/elastic/synthetics/issues/793>
>
> Currently user can configure a lightweight monitor with params.
> 
> This also all…ow params in id field. We should validate this and don't allow params in id field. Since this will have an issue with how results are displayed against a monitor in UI 
> 
> \`\`\`
> heartbeat.monitors:
> \- type: http
> name: Manager Login ${environment}
> id: "manager-login-${environment}" \<--- this should not be allowed 
> enabled: true
> urls: "https://${baseUrl}/manager/"
> schedule: '@every 5m'
> timeout: 16s
> alert.status.enabled: false
> \`\`\`

I will take a look at tags and env vars question and will respond.

---

<div class="post-metadata">

**Author:** ![vigneshshanmugam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vigneshshanmugam/32/40324_2.png) [@vigneshshanmugam](https://discuss.elastic.co/u/vigneshshanmugam)\
**Post date:** [June 23, 2023, 6:39pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/12 "2023-06-23T18:39:03Z")

</div>

Hi @Ben_Berg1,

The monitor tags not getting applied to all pushed monitors is already tracked in this [issue](https://github.com/elastic/synthetics/issues/780) where we are consolidating how tags should behave similar to other parameters like `locations`.

Also, I would like to understand more about your use case on why you would want to tie in your monitor name with environment when the URL for the monitor is going to be the same in the latest test.

Thanks,  
Vignesh

---

<div class="post-metadata">

**Author:** ![Ben\_Berg1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben_berg1/32/78116_2.png) [@Ben\_Berg1](https://discuss.elastic.co/u/Ben_Berg1)\
**Post date:** [June 26, 2023, 3:46pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/13 "2023-06-26T15:46:05Z")

</div>

Thanks for the link @vigneshshanmugam .  
For using the environment in monitor name it is to be able to see what environment the synthetic is running on easily. We have 2 elastic cloud deployments currently, one for local, dev, and staging and one for prod.  
We deploy monitors for dev and staging through CI/CD and the urls would be for different environments. Local is used for local testing of synthetics and have basically same configuration as dev but aren't super critical expect during development of synthetic monitors.  
We could use tags likely just as well to filter and seems filtering by project also works - just trying to find a fool proof way for consumers of the monitor data to know what environment they are working with and the environment name in the name seems like a very hard thing to miss!  
Thanks again!  
Ben

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 24, 2023, 3:47pm UTC](https://discuss.elastic.co/t/parameters-for-use-in-lightweight-and-journey-browser-monitors/336716/14 "2023-07-24T15:47:05Z")

</div>

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