Gitlab hero border pattern left svg Gitlab hero border pattern right svg

Periscope Data

On this page


Periscope dbt docs

Accessing Periscope

Everyone at GitLab has View-only access to Periscope. Log in using Okta. If you need elevated access, such as Editor permissions to create your own charts, create an access request. Also see the user roles section

Periscope Resources

Self-Serve Analysis in Periscope

The goal of this section is to empower the reader to build their own Periscope dashboards that answer their questions about GitLab data. The examples given at the end are specific to the Product organization but are generalizable to any other team at GitLab.

Periscope Basics

The first step to building your own Periscope dashboard is checking that you have the correct permissions.

After logging in to Periscope using Okta, you should see a New Chart button in the top right corner. If you don’t see anything, you only have View-only access and you should follow the instructions above to gain Editor access.

Once you can see New Chart, you can start creating your own dashboards! Find Dashboards on the left side nav bar and click the + icon to build one. Make sure to give it a name in order to keep our directory organized.

Once your dashboard is built and named, you can start adding charts by clicking New Chart in the top right. Now you’re ready to start writing queries.

Finding the Right Data Sources

The next step to answering your data question is finding the relevant table(s) to query from. This requires knowing some background about our Snowflake data warehouse and the data sources which feed into it. There are 3 general types of data that we store in Snowflake: External, Internal Frontend, and Internal Backend.

External Data

External data is all of the data generated by third-party software we use at GitLab, but don’t store the production data ourselves. These sources include Salesforce, Zuora, Netsuite, Greenhouse, and BambooHR. We load this data into our data warehouse using APIs.

Internal Backend Data

GitLab.com is a Ruby on Rails app using a Postgres database on the backend. Each time a user on GitLab.com creates a new MR, issue, comment, milestone, etc., they create a new row in the database. The data team has written custom ELT to sync these Postgres tables into our data warehouse where they’re scrubbed for PII and made available to analyze.

For self-managed instances, we try to get weekly anonymized summaries of these backend databases using usage ping.

Internal Frontend Data

Additionally, we’ve enabled a tool called Snowplow to track frontend interactions on gitlab.com. Snowplow has automatic page view tracking as well as form and link-click tracking. Snowplow sends metadata along with every event, including information about the user’s session and browser.

Note: Snowplow is also capable of capturing backend events but at the moment we’re primarily using it for javascript (frontend) tracking.

What’s the difference between frontend and backend data? Backend data is data that’s already being preserved in the application database because it serves some purpose for the application (MRs, issues, pipelines). In contrast, the primary purpose of frontend tracking is analytics.

dbt Documentation

Our dbt Docs site lists all of the tables available for querying in snowflake. Many of these are documented at both the table and column level, making it a great starting point for writing a query.

Examples

Question 1: How many GitLab.com users visit the preferences page every day? We can use internal frontend data to answer this question since we're asking about page views. We can query Snowplow page views with like this:

SELECT
  DATE_TRUNC('day', page_view_start)::DATE AS period,
  COUNT(DISTINCT user_snowplow_domain_id) AS "Count Users"
FROM analytics.snowplow_page_views
WHERE page_url LIKE '%/profile/preferences%'
  AND page_view_start > DATEADD(day, -7, CURRENT_DATE) -- Last 7 days
GROUP BY 1
ORDER BY 1

Running this query in Periscope’s SQL editor will output a table in the chart section below the query. From there, Periscope offers you a variety of options for visualizing your data. A great way to learn about building charts is to watch this 10-minute Data Onboarding video from Periscope.

Question 2: How many GitLab.com users create a merge request every month? We can use internal backend data to answer this question since merge requests are stored in GitLab.com's backend database.

SELECT
  DATE_TRUNC('month', merge_request_created_at)::DATE AS period,
  COUNT(DISTINCT author_id) AS "Count Users"
FROM analytics.gitlab_dotcom_merge_requests_xf
WHERE merge_request_created_at BETWEEN '2019-01-01' AND '2019-06-01'
  AND merge_request_created_at < DATE_TRUNC('month', CURRENT_DATE) -- Don't show current month
GROUP BY 1
ORDER BY 1

