Table of Contents | ||||||
---|---|---|---|---|---|---|
|
...
- Downloads Count
- Page Views
- Data Breaches/Audit Trail
Downloads Count
This is the main statistic that the users are currently looking for, it provides a way for project owners, funders and data contributor to monitor the interest over time in the datasets published in a particular project, which then reflects on the interest on the project itself and it is a metric of the value provided by the data in the project. This kind of data is related specifically to the usage of the platform by synapse users, since without being authenticated the downloads are not available. This is part of a generic category of statistics that relates to the entities and metadata that is stored in the backend and it's only a subset of aggregate statistic that can be exposed (e.g. number of projects, users, teams etc).
Page Views
This metric is also an indicator to monitor the interest but it plays a different role and focuses on the general user activity over the synapse platform as a whole. While it might be an indicator for a specific project success it captures a different aspect that might span to different type of clients used to interface on the Synapse API and that include information about users that are not authenticated into synapse. For this particular aspect there are tools already integrated (E.g. google analytics) that collect analytics on the user interactions. Note however that this information is not currently available to the synapse users, nor setup in a way to produce information about specific projects pages, files, wikis etc.
Data Breaches/Audit Trail
Another aspect that came out and might seem related is the identification of when/what/why of potential data breaches (e.g. a dataset was released even though it was not supposed to). This relates to the audit trail of users activity in order to identify potential offenders. While this information is crucial it should not be exposed by the API, and a due process is in place in order to access this kind of data.
Project Statistics
With this brief introduction in mind this document focuses on the main driving use case, that is:
- A funder and/or project creator would like to have a way to understand if the project is successful and if its data is used.
There are several metrics that can be used in order to determine the usage and success of a project, among which:
- Project Access (e.g. page views)
- Number of Downloads
- Number of Uploads
- User Discussions
...
Files, Downloads and Uploads
Files in synapse are referenced through an abstraction (FileHandle) that maintain the information about the link to the content of the file itself (e.g. an S3 bucket). A file handle is then referenced in many places (such as FileEntity and WikiPage, see FileHandleAssociateType) as pointers to the actual file content. In order to actually download the content the synapse platform allows to generated a pre-signed url (according to the location where the file is stored) that can be used to directly download the file. Note that the platform has no way to guarantee that the pre-signed url is actually used by the client in order to download a file. Every single pre-signed url request in the codebase comes down to a single method getURLForFileHandle.
...
We propose to introduce a dedicated /statistics
endpoint that will serve as main entry point to statistics requests. The project statistics are nested within this endpoint:
Endpoint | Method | Description | Response Type | Restrictions |
---|---|---|---|---|
/statistics/project/{projectSynId} | GET | Allows to get the statistics for the given project | ProjectStatistics |
|
The endpoint accepts the following optional URL parameters:
Parameter Name | Type | Default Value | Description |
---|---|---|---|
downloads | Boolean | true | If set to false allows to exclude the downloads statistics from the response |
uploads | Boolean | true | If set to false allows to exclude the uploads statistics from the response |
Code Block | ||||
---|---|---|---|---|
| ||||
GET /statistics/project/syn123?downloads=true&uploads=false |
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "lastUpdatedOn: "2019-26-06T01:01:00.000Z", "downloads": { "lastUpdatedOn": "2019-26-06T01:01:00.000Z", "monthly": [{ "startDate": "2019-01-06T00:00:00.000Z", "count": 1230, "usersCount": 10 }, { "startDate": "2019-01-05T00:00:00.000Z", "count": 10000, "usersCount": 100 }] }, "uploads": { "lastUpdatedOn": "2019-26-06T01:01:00.000Z", "monthly": [{ "startDate": "2019-01-06T00:00:00.000Z", "count": 51200, "usersCount": 200 }, { "startDate": "2019-01-05T00:00:00.000Z", "count": 10000, "usersCount": 100 }] } } |
Proposed Backend Architecture
- AWS Kinesis Firehose: Allows to collect events records from the Synapse API, convert the records into an columnar format such as Apache Parquet and store the stream to an S3 destination bucket
- AWS Glue: Glue is used to build the catalog of tables used both by Kinesis Firehose for the record conversion and by Athena to efficiently query the data stored in S3
- AWS Athena Is used to query the data produced by kinetics firehose, the data will be stored using the Apache Parquet format thanks to the Kinesis Firehose automatic conversion
Code Block | ||
---|---|---|
| ||
{
"timestamp": "1562626674712",
"stack": "dev",
"instance": 123,
"projectId": 456,
"userId": 5432,
"associationType": "FileEntity",
"associationId": 12312
"fileId": 6789
} |
statistics_last_update
that simply stores the statistic type (e.g. statistics_project_monthly_download and statistics_project_monthly_upload) and its last update time.statistics_project_monthly
with the following columns:Code Block | ||
---|---|---|
| ||
statistics_project_monthly <project_id, year, month, download_count, download_users_count, upload_count, upload_users_count> |
Note that when the aggregate query is run from a worker, only the projects for which at least one download or upload was recorded will be stored in the table, if no download and uploads were performed on a particular project (e.g. no record is found) the API can simply return a 0 count.
Note also that we can implement a worker per type of statistics, e.g. one that queries the downloads and one that queries the uploads and both store the results in the same table for now. For the moment we can simply have one worker per statistics aggregate.
Finally note that given that we query the data stored in S3 month by month, we can partition the data directly so that Athena will scan only the needed records (See https://docs.aws.amazon.com/athena/latest/ug/partitions.html). We can initially create partitions day by day so that we do not restrict ourselves to always load a month of data for each query that we run using athena, this will produce slightly slower queries for the worker as multiple partitions will need to be loaded, but will gives us more flexibility.
Web Client Integration
The web client should have a way to show the statistics for a project or a specific file, some initial ideas:
...