Skip to content

Commit

Permalink
fix(synthetics): editing the language for a new job manager doc
Browse files Browse the repository at this point in the history
  • Loading branch information
homelessbirds committed Mar 25, 2024
1 parent ac1e8d9 commit da4bf76
Showing 1 changed file with 82 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,134 +18,134 @@ Learn how to configure your [synthetics job manager](/docs/synthetics/synthetic-
As a note, New Relic is not liable for any modifications you make to the synthetics job manager files.

You can do the following to customize your private synthetics job manager:

* Provide [user-defined variables](#user-defined-vars) in your configuration.
* Update other [environment-variables](#environment-variables) when launching your synthetics job manager.

## User-defined variables for scripted monitors [#user-defined-vars]
Private synthetics job managers let you configure environment variables for use in scripted monitors. These variables are managed locally on the SJM and can be accessed via $env.USER_DEFINED_VARIABLES. There are two ways to set user-defined variables: by mounting a JSON file or by supplying an environment variable to the SJM on launch. If both are provided, the SJM will use values provided from the environment only.
Private synthetics job managers let you configure environment variables for scripted monitors. These variables are managed locally on the SJM and can be accessed via $env.USER_DEFINED_VARIABLES. There are two ways to set user-defined variables: mounting a JSON file or supplying an environment variable to the SJM on launch. If both are provided, the SJM will only use values provided by the environment.

<CollapserGroup>
<Collapser
id="user-file-example"
title="Mounting JSON file"
>
The user may create a JSON-formatted file and mount the volume the where the file is located to a specified target path in the SJM container.

The file must have read permissions and contain a JSON-formatted map. Example user-defined variables file:

```
{
"KEY": "VALUE",
"user_name": "MINION",
"my_password": "PASSW0RD123",
"my_URL": "https://newrelic.com/",
"ETC": "ETC"
}
```

Place the file in the source directory on the host. The SJM is expecting the file name to be user_defined_variables.json

Docker example:

The expected target directory is: `/var/lib/newrelic/synthetics/variables/`
<Collapser
id="user-file-example"
title="Mounting JSON file"
>
The user may create a JSON-formatted file and mount the volume where the file is located to a specified target path in the SJM container.

The file must have read permissions and contain a JSON-formatted map. Example user-defined variables file:

```
{
"KEY": "VALUE",
"user_name": "MINION",
"my_password": "PASSW0RD123",
"my_URL": "https://newrelic.com/",
"ETC": "ETC"
}
```

Place the file in the source directory on the host. The SJM is expecting the file name to be user_defined_variables.json

Docker example:

The expected target directory is: `/var/lib/newrelic/synthetics/variables/`

```
docker run ... -v /variables:/var/lib/newrelic/synthetics/variables:rw ...
```

Kubernetes example:

The user has two options when providing a file to the SJM pod in Kubernetes. They may:
1. pass in a local file.
2. provide a PersistentVolume that includes the user_defined_variables.json.

### Pass in a local file
This option creates a ConfigMap Kubernetes resource and mounts that to the SJM pod.

```
docker run ... -v /variables:/var/lib/newrelic/synthetics/variables:rw ...
```

Kubernetes example:

The user has 2 options when providing a file to the SJM pod in Kubernetes. They may:
1. pass in a local file.
2. provide a PersistentVolume that includes the user_defined_variables.json.

### Pass in a local file
This option creates a ConfigMap Kubernetes resource and mounts that to the SJM pod.
```
helm install newrelic/synthetics-job-manager ... --set-file "synthetics.userDefinedVariables.userDefinedFile=[local-path]/user_defined_variables.json" ...
```

### Mount a PersistentVolume
This option requires the user to provide a PersistentVolume that includes the user_defined_variables.json file or a PersistentVolumeClaim to the same. For more details on helm chart installation using a PersistentVolume, follow the instructions at [permanent data storage](/docs/synthetics/synthetic-monitoring/private-locations/job-manager-configuration#permanent-data-storage).

Once the user has prepared a PersistentVolume as described below, launch the SJM, setting the path where the user_defined_variables.json file is located and setting any other `synthetics.persistence` variables as necessary.
```
helm install newrelic/synthetics-job-manger ... --set synthetics.userDefinedVariables.userDefinedPath="variables"
```
</Collapser>

<Collapser
id="passing-env-var"
title="Passing as an environment variable"
>
The variables may be passed to their respective container system via environment variable.
```
helm install newrelic/synthetics-job-manager ... --set-file "synthetics.userDefinedVariables.userDefinedFile=[local-path]/user_defined_variables.json" ...
```

Docker example:
### Mount a PersistentVolume
This option requires the user to provide a PersistentVolume that includes the user_defined_variables.json file or a PersistentVolumeClaim to the same. For more details on helm chart installation using a PersistentVolume, follow the instructions at [permanent data storage](/docs/synthetics/synthetic-monitoring/private-locations/job-manager-configuration#permanent-data-storage).

Once the user has prepared a PersistentVolume as described below, launch the SJM, setting the path where the user_defined_variables.json file is located and setting any other `synthetics.persistence` variables as necessary.

Use the `-e` flag to set up an environment variable named `USER_DEFINED_VARIABLES` and give it a value of a JSON formatted map string.
```
helm install newrelic/synthetics-job-manger ... --set synthetics.userDefinedVariables.userDefinedPath="variables"
```
</Collapser>

```
docker run ... -e USER_DEFINED_VARIABLES='{"key":"value","name":"sjm"}' ...
```
<Collapser
id="passing-env-var"
title="Passing as an environment variable"
>
The variables may be passed to their respective container system via environment variable.
Docker example:

Kubernetes example:
Use the `--set-literal` flag to pass in the JSON formatted string.
Use the `-e` flag to set up an environment variable named `USER_DEFINED_VARIABLES` and give it the value of a JSON formatted map string.

```
helm install newrelic/synthetics-job-manager ... --set-literal synthetics.userDefinedVariables.userDefinedJson='{"key":"value","name":"sjm"}' ...
```
```
docker run ... -e USER_DEFINED_VARIABLES='{"key":"value","name":"sjm"}' ...
```

</Collapser>
Kubernetes example:
Use the `--set-literal` flag to pass in the JSON formatted string.
```
helm install newrelic/synthetics-job-manager ... --set-literal synthetics.userDefinedVariables.userDefinedJson='{"key":"value","name":"sjm"}' ...
```
</Collapser>
</CollapserGroup>

### Accessing user-defined environment variables from scripts [#env-vars-scripts]

To reference a configured user-defined environment variable, use the reserved `$env.USER_DEFINED_VARIABLES` followed by the name of a given variable with dot notation.

For example, `$env.USER_DEFINED_VARIABLES.MY_VARIABLE`

<Callout variant="caution">
User-defined environment variables are not sanitized from logs. For sensitive information, consider using the [secure credentials](/docs/synthetics/new-relic-synthetics/using-monitors/secure-credentials-store-credentials-information-scripted-browsers) feature.
User-defined environment variables are not sanitized from logs. Consider using the [secure credentials](/docs/synthetics/new-relic-synthetics/using-monitors/secure-credentials-store-credentials-information-scripted-browsers) feature for sensitive information.
</Callout>

## Permanent data storage [#permanent-data-storage]

Users may want to use permanent data storage in order to provide the `user_defined_variables.json` file or to support custom node modules (not yet available to private Synthetics Job Managers).
Users may want to use permanent data storage to provide the `user_defined_variables.json` file or support custom node modules (not yet available to private Synthetics Job Managers).

### Docker

To set permanent data storage on Docker:

1. Create a directory on the host where you are launching the Job Manager. This is your source directory.
2. Launch the Job Manager, mounting the source directory to the target directory `/var/lib/newrelic/synthetics`.


Example:

```
docker run ... -v /sjm-volume:/var/lib/newrelic/synthetics:rw ...
docker run ... -v /sjm-volume:/var/lib/newrelic/synthetics:rw ...
```

### Kubernetes

To set permanent data storage on Kubernetes, the user has 2 options:
To set permanent data storage on Kubernetes, the user has two options:

1. Provide an existing PersistentVolumeClaim (PVC) for an existing PersistentVolume (PV), setting the `synthetics.persistence.existingClaimName` configuration value.

Example:

```
helm install ... --set synthetics.persistence.existingClaimName=sjm-claim ...
helm install ... --set synthetics.persistence.existingClaimName=sjm-claim ...
```

2. Provide an existing PersistentVolume (PV) name, setting the `synthetics.persistence.existingVolumeName` configuration value. Helm will generate a PVC for the user.

The user may optionally set the following values as well:
- `synthetics.persistence.storageClass`: the storage class of the existing PV. If not provided, Kubernetes will use the default storage class.
- `synthetics.persistence.size`: the size to be used for the claim. If not set, the default is currently 2Gi.
- `synthetics.persistence.size`: the size for the claim. If not set, the default is currently 2Gi.

```
helm install ... --set synthetics.persistence.existingVolumeName=sjm-volume --set synthetics.persistence.storageClass=standard ...
helm install ... --set synthetics.persistence.existingVolumeName=sjm-volume --set synthetics.persistence.storageClass=standard ...
```

## Environment variables [#environment-variables]
Expand Down

0 comments on commit da4bf76

Please sign in to comment.