This shows that about 110K users create a merge request every month.

Official Badge for a Dashboard

Some dashboards in Periscope will include an Official Badge (similar to Twitter's Verified Checkmark). Periscope Verified Checkmark

That means these analyses have been reviewed by the data team for query accuracy. Dashboards without the verified checkmark are not necessarily inaccurate; they just haven't been reviewed by the data team. Only members of the Data role can add or remove the Official Badge.

Spaces

We have two Periscope spaces:

They connect to the data warehouse with different users- periscope and periscope_sensitive respectively.

Most work is present in the GitLab space, though some extremely sensitive analyses will be limited to GitLab sensitive. Examples of this may include analyses involving contractor and employee compensation and unanonymized interviewing data.

Spaces are organized with tags. Tags should map to function (Product, Marketing, Sales, etc) and subfunction (Create, Secure, Field Marketing, EMEA). Tags should loosely match issue labels (no prioritization). Tags are free. Make it as easy as possible for people to find the information they're looking for. At this time, tags cannot be deleted or renamed.

Pushing Dashboards into Slack Automatically

Many folks will have some cadence on which they want to see dashboards; for example, Product wants an update on opportunities lost of product reasons every week. Where it is best that this info is piped into Slack on a regular cadence, you can take advantage of Slack's native /remind to print the URL. If it does not appear that the dashboard is autorefreshing, please ping a Periscope admin to update the refresh schedule.

User Roles

There are three user roles (Access Levels) in Periscope: admin, SQL, and View Only.

The current status of Periscope licenses can be found in the analytics project.

Updating Users for Periscope

let jq = document.createElement("script");
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";
jq.onload = function() {
  //your code here
};
document.body.appendChild(jq);
  • To get list of all users from a list visiable in the DOM, run this in the console, replacing the class name with the actual label.
$('div.list_class_namer_replace_this').map(function(i, el) {
  return $(el).text()}
).toArray()

Administrators

These users have the ability to provision new users, change permissions, and edit database connections. (Typical admin things)

Resource: Onboarding Admins

Editor access

The users have the ability to write SQL queries against the analytics and analytics_staging schemas of the analytics database that underlie charts and dashboards. They can also create or utilize SQL snippets to make this easier. There are a limited number of SQL access licenses, so at this time we aim to limit teams to one per Director-led team. It will be up to the Director to decide on the best candidate on her/his team to have SQL access.

View-only users

These users can consume all existing dashboards. They can change filters on dashboards. Finally, they can take advantage of the Drill Down functionality to dig into dashboards.

Functional Group Users

We have additional roles for further subdividing the Editor role. Certain charts should not be able to be edited by anyone. For example, the Finance KPIs dashboard should only be able to be edited by members of the Data and Finance roles.

Notes for when provisioning users

All users have View-only access privileges via Okta.

To upgrade a user, in the Periscope UI, navigate to the Roles and Policies section. Then add the user to the relevant group (Admin/Editor) and their functional group (e.g. Marketing, Product, etc.).

Users will inherit the highest access from any group they are in. This is why all functions are by default View-only.

New Dashboard Creation and Review Workflow

This section details the workflow of how to push a dashboard to "production" in Periscope. Currently, there is no functionality to have a MR-first workflow. This workflow is intended to ensure a high level of quality of all dashboards within the company. A dashboard is ready for production when the visuals, SQL, Python, and UX of the dashboard have been peer reviewed by a member of the Data Team and meet the standards detailed in the handbook.

  1. Create a dashboard with WIP: as the name and add it to the WIP topic
  2. Utilize the documentation of dbt and the warehouse to build your queries and charts
  3. Once the dashboard is ready for review, create an MR in the data team project using the Periscope Dashboard Review template. You do not need to make any changes, and this should be an empty MR.
  4. Follow the instructions on the template
  5. Assign the template to a member of the data team for review. If you don't know who to ping, use @gitlab-data.
  6. Once all feedback has been given and applied, the data team member will update the text tile in the upper right corner detailing who created and reviewed the dashboard, when it was last updated, and cross-link relevant issues (See Data Analysis Process for more details)
  7. The data team member reviewer will:
    • Rename the dashboard to remove the WIP: label
    • Remove the dashboard from the WIP topic
    • Add the Approval Badge to the dashboard
    • Merge the MR if they have permissions or assign it to someone with merge rights
      • MR's can also be closed if there are no meaningful changes

Update to Existing Dashboard Workflow

This section details the workflow on how to make updates to existing dashboards that have already been through the Data Team Peer Review process. Once a dashboard is in production, incremental additions to the dashboard can be implemented by the Data Analyst and the DRI/Prioritization Owner without going through the entire New Dashboard Creation and Review Workflow. Please follow the below steps to update an exisiting dashboard.

  1. Add WIP: to the title of the chart being updated. If a new chart is being added, add WIP: to the title.
  2. Make changes to the existing chart or add a new chart in accordance with the SQL style guide and Periscope visualization best practices set forth in the New Dashboard Creation and Review Workflow.
  3. Once the dashboard is ready for review by the DRI/Prioritization Owner, create a MR in the data team project using the Periscope Dashboard Review template. Ask the DRI/Prioritization Owner to complete their section of the MR located at the top. The Data Analyst should complete the Update to Existing Dashboard only section.
  4. After the Business Stakeholder/DRI reviews and approves the update and you have completed the Update to Existing Dashboard checklist, you can remove the WIP: from the new or updated chart and close the MR.

Embedding Periscope Charts in the Handbook

The business unit, not the data team, is responsible for embedding these charts in the handbook. Periscope has great embed docs and chat support through the app. There are three main ways to embed charts or dashboard in our handbook.

Hardcoded HTML

You can always hardcode HTML in any file type that accepts it. .html files are the obvious example. But markdown (.md) and embedded ruby (.erb) files also allow fallback to regular HTML.

Dashboards

It is quite easy to embed a whole dashboard in the handbook. To embed a dashboard, you must first make it an Externally Shared Dashboard. Then, you can add ?embed=true to the URL string to make it an embed link. Plug the URL into the following:

<iframe class="dashboard-embed" src="https://app.periscopedata.com/shared/string-of-numbers-here?embed=true" height="700"> </iframe>

We aim to make sure that the dashboard does not require scroll within the handbook, so you will need to adjust the height value appropraitely. There is no way to do that programmatically.

Charts

To embed a chart in the handbook, you need to generate a special URL for that chart. That can be done using the Periscope Embed Link Generator. After generating the URL, you can replace the below URL and embed it using

<embed width="100%" height="100%" src="https://www.periscopedata.com/api/embedded_dashboard?data=%7B%22chart%22%3A+5992548%2C+%22dashboard%22%3A+463858%2C+%22embed%22%3A+%22v2%22%2C+%22border%22%3A+%22off%22%7D&signature=d854fe408d1d3080813b52e6034fef08cfcf9ad98f07e9c084d142646773cf5c">

See an example

Embedded Ruby syntax

In .erb files you can use the helper function signed_periscope_url to generate a signed URL for you automatically. It has the advantage of not needing a member of the data team to generate a signed URL for you. This is especially convenient when experimenting with passing different data options to the Periscope API.

You simply pass the data as argument to the function. It can take any data required by the Periscope API, including sub-arrays and objects.

<embed width="100%" height="100%" src="<%= signed_periscope_url(chart: 6114177, dashboard: 463858, embed: 'v2') %>">

Unfortunately this method does not work in plain Markdown or HTML files because they do not execute code when rendering.

Performance Indicators YML

data/performance_indicators.yml is the basis for a system that automatically generates handbook pages with performance indicator content on them, according to a convention. If you give an object the periscope_data property with sub-values, the template will automatically generate a signed URL and write the HTML for you. It uses the same helper function as above.

- name: Average MRs/Dev/Month
  description: Average MRs per Developer per month is a monthly evaluation of how MRs on average an author performs.
  periscope_data:
    chart: 6114177
    dashboard: 463858
    embed: v2
  is_key: true

Pulling data out of Periscope

There may be times in which you need to pull data out of Periscope. If this is a one-off case, you can always download a CSV from the UI. If you need to regularly pull this data into, for example, a sheet, you can explose the CSV's public URL by going to Edit > Chart Format > Advanced > Expose Public CSV URL. Then in the sheet you can use =importdata("PUBLICURLHERE")

Tips and Tricks

Having a Dashboard that only presents the correct fiscal quarter information

You may want a dashboard that only filters to the current fiscal quarter or the next fiscal quarter. Periscope's off-the-shelf date filters cannot accomodate for custom fiscal years.

In your analysis, add the following: (update the [datevalue] with the date you're looking to have filtered)

LEFT JOIN analytics.date_details on current_date = date_actual
WHERE [datevalue] < last_day_of_fiscal_quarter
AND [datevalue] > first_day_of_fiscal_quarter

Filter out current month in dashboard queries

In most cases, you need to filter out the current month from your query and only report on completed months. The current month is incomplete and showing these numbers can be misleading. Please use the below statement in your dashboard query to filter out current month.

WHERE <month_column> < date_trunc('month', CURRENT_DATE)

Timezones

All timestamps in Snowflake should be in UTC.

Periscope's display time is set to PT (Pacific Time). This is aligned with the communication guidelines.

When using [created_date=daterange] Periscope uses the current_timestamp and converts it to PT for the comparison. For example, if on October 4th at 13:00 PT (20:00 UTC), you request data from the past 3 days, then Periscope will make the filter from 2019-10-02 07:00:00.000 to 2019-10-05 07:00:00.000. These times are in UTC and correspond to midnight at the start of 2019-10-02 in PT and midnight at the end of 2019-10-04 in PT - i.e. this is 3 full days for PT. If the database stores the values in UTC (which we do), then the comparison is exactly what you want.

The main thing you should worry about as an end-user is formatting the date for display in the chart. This can be done simply by converting the timestamp to PT with this syntax [created_at:pst]. You can also convert it to a date by appending :date like so [created_at:pst:date]. This is necessary when comparing dates in a source system such as Salesforce to what you see in Periscope.

The key things to remember are:

Working with Date Range Filters

When you have an aggregated date that you want to use as a filter on a dashboard, you have to use the aggregated period as the date range start and one day less than the end of the aggregation as the date range end value. Your date range start value can be mapped to your date period.

DRS

For the date range end, you need to create an additional column in your query to automatically calculate the end date based on the value selected in your aggregation filter. If we've been using sfdc_opportunity_xf.close_date as the date we care about, here is an example: dateadd(day,-1,dateadd([aggregation],1,[sfdc_opportunity_xf.close_date:aggregation])) as date_period_end Then add the mapping for the date range end.

DRE

Avoid unclear Visualizations

Pie charts are universally seen as a poor method of visualizing data. Read this blog post as a primer on why not to use pie charts.

High-Quality Image Exports

When exporting static charts out of Periscope, use the built-in export functionality instead of taking a screenshot. Exporting produces a higher-quality image with a transparent background. To export an image out of Persicope, select More Options in the top-right corner of any chart and then select Download Image.

Download Image

Periscope Housekeeping

Periscope operates as our Business Intelligence Tool and our Single Source of Truth. As our SSOT, Periscope requires us to maintain a very high level of cleanliness, tidiness, and accuracy.

It also requires that the dashboards created and/or approved by the data team are accurate and informative. It also requires some periodic maintenance from the data team members.

Main Principles:

Auto-archival of unused dashboards

At the moment, for all dashboards, the auto-archival feature is enabled. That means that if a dashboard is not viewed for more than 45 days, it will be automatically archived. An archived dashboard is not deleted and can be unarchived.

Monthly Periscope Cleanup

Entropy is a natural but avoidable state of a Business Intelligence Tool. In order to act against this tendency, the Data Team operates periodic Maintenance Operations in our Periscope space.

Every month, a Data Team member will take care of the maintenance. This could be proactively claimed one week before the end of each month during one of the Data Ops meetings.

The maintenance task has to be completed in the first week of every month. To do so, you have to open a new issue in the data team project and select the Periscope Cleanup Issue templace. This template will give a list of tasks to complete. Once all of them are completed, you can close the issue.