Selenium Synthetics Setup

Setting up Selenium Synthetics to run with LogicMonitor involves installing the Selenium GRID where a LogicMonitor Collector can access it, and then updating the Collector with information about the Selenium GRID. This enables you to add a Selenium Synthetics Webcheck in your LogicMonitor portal for ingesting Synthetics data to LogicMonitor.

General Requirements

To set up Selenium Synthetics with LogicMonitor, you need the following:

  • Selenium GRID 4
    See Selenium’s Selenium Grid 4 documentation for more information.
  • LogicMonitor Collector 30.103 or later

Note: The Collector must be installed where is has access to the Selenium GRID. See Installing Collectors.

Selenium GRID Installation

The Selenium GRID is a smart proxy server that can execute Selenium Synthetics checks. It can operate as a standalone Hub or as a Hub with smaller Nodes to allow tests to run in parallel. During installation, you can specify the browser or environment you want to use for certain tests, and specify how large you would like each Node to be. You can install the Selenium GRID using the following methods:

  • Method 1: Install the Selenium GRID in a container

Note: This method allows you to install Selenium GRID using pre-configured images, or you can install Selenium GRID manually in a container and configure additional settings during the installation.

  • Method 2: Install the Selenium GRID locally

Method 1: Installing the Selenium GRID in a Container

You can install the Selenium GRID in a Docker container using the following pre-configured images available from the provider:

Alternatively, you can manually create a container and install Selenium GRID by creating a Hub with Nodes. The following example procedure demonstrates how to install Selenium GRID in a Docker container:

  1. Create a Docker network using the following command:
$ docker network create grid
  1. Use the following command to start a Selenium Hub:
$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.0.0
  1. Use the following command to start a Chrome Node using the environment variables:
$ docker run -d --net grid --name selenium-chrome -e SE_EVENT_BUS_HOST=selenium-hub  -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 selenium/node-chrome:4.0.0
  1. Use the following command to start an Edge Node:
$ docker run -d --net grid --name selenium-edge -e SE_EVENT_BUS_HOST=selenium-hub  -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 selenium/node-edge:93.0-edgedriver-93.0-grid-4.0.0

Optional Docker Configurations

You can use the following configuration options when setting up Selenium Grid as a Standalone through Docker. You can configure these options as environment variables when starting the Docker container. Some configuration options, like SE_NODE_MAX_SESSIONS and SE_NODE_SESSION_TIMEOUT, are given default values by the Docker container, and must be specifically overridden. Other configuration options can be added by altering the SE_OPTS environment variable, which is a catch-all for configuration options that do not have default values.

ConfigurationDetailsExample
Session Request TimeoutThis setting is configured when starting the Standalone Docker container. The session request timeout determines how many seconds a request waits in the session queue for an available node before timing out. Default is 300 seconds. Retries are done every five seconds. If the session request timeout is set to zero, requests wait in the queue indefinitely.
It is possible to override those values through environment variables in the Hub and the SessionQueue (SE_SESSION_REQUEST_TIMEOUT and SE_SESSION_RETRY_INTERVAL). For example, a timeout of 500 seconds would be SE_SESSION_REQUEST_TIMEOUT=500 and a retry interval of 2 seconds would be SE_SESSION_RETRY_INTERVAL=2.
This option can be set by passing –session-request-timeout as an additional option into the SE_OPTS environment variable when starting the docker Hub container.
$ docker run -d -p 4444:4444 -e SE_OPTS='--session-request-timeout 20' selenium/standalone-chrome:4.0
Max SessionsThis setting is configured when starting the Standalone Docker container. The max sessions setting determines the amount of available browser sessions that can handle a request. Changing this setting to more than the number of available processors may lead to sessions failing because of insufficient resources. In both the Chrome and Edge Standalone Docker containers, the max sessions setting is given a default value of 1. This setting can be set by overriding the SE_NODE_MAX_SESSIONS environment variable when starting the Standalone docker container.$ docker run -d -p 4444:4444 -e SE_NODE_MAX_SESSIONS=4 selenium/standalone-edge:4.0
Node Session TimeoutAfter session slot has been taken by a test request, this setting controls how long the session is allowed to remain idle without any activity before the slot is freed. In both the Chrome and Edge Standalone Docker containers, the node session timeout setting is given a default value of 300 seconds. This setting can be set by overriding the SE_NODE_SESSION_TIMEOUT environment variable when starting the Node docker container.
The Selenium Side Runner has a dependency on the NodeJS; therefore, you must install Node 8 or 10 before installing a side runner.
$ docker run -d -p 4444:4444 -e SE_NODE_SESSION_TIMEOUT=10 selenium/standalone-edge:4.0

