Skip to main content
If you plan to move from Open Analytics to your own tool or to MoEngage Analytics, plan these steps:
  1. Save and export your queries. Copy or export the SQL of each query you want to keep. For more information, refer to Save Your Queries.
  2. Download your reports. Download the results of the queries you need. For more information, refer to Download Query Results.
  3. Migrate reports to MoEngage Analytics. Rebuild the reports that MoEngage Analytics supports in custom dashboards.
  4. Set up data exports. If you don’t use them already, set up MoEngage Data Exports to send your MoEngage data to your own warehouse or data tools. Use them to run these workloads on a recurring basis.
To export historical events, create a support ticket. This export can incur charges and needs admin approval. It can take a few weeks, depending on the number of events and their date range.
Open Analytics is built on Redash, so the screens in this guide are Redash screens. You can export two types of content from it:
  • Queries: the SQL text, for backups, code reviews, version control, or migrations.
  • Query results: the data a query returns, as CSV, TSV, Excel, or JSON, for reports, spreadsheets, or other tools.

Choose an Export Method

Before You Start

The API and command-line methods need a query ID, an API key, or both.
  • Query ID: Open the query and copy the number at the end of the browser URL. For example, in https://<OPEN_ANALYTICS_URL>/queries/4821, the query ID is 4821.
  • API key: Use the key type that matches your task.

Save Your Queries

You can copy the SQL of one query from the editor, or export every query you can access as .sql files. Copying works for a few queries. For more than a few, the bulk export is faster and keeps each query’s name with its SQL.

Copy the SQL From the Editor

1

Open the Query

In the top navigation, click Queries and select the query from the list or from Favorite Queries.
2

Show the SQL

Click Edit Source. The SQL editor opens above the results.
3

Copy the SQL

Click in the editor, press Cmd+A (macOS) or Ctrl+A (Windows) to select the full query, and copy it. Paste it into a text file or your code repository.
Open a query from the Queries menu, click Edit Source, and select the SQL in the editor.
To fetch the SQL with a script instead, send a GET request with your user API key. The response is a JSON object that describes the query, and the SQL is in its query field.
Get One Query
To save only the SQL to a file, filter the response with jq:
Save One Query as SQL

Export All Queries With redash-toolbelt

The export-queries command in the official redash-toolbelt Python package saves each query you can access as a query_<QUERY_ID>.sql file in the current folder. Each file starts with a comment that lists the query name, data source, author, and last update time.
1

Install redash-toolbelt

Install
2

Set Your User API Key

Set the API Key
If you skip this step, the command prompts you for the key.
3

Run the Export

Export All Queries

Download Query Results

You can download the results of a query as a file from the console, or read them from a URL with the query API key. Use the console for a one-time file. Use the API when a script needs the latest results.

Download Results From the Console

1

Run the Query

Open the query and click Execute so the results are current.
2

Open the Results Menu

Below the results table, click the vertical ellipsis (⋮) next to Edit Visualization.
3

Download the File

Click Download as CSV File, Download as TSV File, or Download as Excel File.
The results menu below the query results with options to download as CSV, TSV, or Excel.
To download from a dashboard, open the widget menu and select the download option. You get the same file for the query behind that widget.
The download contains the full cached result, not only the rows on screen. If a query returns millions of rows, aggregate the data or add a LIMIT before you download. Very large downloads can time out.

Get Results From the API

Each saved query has its own query API key. With it, a script can read the query’s results over HTTPS without logging in.
1

Copy the Query API Key

Open the query, click the horizontal ellipsis (…) next to Edit Source, and click Show API Key. The dialog shows the key and example URLs for CSV and JSON results.
2

Build the Results URL

Add the query ID and key to the URL. To get JSON or Excel instead of CSV, change .csv to .json or .xlsx.
Results URL
The query menu with Show API Key selected and the dialog showing the API key and result URLs.
Anyone with this URL can download the results without logging in. Treat the URL like a password, and don’t commit it to a code repository.
The results URL works as follows:
  • It returns the latest result. If you add a result ID to the path, for example /results/<RESULT_ID>.csv, the URL stays pinned to that one result and doesn’t update.
  • It returns cached results only. The URL doesn’t run the query. If the query has never run, you get a No cached result found error. Run the query or set a refresh schedule first.
  • It doesn’t work for queries with parameters. For a query that uses parameters, such as {{limit}}, you get a No cached result found error. To get these results, send a POST request to /api/queries/<QUERY_ID>/results with your user API key. For details, see the Redash API reference.
  • It can fail on very large results. Results of about 200 MB or more can fail with a 502 Bad Gateway error. Filter or aggregate the data, or split the query into smaller date ranges.
You can call the URL from any tool that reads files over HTTPS:

Security Practices

  • Use the narrowest key. Use a query API key to share or automate results. Use your user API key only in scripts you control.
  • Keep keys out of code. Store API keys in environment variables or a secrets manager. Don’t put keys or results URLs in source code or Git.
  • Protect customer data. Exported files can contain personally identifiable information (PII). Check who can open a file before you share it.
  • Back up on a schedule. Run export-queries on a schedule into a private Git repository. This gives you a version history and a way to recover a query that someone changes or deletes.

Troubleshooting