You are browsing a read-only backup copy of Wikitech. The live site can be found at

Analytics/Data access: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>Gergő Tisza
(→‎Databases: it's not detailed below)
Line 213: Line 213:

You can access this data using the replica MariaDB databases.  These are accessible from the stat100* machines, as [[Analytics/Data_access#Stats_machines|detailed below]].
You can access this data using the replica MariaDB databases.  These are accessible from the stat100* machines via <code>analytics-mysql <wiki-id></code>. For more details [[Analytics/Systems/MariaDB|see here]].

For an overview of how the data is laid out in those databases, consult the [[mediawikiwiki:Manual:Database_layout|database layout manual]].  
For an overview of how the data is laid out in those databases, consult the [[mediawikiwiki:Manual:Database_layout|database layout manual]].  

Revision as of 16:35, 5 April 2021

In addition to a variety of publicly-available data sources, Wikimedia has a parallel set of private data sources. The main reason is to allows a carefully vetted set of users to perform research and analysis on confidential user data (such as the IP addresses of readers and editors) which is stored according to our privacy policy and data retention guidelines. This private infrastructure also provides duplicate copies of publicly-available data for ease of use.

Do you need it?

Private data lives in same server cluster that runs Wikimedia's production websites. Often, this means you will need production shell access to get it.

However, since this access gets you closer to both those production websites and this confidential data, it is not freely given out. First, you have to demonstrate a need for these resources. Second, you need to have a non-disclosure agreement with the Wikimedia Foundation. If you're a Foundation employee, this was included as part of your employment agreement. If you're a researcher, it's possible to be sponsored through a formal collaboration with the Wikimedia Foundation's Research team.

User responsibilities

You must remember this access is extremely sensitive. You have a duty to protect the privacy of our users. As Uncle Ben says, "with great power comes great responsibility." Always follow the rules outlined in the Acknowledgement of Server Access Responsibilities, even if you don't have requested ssh access to stat100x clients since it contains good guidelines about how to handle sensitive data.

In addition, keep in mind the following important principles:

  • Be paranoid about personally identifiable information (PII). Familiarize yourself with the data you are working on, and determine if it contains any PII. It's better to double and triple check than to assume anything, but if you have any doubt ask the Analytics team (via IRC or email or Phabricator). Please see the data retention guidelines.
  • Don't copy sensitive data (for example, data accessible only by the users in the analytics-privatedata-users) from its origin location to elsewhere (in HDFS or on any other host/support) unless strictly necessary. And most importantly, do it only if you know what you are doing. If you are in doubt, please reach out to the Analytics team first.
  • Restrict access. If you do need to copy sensitive data somewhere, please make sure that you are the only one able to access the data. For example, if you copy Webrequest data from its location on HDFS to your /user/$your-username directory, make sure that the permissions are set to avoid everybody with access to HDFS to read the data. This is essential to avoid accidental leaks of PII/sensitive data or retention over our guidelines (
  • Clean up copies of data. Please make sure that any data that you copied is deleted as soon as your work has been done.

If you ever have any questions or doubts, err on the side of caution and contact the Analytics team. We are very friendly and happy to help!

Requesting access

If after reading the above you do need access to WMF analytics data and/or tools, you'll need to submit a request on Phabricator and tag SRE-Access-Requests. See: Production access#Access Request Process.

Read the following sections to figure out what you'll access levels you should request in your ticket.

Access Levels

There are a few varying levels and combinations of access that we support.

'analytics-*' groups have access to the Analytics Cluster (which mostly means Hadoop) and to stat* servers for local (non distributed) compute resources. These groups overlap in what servers they grant ssh access to, but further posix permissions restrict access to things like MySQL, Hadoop, and files.

  • LDAP membership in the wmf or nda LDAP group allow you to log in and authenticate via web tools like Superset and Turnilo.
  • Shell (posix) membership in the `analytics-privatedata-users` group allows you to read private data stored in tools like Hadoop, Hive, Presto.
  • An ssh key for your shell user allows you to ssh into the analytics client servers (AKA stat boxes) (and access tools like Jupyter which also needs LDAP membership).
  • A Kerberos principal allows you to access data in Hadoop directly.
  • Team specific shell (posix) group membership for management of team specific jobs and data.

This might all be confusing if you are just trying to figure out what to put in your Phabricator SRE-Access-Requests ticket. Here are a few common use cases of what you might be trying to request.

What access should I request?

If you need access to...

Dashboards in web tools like Turnilo and/or Superset that do not access private data

  • LDAP membership in the wmf or nda LDAP group.

Dashboards in Superset / Hive interfaces (like Hue) that do access private data

  • LDAP membership in the wmf or nda LDAP group.
  • Shell (posix) membership in the `analytics-privatedata-users` group

Note to SREs granting this access: This can be done by declaring the user in Puppet as usual, but with an empty array of ssh_keys.

ssh login to analytics client servers (AKA stat boxes) without Hadoop, Hive, Presto access

This is a rare need, but you might want it if you just want to use a GPU on a stat box, or access to MediaWiki analytics MariaDB instances.

  • LDAP membership in the wmf or nda LDAP group.
  • Shell (posix) membership in the `analytics-privatedata-users` group
  • An ssh key for your shell user

ssh login to analytics client servers (AKA stat boxes) with Hadoop, Hive, Presto access

  • LDAP membership in the wmf or nda LDAP group.
  • Shell (posix) membership in the `analytics-privatedata-users` group
  • An ssh key for your shell user
  • A Kerberos principal

All of the above

If you are a WMF engineer wanting to work with analytics data, most likely you'll want all of these access levels together:

  • LDAP membership in the wmf or nda LDAP group.
  • Shell (posix) membership in the `analytics-privatedata-users` group
  • An ssh key for your shell user
  • A Kerberos principal

If needed for work on your team, you may also want Team specific shell (posix) group membership (see below).

Analytics shell (posix) groups explained

Generic data access (can go together with the Team specific ones)

analytics-privatedata-users (no kerberos, no ssh)

The Analytics team offers various UIs to fetch data from Hadoop, like Turnilo and Superset. They are both guarded by CAS authentication (requiring the user to be in either the wmf or the nda LDAP groups), fetching data from Druid (currently not authenticated). Superset is also able to fetch data from Hadoop/Hive on behalf of the logged in user via a (read-only) tool called Presto. There are two use cases:

  • Sql-lab panel: the user is able to make sql-like queries on Hadoop datasets (pageviews/event/etc..) without the need to log in on a stat100x host.
  • Dashboards: data visualized in dashboards fetched from Hadoop.

In both cases, Superset works on behalf of the user, so eventually the username will need to hold read permissions for Hadoop data to correctly visualize what requested. This is guaranteed by being into analytics-privatedata-users, that gets deployed on the Hadoop master nodes (without ssh access) to outline user permissions on HDFS. This is why some users might want to be in the group without either kerberos or ssh.

analytics-privatedata-users (no kerberos)

Grants access to the analytics clients, GPUs and to MariaDB replicas (using the credentials at /etc/mysql/conf.d/analytics-research-client.cnf).

analytics-privatedata-users (with kerberos)
Grants access to all the analytics clients, the analytics cluster (Hadoop/Hive) and the private data hosted there, and to MariaDB replicas, using the credentials at /etc/mysql/conf.d/analytics-research-client.cnf.
Users in this group also need a Kerberos authentication principal. If you're already a group member and don't have one, follow the instructions in the the Kerberos user guide. If you're requesting membership in this group, the SRE team will create this for you when they add you to the group.

The list of users currently in each group is available in this configuration file.[1]

Team specific (they do not grant access to PII data on Hadoop, for that see analytics-privatedata-users)

For Wikimedia Deutschland employees, mostly used for crons running automation jobs as the analytics-wmde system user. Grants access to all stat100x hosts, to the MariaDB replicas via /etc/mysql/conf.d/research-wmde-client.cnf and to the analytics-wmde system user. It is not required that every WMDE user is placed into this group, only those who needs to take care of the the aforementioned automation will require access (so they'll ask it explicitly).
For members of the Wikimedia Foundation Search Platform team , used for various Analytics-Search jobs). Grants access to all stat100x hosts, an-airflow1001 and to the analytics-search system user.
For members of the Product Analytics team, used for various Analytics jobs. Grants access to all stat100x hosts, and to the analytics-product system user.

Groups to avoid (deprecated)


Host access granted

There used to be a lot of differences in what hosts an Analytics POSIX group could have had access to, but now there is none anymore.

Data access granted

Access Groups Hadoop access

(No private data)

Hadoop access

(Private data)

Mariadb credentials System user Other
analytics-privatedata-users yes yes analytics-research-client.cnf analytics-privatedata
analytics-wmde-users research-wmde-client.cnf (only on stat1007) analytics-wmde
analytics-search-users Airflow admin
analytics-product-users analytics-product

Shell access expiration

Data access is given to collaborators and contractors with a time limit. Normally the end date is set to be the contract or collaboration end date. For staff data access terminates upon employment termination unless there is a collaboration in place.

Once a user is terminated their home directory is deleted, if the team wishes to preserve some of the user work (work, not data as data as strict guidelines for deletion) it can be done via archiving that work to hadoop. Please file a phab ticket to have this done. Archival to hadoop would happen in the following directory:


LDAP access

Some Analytics systems, including Superset, Turnilo, and Jupyter, require a developer account in the wmf or nda LDAP groups for access.

If you need this access, first make sure you have a working developer account (if you can log into this wiki, you have one). If you need one, you can create one at mw:Developer_account.

Note that a developer account comes with two different usernames; some services need one and some services need the other. You can find both by logging into this wiki and visiting the "user profile" section of Special:Preferences. Your Wikitech username is listed under "Username", while your developer shell username is listed under "Instance shell account name". Thankfully, there's only one password!

Then, create a Phabricator task: Read and follow the instructions for LDAP-access-requests to request getting added to the appropriate group. Make sure you include both your usernames.

Note that this access has similar requirements to shell access: you will need to either be a Wikimedia Foundation employee or have a signed volunteer NDA.


Analytics clients

The analytics clients are servers in the production cluster where you can run your code and queries. In fact, you should use them to run all your analysis, so that sensitive data never leaves the production cluster.

They have a number of useful capabilities, from large amounts of memory to Jupyter notebooks.


The Analytics MariaDB cluster contains copies of the production MediaWiki databases (both actively-used mainstream projects and small internal-facing wikis, like various projects' Arbitration Committees).


Hadoop is our storage system for large amounts of data. You can query data in Hadoop using Hive, Presto, or Spark.

In addition to SSH, we use Kerberos to manage access to data in Hadoop.

Scripting access

If you're writing some analysis code, you will probably need to access data first. There are a couple of software packages that have been developed to make this easy. Note that both of them are designed to work on the analytics clients only.

For Python, there is wmfdata. It can access data through MariaDB, Hive, Presto, and Spark and has a number of other useful functions, like creating custom Spark sessions.

For R, there is wmf. It can access data from MariaDB and Hive and has many other useful functions, particularly for graphing and statistics.

Data sources

Data sets and data streams can be found in Category:Data_stream

Data Dashboards. Superset and Turnilo

Superset: Turnilo:

You need a wikitech login that is in the "wmf" or "nda" LDAP groups. If you don't have it, please create a Phabricator task by following instructions on phab:tag/ldap-access-requests/.

Before requesting access, please make sure you:

Depending on the above, you can request to be added to the wmf group or the nda group. Please indicate the motivation on the task about why you need access and ping the analytics team if you don't hear any feedback soon from the Opsen on duty.

MediaWiki application data

You can do a lot of work with the data stored by MediaWiki in the normal course of running itself. This includes data about:

  • Users' edit counts (consult the user table)
  • Edits to a particular page (consult the revision table, joined with the page table if necessary)
  • Account creations (consult the logging table)


You can access this data using the replica MariaDB databases. These are accessible from the stat100* machines via analytics-mysql <wiki-id>. For more details see here.

For an overview of how the data is laid out in those databases, consult the database layout manual.

There are a few things that aren't available from the databases replicas. The main example of this is the actual content of pages and revisions. Instead, you can access them through the API or in the XML dumps, which are both described below.


A subset of this application data, which doesn't present privacy concerns, is also publicly accessible through the API (except for private wikis, which you shouldn't really need to perform research on anyway!). A good way to understand it, and to test queries, is Special:ApiSandbox, which provides a way of easily constructing API calls and testing them. The output includes "Request URL" - a direct URL for making that query in the future, that should work on any and all Wikimedia production wikis.

If you're interested in common API tasks, and don't feel like reinventing the wheel, there are a number of Python-based API wrappers and MediaWiki utilities. Our very own Aaron Halfaker maintains MediaWiki Utilities, which includes a module dedicated to API interactions. There's no equivalent for R yet.

Database dumps

Every month, XML snapshots of the databases are generated. Since they're generated monthly, they're always slightly outdated, but make up for it by being incredibly cohesive (and incredibly large). They contain both the text of each revision of each page, and snapshots of the database tables. As such, they're a really good way of getting large amounts of diffs or information on revisions without running into the query limits on the API.

Aaron's MediaWiki-utilities package contains a set of functions for handling and parsing through the XML dumps, which should drastically simplify dealing with them. They're also stored internally, as well as through, and can be found in /mnt/data/xmldatadumps/public on stat1004, stat1005, stat1006, stat1007, and stat1008.

EventLogging data

One analytics-specific source of data is EventLogging. This allows us to track things we're interested in as researchers that MediaWiki doesn't normally log. Examples include:

  1. A log of changes to user preferences;
  2. A/B testing data;
  3. Clicktracking data.

These datasets are stored in the event and event_sanitized Hive databases, subject to HDFS access control.

Pageviews data

An important piece of community-facing data is information on our pageviews; what articles are being read, and how much? This is currently stored in our Hadoop cluster, which contains aggregated pageview data as well as the mostly-raw database of web requests. See the detailed documentation here.



Geolocation data

When you have IP addresses - be they from the RequestLogs, EventLogging or MediaWiki itself - you can do geolocation. This can be a very useful way of understanding user behaviour and evaluating how our ecosystem works. We currently use the MaxMind geolocation services, which are accessible on stat boxes: a full guide to geolocation and some examples of how to do it can be found on the 'geolocation' page.


  1. Other groups including statistics-admins, analytics-admins, eventlogging-admins, and statistics-web-users are for people doing system maintenance and administration, so you don't need them just to access data.