If you make configuration changes to your Docker container, you must restart the container by identifying the container ID and executing a start command similar to the following:

#find the container id’s (not running)

$ docker ps -a

CONTAINER ID   IMAGE                                                                         COMMAND                  CREATED       STATUS                       PORTS                                                           NAMES

75bca4385216   selenium/node-edge:93.0-edgedriver-93.0-grid-4.0.0-rc-1-prerelease-20210823   "/opt/bin/entry_poin…"   10 days ago   Exited (255) 6 minutes ago   5900/tcp                                                        selenium-edge

77615a7ada1c   selenium/node-chrome:4.0                                                    "/opt/bin/entry_poin…"   10 days ago   Exited (255) 6 minutes ago   5900/tcp                                                        selenium-chrome

b838fe090610   selenium/hub:4.0                                   "/opt/bin/entry_poin…"   10 days ago   Exited (255) 6 minutes ago   0.0.0.0:4442-4444->4442-4444/tcp, :::4442-4444->4442-4444/tcp   selenium-hub

#start the containers

$ docker start 75bca4385216 77615a7ada1c b838fe090610

75bca4385216

77615a7ada1c

b838fe090610

#now they’re running

$ docker ps

CONTAINER ID   IMAGE                                                                         COMMAND                  CREATED       STATUS          PORTS                                                           NAMES

75bca4385216   selenium/node-edge:93.0-edgedriver-93.0-grid-4.0.0-rc-1-prerelease-20210823   "/opt/bin/entry_poin…"   10 days ago   Up 14 seconds   5900/tcp                                                        selenium-edge

77615a7ada1c   selenium/node-chrome:4.0                                                    "/opt/bin/entry_poin…"   10 days ago   Up 13 seconds   5900/tcp                                                        selenium-chrome

b838fe090610   selenium/hub:4.0 "/opt/bin/entry_poin…"   10 days ago   Up 9 seconds    0.0.0.0:4442-4444->4442-4444/tcp, :::4442-4444->4442-4444/tcp   selenium-hub

Method 2: Installing the Selenium GRID Locally

You can install the Selenium GRID (both Hub and Node included) as a standalone installation, or you can install the Hub and Nodes as a separate installation.

Requirements

To install the Selenium GRID locally, you need the following:

  • Selenium Server Standalone package jar
    This includes the Selenium Hub, WebDriver, and RC needed to run the GRID.
  • Java installed and added to the environment variables
  • The browser installed that you want to test
  • The appropriate drivers for the test browser downloaded and added to PATH

Standalone Installation

To install the Selenium GRID as a standalone, execute the following command to start the Selenium GRID:

java -jar selenium-server-standalone-<version>.jar -standalone

Note: This command starts a standalone Selenium GRID using port 4444 by default. You can use an alternate port using the following command: java -jar selenium-server-standalone-.jar -standalone -host

When Selenium starts, it provides the URI for accessing the GRID. Navigate to the URI in the browser to view the Selenium console and the available hubs and nodes.

Separate Installation

To install the Selenium server Hub, execute the following command:

java -jar selenium-server-standalone-<version>.jar -role hub

To start a Node associated with the Hub, execute the following command:

java -jar selenium-server-standalone-<version>.jar -role node -hub https://<uri>:<port number>/grid/register

Note: The URI is the URI of the Selenium server Hub (usually localhost) and the port number is 4444 by default, unless specified otherwise during setup.

Updating the LogicMonitor Collector for Synthetics

The LogicMonitor Collector uses the agent.conf configuration file and its assigned properties in setup. For a Collector to run Selenium Synthetics checks, the URL where the Collector is able to access the grid must be provided as a property before it is selectable in the LogicMonitor portal to assign a Selenium Synthetics Webcheck.

  1. Navigate to the Collector that has access to the Selenium GRID in Settings > Collectors, and select the Manage icon.
  2. From the Support dropdown menu, select “Collector Configuration”.
  1. Toggle the Edit agent.conf manually switch, and add the Selenium GRID URL to the synthetics.selenium.environment.grid.url property.
  1. Click Save and Restart.

The Collector restarts with the Selenium Synthetics Webcheck assigned to it.

In This Article