Tracking ElastiCube size over time
What the solution does âď¸ This solution leverages Custom Code Notebooks and the Sisense REST API to capture ElastiCube size on a desired interval, making the data available for historical analysis. This analysis can be performed via Dashboards, Pulse, or any other method that benefits from a basic flat file structure. Why itâs useful â As mentioned in the Introduction, ElastiCube size is important because it directly impacts performance, hardware resource consumption, build times, and scalability. Efficiently managing cube size is key to maintaining a fast and stable analytics environment. There may also be licensing considerations, requiring the deployment to remain below a sizing threshold. However, it can be challenging to monitor this data on a historical basis for purposes of trending, forecasting, or capturing anomalies. This solution aims to remove that challenge and provide your team with this data in an easy-to-use format. đ¨How it's achieved Create a new ElastiCube and add a Custom Code table. Import the attached Notebook file, getElasticubeSize.ipynb (inside .zip) -- the raw code can also be found below Infer the schema from the Notebook Ensure LastBuildDate and SnapshotDate_UTC are set to DateTime data type âApplyâ the schema changes Save the Custom Code table and rename it as desired # Test Cell # When the notebook is executed by the Build process, this cell is ignored. # See the `Test Cell` section below for further details. additional_parameters = '''{}''' from init_sisense import sisense_conn import os import json import requests import pandas as pd from datetime import datetime # Construct the Sisense server base URL server = ( "http://" + os.environ["API_GATEWAY_EXTERNAL_SERVICE_HOST"] + ":" + os.environ["API_GATEWAY_EXTERNAL_SERVICE_PORT"] ) required_columns = [ "ElasticubeName", "TenantId", "SizeInMb", "SizeInGb", "LastBuildDate", "SnapshotDate_UTC", ] def get_elasticube_size(server): """Retrieve Elasticube size and metadata from Sisense API with error handling.""" endpoint = "/api/v1/elasticubes/servers/next" # API call try: response = sisense_conn.call_api_custom("GET", server, endpoint, payload=None) response.raise_for_status() response_json = response.json() except Exception as e: print(f"API error: {e}") return pd.DataFrame(columns=required_columns) # Validate JSON list structure if not isinstance(response_json, list): print(f"Unexpected response format: {type(response_json)}") return pd.DataFrame(columns=required_columns) # Compute snapshot timestamp once for all rows snapshot_timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ") ec_size_data = [] for item in response_json: size_mb = item.get("sizeInMb", 0) size_gb = (size_mb or 0) / 1024 ec_size_data.append( { "ElasticubeName": item.get("title") or pd.NA, "TenantId": item.get("tenantId"), "SizeInMb": size_mb, "SizeInGb": size_gb, "LastBuildDate": item.get("lastBuildUtc"), "SnapshotDate_UTC": snapshot_timestamp, } ) df = pd.DataFrame(ec_size_data) # Convert LastBuildDate if not df.empty: df["LastBuildDate"] = pd.to_datetime( df["LastBuildDate"], errors="coerce", utc=True ) # Format to ISO 8601 df["LastBuildDate"] = df["LastBuildDate"].dt.strftime("%Y-%m-%dT%H:%M:%SZ") # Ensure correct column order return df[required_columns] # === Main Execution === df_result = get_elasticube_size(server) print(df_result.head()) # === Write DataFrame to CSV === output_folder = "/opt/sisense/storage/notebooks/ec_size" os.makedirs(output_folder, exist_ok=True) ts = datetime.utcnow().strftime("%Y%m%d_%H%M%S") file_name = f"elasticube_sizes_{ts}.csv" output_path = os.path.join(output_folder, file_name) df_result.to_csv(output_path, index=False) print(f"CSV written: {output_path}") print("Program completed successfully.") This Custom Code hits the Sisense REST API to capture ElastiCube size, along with the capture date (for historical trending purposes). It only serves as a starting point and can be freely edited. Every time the cube is built, it will generate a csv of the data and place it under /opt/sisense/storage/notebooks/ec_size. This location can be accessed in the Sisense UI via File Management â the ec_size folder may need to be created manually. To leverage the data in the csv files, I recommend creating a separate ElastiCube with a csv connection. In the connection: Select âServer Locationâ Define the Input Folder Path: /opt/sisense/storage/notebooks/ec_size/ Ensure âUnion Selectedâ is enabled. This will combine all of the csv files into a singular data set. The reason I recommend creating a separate data model is so you donât have to worry about table build order. For example, if the Custom Code and CSV tables exist in the same model, itâs possible for the CSV table to be built before the Custom Code builds/executes, so the latest CSV fileâs data would be missed until the next build (and so on). By keeping the Custom Code and csv data models separate, you have more control over the build order by scheduling the builds sequentially. This dataset can be used as-is to build basic historical analyses, or you can enhance it by building separate custom tables that sit on top of it. Further, you can modify the Custom Code table itself to pull whatever data is needed from the Sisense REST API, such as ElastiCube row counts and more. NOTE: Similar data can be sourced from the Usage Analytics data model, using the SummarizeBuild table. But the Custom Code solution provides more flexibility in what is pulled, when, and how long it is retained, without affecting anything else. Additionally, each csv is available for independent review/modification as needed.46Views0likes0CommentsExporting a Dashboard Into PDF with SisenseJS
Exporting a Dashboard Into PDF with SisenseJS This article explains how to develop the functionality of generating PDF with the shown widgets when Sisense dashboard is embedded with SisenseJS. When the dashboard is exported into PDF, the report is generated on the Sisense server. When a dashboard is embedded with SisenseJS, then developers can create their own layout, which can differ from the layout created by the dashboardâs designer. SisenseJS does not provide an option to export the shown widgets to PDF, because Sisense will not be able to render the same layout that is used in the parent application. Nevertheless, the shown dashboard can be easily exported into PDF. For exporting we need to use the external library [html2pdf.js]. More information about this library can be found at this link. This library should be added to the page: <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script> Once this library is loaded and Sisense widgets are rendered on the page, you can call methods from this library in order to generate PDF reports. To utilize the methods of this library, I created a function exportToPDF() and variable [opt]. Variable [opt] stores settings that will be used to initiate exporting to PDF. In the sample below, the returned file will be named âmyfile.pdfâ. Function exportToPDF() expects a DOM element that contains the rendered widgets. HTML of the given element will be rendered in the returned PDF: const opt = { filename: 'myfile.pdf', //File name }; function exportToPDF(lmnt) { const dashboardContainer = document.getElementById(lmnt); html2pdf().set(opt).from(dashboardContainer).save(); } Sample of this logic execution: exportToPDF('sisenseApp'); In the generated PDF the widgets will be placed as the developer placed them. Using this approach you can easily implement the functionality of generating PDF reports. Feel free to use this logic and modify them according to your needs!1.7KViews1like1CommentError exporting to PDF
Sisense allows you to generate a PDF report of your dashboard when you need to take copies of your dashboards with you for meetings or sharing them with others. This article gives detailed troubleshooting steps on how to handle PDF export failures on all Sisense versions. How Does It Work? When you click Download PDF or the PDF icon in the menu bar , a preview of your report is opened. After you have defined the appearance of your report, you can save the layout of the dashboard by clicking Save. The next step is to click Download PDF, your saved layout will be downloaded into a PDF file. Disable All Plugins One of the most common causes of a PDF export failure is due to a faulty plugin. If you cannot export any report to PDF, then the issue is most likely due to plugins. Firstly, disable all the plugins. To do so, go to Admin â Plugins under System Configuration and toggle the switch to disable each plug-in. To disable all plugins at once, select each Plug-in and toggle the Disable Selected switch: If the report is exported to PDF successfully, then you can switch on the plug-ins one-by-one to find the problematic one. When you find a problematic plug-in, make sure you have the latest version of the plug-in installed. If disabling all plugins does not work we recommend going to the actual "plugins" folder on the Sisense server and removing all the plugin folders manually. For versions 7.2 and higher the "plugins" folder can be found in C:\Program Files\Sisense\app\plugins For versions 7.1 and lower the "plugins" folder can be found in C:\Program Files\Sisense\PrismWeb\plugins Disable All Scripts An easy way to determine where the issue is, is to create a new simple widget and try to export it. If the dashboard is exported successfully, it means that the issue is local, and you need to check the scripts applied to your widgets and dashboards. Try to disable your scripts to understand if it affects your PDF exports. Once you find the broken script, you will need to fix it. To disable a script, you need to open the Script Editor and disable your script by commenting it out. It can be commented out by adding â//â to the beginning of each row. For dashboard scripts, for the dashboard, in your dashboard, click Edit Script For a specific widget, click on the widget in Edit mode. 7.2 And Later Further Troubleshooting If you are using Sisense installation which is on V7.2 and above and still experiencing errors with PDF exports, it is possible that it is related to a Configuration Manager setting. To troubleshoot this, on a Sisense webserver take the following steps: (please note that this could make your site unavailable for a short period of time so take care to do this off-hours if in a production environment) In a web browser (Chrome is preferred but any of the supported web browsers are OK), navigate to http://localhost:3030 You will see the Configuration Manager appear Scroll down to the "Domain Binding" section. If this field is populated, remove the entry. There are only a few specific reasons to have this set. If your Sisense domain is attached to the server via a DNS entry you typically do not need to set this. Click the 'Save' button at the top right-hand corner 7.1 And Earlier Further Troubleshooting If you are using Sisense installation which is below V7.2 and still experiencing errors with PDF exports, it is possible that it is related to a local configuration file issue. To verify the configuration is correct, please follow the below: If you have an domain defined on your server, make sure the setting in 'Admin'-->'system configuration' does not include "http://" Make sure that you have access to the domain URL from the local server (ie. http://bi.my.company.com/) If you have SSL configured - please make sure you can browse to the secure site locally as well (ie. https://bi.my.company.com/) Check bindings: Open the Windows IIS Manager -> Navigate to each of the websites -> "Bindings" and make sure that no two websites bind to same port (double bindings) Go to "Add or Remove Programs" -> Right click on Sisense and choose "Change..." -> In installation window "Continue" -> "Change Settings" and verify that the port configured matches the port specified in the IIS Manager for Sisense Web If these troubleshooting steps do not fix the issue, you may need to edit the exporting section of the default.yaml file. Find the file here: C:\Program Files\Sisense\PrismWeb\vnext\config The exporting section is located at the end of the file, and there are 3 variables you may have to change- host, port, and protocol. Please set these variables to the values that are used to access Sisense Web on the server. For example, if you access Sisense Web by going to http://test.dashboards.com, you would set the variables tohost: "test.dashboards.com" port: 80 protocol: "http" After making the changes, save the file, and restart IIS. Log Files For further investigation detailed logs on the any PDF related errors can be found below For Sisense V7.1.3 and earlier: C:\Program Files\Sisense\PrismWeb\vnext\iisnode For Sisense V7.2 and later: C:\ProgramData\Sisense\application-logs If you are still seeing issues after following this guide please feel free to contact Sisense Support for further assistance2.4KViews0likes0Comments