You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
% What needs to be done: Align serverless/stateful
9
+
After you’ve [created a synthetic monitor](../../../solutions/observability/apps/get-started.md), you’ll need to manage that monitor over time. This might include updating or permanently deleting an existing monitor.
10
10
11
-
% Use migrated content from existing pages that map to this page:
11
+
If you’re using {{project-monitors}}, you should also set up a workflow that uses [best practices for managing monitors effectively](../../../solutions/observability/apps/manage-monitors.md#synthetics-projects-best-practices) in a production environment.
% Internal links rely on the following IDs being on this page (e.g. as a heading ID, paragraph ID, etc):
14
+
## Update a monitor [manage-monitors-config]
17
15
18
-
$$$synthetics-projects-best-practices$$$
16
+
You can update a monitor’s configuration, for example, changing the interval at which the monitor runs a test.
17
+
18
+
You can also update the journey used in a browser monitor. For example, if you update the UI used in your application, you may want to update your journey’s selectors and assertions.
19
+
20
+
:::::::{tab-set}
21
+
22
+
::::::{tab-item} Project monitors
23
+
If you [set up the monitor using a Synthetic project](../../../solutions/observability/apps/create-monitors-with-project-monitors.md), you’ll update the monitor in the Synthetic project source and then `push` changes.
24
+
25
+
For lightweight monitors, make changes to the YAML file.
26
+
27
+
For browser monitors, you can update the configuration of one or more monitors:
28
+
29
+
* To update the configuration of an individual monitor, edit the journey directly in the JavaScript or TypeScript files, specifically the options in `monitor.use`.
30
+
* To update the configuration of *all* monitors in a Synthetic project, edit the [global synthetics configuration file](../../../solutions/observability/apps/configure-synthetics-projects.md#synthetics-configuration-monitor).
31
+
32
+
To update the journey that a browser monitor runs, edit the journey code directly and [test the updated journey locally](../../../solutions/observability/apps/write-synthetic-test.md#synthetics-test-locally) to make sure it’s valid.
33
+
34
+
After making changes to the monitors, run the [`push` command](../../../solutions/observability/apps/use-synthetics-cli.md#elastic-synthetics-push-command) to replace the existing monitors with new monitors using the updated configuration or journey code.
35
+
36
+
::::{note}
37
+
Updates are linked to a monitor’s `id`. To update a monitor you must keep its `id` the same.
38
+
::::
39
+
::::::
40
+
41
+
::::::{tab-item} Synthetics UI
42
+
If you [set up the monitor using the Synthetics UI](../../../solutions/observability/apps/create-monitors-in-synthetics-app.md), you can update the monitor configuration of both lightweight and browser monitors in the {{synthetics-app}}:
43
+
44
+
1. Go to **Management**.
45
+
2. Click the pencil icon next to the monitor you want to edit.
46
+
3. Update the *Monitor settings* as needed.
47
+
48
+
1. To update the journey used in a browser monitor, edit *Inline script*.
49
+
2. Make sure to click **Run test** to validate the new journey before updating the monitor.
50
+
51
+
4. Click **Update monitor**.
52
+
::::::
53
+
54
+
:::::::
55
+
56
+
## Delete a monitor [manage-monitors-delete]
57
+
58
+
Eventually you might want to delete a monitor altogether. For example, if the user journey you were validating no longer exists.
59
+
60
+
:::::::{tab-set}
61
+
62
+
::::::{tab-item} Project monitors
63
+
If you [set up the monitor using a Synthetics project](../../../solutions/observability/apps/create-monitors-with-project-monitors.md), you’ll delete the monitor from the project source and push changes.
64
+
65
+
For lightweight monitors, delete the monitor from the YAML file.
66
+
67
+
For browser monitors, delete the full journey from the JavaScript or TypeScript file.
68
+
69
+
Then, run the [`push` command](../../../solutions/observability/apps/use-synthetics-cli.md#elastic-synthetics-push-command). The monitor associated with that journey that existed will be deleted.
70
+
::::::
71
+
72
+
::::::{tab-item} Synthetics UI
73
+
If you [set up the monitor using the Synthetics UI](../../../solutions/observability/apps/create-monitors-in-synthetics-app.md), you can delete a lightweight or browser monitor in the Synthetics UI:
74
+
75
+
1. Go to **Management**.
76
+
2. Click the trash can icon next to the monitor you want to delete.
77
+
::::::
78
+
79
+
:::::::
80
+
Alternatively, you can temporarily disable a monitor by updating the monitor’s configuration in your journey’s code or in the Synthetics UI using the *Enabled* toggle.
81
+
82
+
83
+
## Implement best practices for Synthetics projects [synthetics-projects-best-practices]
84
+
85
+
::::{important}
86
+
This is only relevant to monitors created using projects.
87
+
::::
88
+
89
+
90
+
After you’ve [set up a project](../../../solutions/observability/apps/create-monitors-with-project-monitors.md), there are some best practices you can implement to manage the Synthetics project effectively.
91
+
92
+
93
+
### Use version control [synthetics-version-control]
94
+
95
+
First, it’s recommended that you version control all files in Git. If your Synthetics project is not already in a version controlled directory add it and push it to your Git host.
96
+
97
+
98
+
### Set up recommended workflow [synthetics-workflow]
99
+
100
+
While it can be convenient to run the `push` command directly from your workstation, especially when setting up a new Synthetics project, it is not recommended for production environments.
101
+
102
+
Instead, we recommended that you:
103
+
104
+
1. Develop and test changes locally.
105
+
2. Create a pull request for all config changes.
106
+
3. Have your CI service automatically verify the PR by running `npx @elastic/synthetics .`
107
+
108
+
Elastic’s synthetics runner can output results in a few different formats, including JSON and JUnit (the standard format supported by most CI platforms).
109
+
110
+
If any of your journeys fail, it will yield a non-zero exit code, which most CI systems pick up as a failure by default.
111
+
112
+
4. Have a human approve the pull request.
113
+
5. Merge the pull request.
114
+
6. Have your CI service automatically deploy the change by running `npx @elastic/synthetics push` after changes are merged.
115
+
116
+
The exact implementation details will depend on the CI system and Git host you use. You can reference the sample GitHub configuration file that is included in the `.github` directory when you create a new Synthetics project.
0 commit comments