Skip to content

Conversation

@rseldner
Copy link
Contributor

Adding instructions for using environment variables in synthetics run from Private Locations

…e Locations

Added instructions for using environment variables in synthetics run from Private Locations
Clarified the scope of variable accessibility in Private Location.
Clarified the source of the environment variable in the script.
@rseldner rseldner added documentation Improvements or additions to documentation Team:Obs Issues owned by the Observability Docs Team labels Nov 18, 2025
@rseldner rseldner marked this pull request as ready for review November 18, 2025 15:35
@rseldner rseldner requested a review from a team as a code owner November 18, 2025 15:35
@github-actions
Copy link

github-actions bot commented Nov 18, 2025

🔍 Preview links for changed docs

Clarified the use of environment variables with Private Locations and moved warning above the example.
Copy link
Contributor

@benironside benironside left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some initial edits, but defer to Mike's expertise here.


::::

### Use environment variables in Synthetics Projects
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Use environment variables in Synthetics Projects
### Use environment variables in synthetics projects

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this suggestion is correct. The rest of the page is consistent in the usage of "Synthetics project"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, Synthetics project seems to be consistent through the docs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was writing Synthetics docs, I would use Synthetics when referring to the Elastic Synthetics product and synthetic when using it as an adjective like synthetic monitors. In this case, I would say it makes more sense to use "Synthetics project" because a "project" is an Elastic-specific concept unlike "monitor", which is generic concept in the world of synthetic monitoring.

### Use environment variables with Private Locations

If you are using Kibana-managed monitors and running them on a Private Location, you can inject environment variables directly into the agent's runtime environment.
This method allows you to keep sensitive values out of the Kibana UI. Instead, it requires access to the infrastructure hosting the Elastic Agent.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This method allows you to keep sensitive values out of the Kibana UI. Instead, it requires access to the infrastructure hosting the Elastic Agent.
This method allows you to keep sensitive values out of the {{kib}} UI. Instead, it stores those values on the infrastructure hosting the {{agent}}.

This method allows you to keep sensitive values out of the Kibana UI. Instead, it requires access to the infrastructure hosting the Elastic Agent.

::::{warning}
These variables will be accessible to **all** monitors running on **this specific** Private Location.
Copy link
Contributor

@benironside benironside Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These variables will be accessible to **all** monitors running on **this specific** Private Location.
These variables are accessible to all monitors running on this specific Private Location.

Comment on lines +164 to +165
#### 1. Pass variables to the Private Location
When starting your Private Location (Elastic Agent) using Docker, use the `--env` flag to pass your variables.
Copy link
Contributor

@benironside benironside Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### 1. Pass variables to the Private Location
When starting your Private Location (Elastic Agent) using Docker, use the `--env` flag to pass your variables.
#### 1. Pass variables to the Private Location
When starting your Private Location ({{agent}}) using Docker, use the `--env` flag to pass your variables.

```

#### 2. Reference variables in the inline script
In the Synthetics Monitor editor in Kibana, you can now access these variables using `process.env`.
Copy link
Contributor

@benironside benironside Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In the Synthetics Monitor editor in Kibana, you can now access these variables using `process.env`.
In the Synthetics **Monitors** editor in {{kib}}, you can now access these variables using `process.env`.


If you are managing monitors with a Synthetics project, you can use environment variables in your `synthetics.config.ts` or `synthetics.config.js` file.

The example below uses `process.env.MY_URL` to reference a variable named `MY_URL` defined in the environment and assigns its value to a param. That param can then be used in both lightweight and browser monitors that are managed in the Synthetics project:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdbirnstiehl is there a good reason to use param here instead of parameter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now see the whole page uses params. Not saying it needs to change. Just curious about it.

Copy link
Contributor

@mdbirnstiehl mdbirnstiehl Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, the setting in Kibana is Global parameters, but you pass --params CLI argument, so I think it would make sense to say either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation Team:Obs Issues owned by the Observability Docs Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants