Screenshot Microservice Prerequisites
Before you can install and use the screenshot microservice ensure your environment meets the prerequisites for this service. DCD-224 Start - Remove this heading, move content downBrowser Requirements
The screenshot microservice uses headless Google Chrome. Chrome-based screenshots include the entire dashboard and can be exported in PNG or PDF formats. DCD-224 New/incorporated Content EndMemory Configuration Considerations
If your use of Self-Service Analytics includes scheduling reports, you may need to update this memory setting. The default memory configuration is suitable for handling up to 10 concurrent reports (different reports scheduled for the same time). If you need to schedule more concurrent reports, increase the memory allocation to about one gigabyte (1GB) more for every 15 concurrent reports. See Configure Memory Settings.Thread Count Considerations
If your use of Self-Service Analytics includes scheduling reports, update the screenshot microservicepool.thread.size setting so it is greater than the number of concurrent reports (see screenshot-service.properties Properties). This setting controls the thread count for screenshot microservice requests.
Obtain the Software
Before you can install the screenshot microservice, contact Self-Service Analytics Technical Support to obtain a download link for the screenshot microservice installation software. Be sure you specify the operating system you are using so the appropriate software is provided.Install the Screenshot Microservice
Install the Screenshot microservice- Download the Screenshot microservice package using the link provided by Self-Service Analytics Technical Support.
-
Install the software using the appropriate command below, modifying
<filename>to match the installation package provided by Self-Service Analytics Technical Support: In CentOS environments:In Ubuntu environments: -
DCD-224 replace this step 3
Install the correct version of ChromeDriver. Refer to the ChromeDriver documentation for more information.
Run the script
install-dependencies.sh(located in the/opt/zoomdata/docs/screenshot-service/installation directory) or enter the following commands on the command line (for all operating systems): -
Optionally, modify the
zoomdata.propertiesfile to enable and set up the Screenshot microservice. In addition to enabling the Screenshot microservice, you can also set the time period for capturing screenshots of your visuals to be displayed on the library page.- To create screenshots in the background, set the
screenshot.daemon.enabledproperty totrue: - Specify which types of screenshots you want to enable. Set the
screenshots.dashboards.enabledproperty totrueif you want to enable capturing and displaying the screenshots for the dashboards.
screenshot.daemon.enabledandscreenshots.dashboards.enabledproperties are enabled, screenshots are created automatically when a dashboard is created or updated and at the rate specified by thescreenshot.daemon.schedule.rateproperty (set in the next step of this procedure). If either thescreenshot.daemon.enabledorscreenshots.dashboards.enabledproperties is disabled, screenshots are not created automatically, but you can still create a screenshot manually using the API. - To create screenshots in the background, set the
-
Specify the frequency at which the screenshots are refreshed by configuring the property
screenshot.daemon.schedule.rate=<n>hinzoomdata.properties. The default frequency is every 24 hours, but you can set your own frequency (in hours) by replacing<n>with your desired frequency. -
Enable and start the Screenshot microservice. If you are using
systemctl, run the following commands:If you are not usingsystemctl, adjust these commands accordingly. Additional information on restarting microservices is provided in Restart Microservices. -
Watch the
/opt/zoomdata/logs/screenshot-service.logfile. The microservice is running successfully when the log displays a line similar to this:
Test the Screenshot Microservice
Test the Screenshot microservice-
Open a web browser to Self-Service Analytics. Obtain the ID for a dashboard to use for testing. Log in to Self-Service Analytics and open a dashboard. On the browser address bar copy the portion of the URL after the + sign. In the following example, you would copy
5ad8d1fa60b2894b38f0933b: -
Use Postman or cURL to issue a PUT request to Self-Service Analytics to request a screenshot of the dashboard in PNG format. In the following example, replace <username> with your user name, <password> with your password, <server> with your server IP address or name, <port> with your port number, and <dash-id> with the dashboard ID you obtained in the previous step.
-
If the
test.pngfile is created successfully, the Screenshot microservice is operating correctly.
Use the Screenshot Microservice API
The Screenshot microservice exposes a single REST endpoint, /api/screenshots. Issue a GET request to this endpoint to generate a screenshot of any URL the microservice can reach, in either PNG or PDF format. Use this endpoint when you want to generate a screenshot on demand rather than relying on the background screenshot daemon. The microservice listens on port 8083 by default. For the full list of ports, see Default Port Reference.Requests to port 8083 are not authenticated. Restrict access to this port to hosts inside your deployment and do not expose it externally. See Configure the Firewall.
Request a Screenshot
Specify the output format using theAccept request header:
- For PNG, set
Accepttoimage/png. - For PDF, set
Accepttoapplication/pdf.
uri query parameter.
Request a PNG screenshot
uri value. For the format of that address and how to obtain a dashboard ID, see Test the Screenshot Microservice.
Set a Request Timeout
Both formats accept atimeoutSeconds parameter. This sets how long the microservice waits for the page to render before it abandons the request. When you omit this parameter, the microservice uses the default from its properties file. See screenshot-service.properties Properties.
Request a PNG screenshot with a custom timeout
PNG Parameters
By default, the microservice does not constrain or resize the image it produces. Control the output for an individual request using the following optional query parameters. All values are integers, in pixels.
You can also set defaults for these values in the properties file using the screenshot.default.image prefix, for example
screenshot.default.image.width=850. See screenshot-service.properties Properties.
How Resizing and Cropping Interact
The microservice resizes first and crops second. Three rules govern the result:- If you supply both
widthandheight, the image is resized to exactly those dimensions. The aspect ratio is ignored, so the image stretches if the requested proportions differ from the original. - If you supply only one dimension, such as
width, the other is scaled to preserve the original aspect ratio. maxWidthandmaxHeightcrop the image only when the resized image is wider or taller than the value you set.
- The microservice captures the page at the default window size of 1920 x 1080 pixels.
- Because
widthis 500 and no height was given, the image is resized to 500 x 260, preserving the original aspect ratio. - Because
maxHeightis 100 and the resized height of 260 exceeds it, the image is cropped to 500 x 100, retaining only the top 100 pixels.
To change the 1920 x 1080 capture size, adjust the screenshot.default.window.width and screenshot.default.window.height properties. Extreme values can cause some dashboards to render incorrectly. See screenshot-service.properties Properties.
PDF Parameters
All PDF query parameters are optional.| Parameter | Type | Default | Description |
|---|---|---|---|
header | string | none | Header text placed at the top of each page. Maximum 50 characters. |
footer | string | none | Footer text placed at the bottom of each page. Maximum 50 characters. |
userName | string | none | The user name placed on the right hand side of the footer. |
includeTimestamp | boolean | false | When set to true, the timestamp is placed in the footer.When set to false, no timestamp is placed in the footer.To control the format of the timestamp, see PDF Timestamp Format. |
landscape | boolean | true | When set to true, page orientation is landscape.When set to false, page orientation is portrait. |
PDF Timestamp Format
When you set includeTimestamp to true, two properties control how the timestamp appears:timestampFormatPattern accepts any pattern string compliant with the Java DateTimeFormatter class.
By default, the timestamp uses the server time. To use a different time zone, set timestampUTCOffset to an integer offset from UTC between -18 and 18. See screenshot-service.properties Properties.
Troubleshoot Screenshot Microservice Problems
Common issues can be resolved by editing the Screenshot microservice properties file in/etc/zoomdata/screenshot-service.properties and, in some cases, the etc/zoomdata/zoomdata.properties file. Changing values in these files requires a restart of the associated microservice. See Restart Microservices. See also Icons Not Reverting to Defaults After Screenshot Microservice Disabled.Timeouts
Self-Service Analytics and the Screenshot microservice include default timeouts for dashboards to render. If you will be requesting screenshots of dashboards that takes longer than this default, you can increase the default timeout in the properties file.
The Screenshot microservice may time out on dashboards that take too long to draw. If a selected Self-Service Analytics dashboard takes more than the default timeout, then the default timeout setting in the properties file can be increased.
Determine how much additional time you need, in seconds, for the dashboards to load or render and then add properties, as described below, to the properties file.
Increase the default timeout
-
On the Self-Service Analytics server, edit
/etc/zoomdata/screenshot-service.properties. -
Update the following properties, specifying an appropriate number of seconds for
<nnnn>:screenshot.webdriver.timeout=<nnnn>export.dashboard.screenshot.timeout.seconds=<nnnn>
-
Save the
screenshot-service.propertiesfile. -
On the Self-Service Analytics server, edit
/etc/zoomdata/zoomdata.properties. -
Update the following property, specifying an appropriate number of milliseconds for
<nnnn>:screenshot.service.http.client.read.timeout.milliseconds=<nnnn> -
Save the
zoomdata.propertiesfile. - Restart the Self-Service Analytics and Screenshot microservices. See Restart Microservices.
Self-Signed Certificate
If Self-Service Analytics is running with a self-signed certificate, the Screenshot microservice must be configured to accept the lower-security certificate. Configure the Screenshot microservice to accept the lower-security certificate:-
On the Self-Service Analytics server, edit
/etc/zoomdata/screenshot-service.properties. -
Update the following property as follows:
- Save the properties file.
-
Restart the Screenshot microservice. See Restart Microservices.
This will pass the options to the ChromeDriver. The option list includes the default options normally passed to the driver, with the additional
--allow-insecure-localhostoption.
Screenshot Microservice Upgrade Notes
After upgrading, the screenshots on the Home page may look different. This occurs if there has been a change in the screenshot aspect ratio. To make the screenshots look correct, make sure that thescreenshot.daemon.enabled property in the zoomdata.properties file is set to true. Remember to restart the Self-Service Analytics server microservice after the change (see Restart Microservices).
After you have updated the properties file, you can update the screenshots in one of the following ways:
- In the
zoomdata.propertiesfile, modify thescreenshot.daemon.schedule.rateproperty and set it to a more frequent refresh rate. - Execute a cURL call to update a screenshot for a specific dashboard.
- Execute a cURL call to upload a custom image for a specific dashboard. Otherwise, the screenshots will be updated when the refresh screenshot procedure runs according to the configured refresh rate.
Icons Not Reverting to Defaults After Screenshot Microservice Disabled
The screenshot microservice can be enabled in Self-Service Analytics using CentOS and Ubuntu. However, users might notice that even after disabling the screenshot microservice, Self-Service Analytics continues to use existing screenshot images and does not automatically revert back to the original default icons for visuals or dashboards used by Self-Service Analytics after installation. To revert the icons used by Self-Service Analytics for the visuals or dashboards before the screenshot microservice was enabled, you must delete all the screenshots in the metadata directly. To do this in MongoDB, run the following commands:mongo command to access the mongo shell through the Linux command line.
Make sure you disable the screenshot microservice as well via the
zoomdata.conf and zoomdata.properties files and restart the Self-Service Analytics microservice for the changes to take effect.Fix Blank Visuals in the Home Page (for RPM Installations)
Symptom
If you successfully installed the RPM version of Self-Service Analytics and only see blank visuals on the dashboard, there may be a hostname mismatch in two specific Self-Service Analytics files:/etc/sysconfig/network and /etc/hosts.
Possible Cause
In the file/etc/sysconfig/network, the following setting is needed:
<servername>.
In the file /etc/hosts, the following should be listed:
<your_server_IP> and <servername>.
Resolution
To resolve this issue, open the two files and verify that the hostname references in both files match.- If the hostname reference does not exist in the
/etc/sysconfig/networkfile, then it must be added. The name must match the name in the/etc/hostsfile. - If the hostname reference exists in both files, then one of the references must be revised to match the other.
- Log out of Self-Service Analytics, if you are still in the program and close the browser.
- From your terminal, open a command line session.
-
Change to the
zoomdatadirectory. See Configure Self-Service Analytics if you need guidance. -
Edit the file
/etc/sysconfig/network. Search for the termHOSTNAME. If the term is not in the file, add the following line:Save the file. -
Edit the file
/etc/hosts. Find or add the following line in the file.Substitute the IP address and hostname of your Self-Service Analytics instance for<your_server_IP>and<servername>. Verify that the<servername>specified in the/etc/hostsfile matches the<servername>in the/etc/sysconfig/networkfile. Save the file. - Open a new browser session and log back into Self-Service Analytics to verify that the visuals are displaying in the gallery.