# Metrics Layer
![Github Actions](https://github.com/Zenlytic/metrics_layer/actions/workflows/tests.yaml/badge.svg)
[![codecov](https://codecov.io/gh/Zenlytic/metrics_layer/branch/master/graph/badge.svg?token=7JA6PKNV57)](https://codecov.io/gh/Zenlytic/metrics_layer)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
# What is a Metrics Layer?
Metrics Layer is an open source project with the goal of making access to metrics consistent throughout an organization. We believe you should be able to access consistent metrics from any tool you use to access data. This metrics layer is designed to work with [Zenlytic](https://zenlytic.com) as a BI tool.
## How does it work?
[Zenlytic](https://zenlytic.com) is the only supported BI tool. The Metrics Layer will read your data model and give you the ability to access those metrics and dimensions in a python client library, or through SQL with a special `MQL` tag.
Sound interesting? Here's how to set Metrics Layer up with your data model and start querying your metrics in **in under 2 minutes**.
## Installation
Make sure that your data warehouse is one of the supported types. Metrics Layer currently supports Snowflake, BigQuery, Postgres, Druid (only SQL compilation, not running the query), Duck DB (only SQL compilation, not running the query), and Redshift, and only works with `python >= 3.8` up to `python < 3.11`.
Install Metrics Layer with the appropriate extra for your warehouse
For Snowflake run `pip install metrics-layer[snowflake]`
For BigQuery run `pip install metrics-layer[bigquery]`
For Redshift run `pip install metrics-layer[redshift]`
For Postgres run `pip install metrics-layer[postgres]`
## Profile set up
There are several ways to set up a profile, we're going to look at the fastest one here.
The fastest way to get connected is to pass the necessary information directly into Metrics Layer. Once you've installed the library with the warehouse you need, you should be able to run the code snippet below and start querying.
You'll pull the repo from Github for this example. For more detail on getting set up, check out the [documentation](https://docs.zenlytic.com)!
```
from metrics_layer import MetricsLayerConnection
# Give metrics_layer the info to connect to your data model and warehouse
config = {
"location": "https://myusername:myaccesstoken@github.com/myorg/myrepo.git",
"branch": "develop",
"connections": [
{
"name": "mycompany", # The name of the connection in your data model (you'll see this in model files)
"type": "snowflake",
"account": "2e12ewdq.us-east-1",
"username": "demo_user",
"password": "q23e13erfwefqw",
"database": "ANALYTICS",
"schema": "DEV", # Optional
}
],
}
conn = MetricsLayerConnection(**config)
# You're off to the races. Query away!
df = conn.query(metrics=["total_revenue"], dimensions=["channel", "region"])
```
That's it.
For more advanced methods of connection and more information about the project check out [the docs](https://docs.zenlytic.com).
Raw data
{
"_id": null,
"home_page": "https://github.com/Zenlytic/metrics_layer",
"name": "metrics-layer",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8.1,<3.12",
"maintainer_email": "",
"keywords": "Metrics Layer,Business Intelligence,Analytics",
"author": "Paul Blankley",
"author_email": "paul@zenlytic.com",
"download_url": "https://files.pythonhosted.org/packages/a5/52/438f9d615f88a7937b94da446d1266f4746bcb9fb4066d3fd58012e22858/metrics_layer-0.10.49.tar.gz",
"platform": null,
"description": "# Metrics Layer\n\n![Github Actions](https://github.com/Zenlytic/metrics_layer/actions/workflows/tests.yaml/badge.svg)\n[![codecov](https://codecov.io/gh/Zenlytic/metrics_layer/branch/master/graph/badge.svg?token=7JA6PKNV57)](https://codecov.io/gh/Zenlytic/metrics_layer)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# What is a Metrics Layer?\n\nMetrics Layer is an open source project with the goal of making access to metrics consistent throughout an organization. We believe you should be able to access consistent metrics from any tool you use to access data. This metrics layer is designed to work with [Zenlytic](https://zenlytic.com) as a BI tool. \n\n## How does it work?\n\n[Zenlytic](https://zenlytic.com) is the only supported BI tool. The Metrics Layer will read your data model and give you the ability to access those metrics and dimensions in a python client library, or through SQL with a special `MQL` tag.\n\nSound interesting? Here's how to set Metrics Layer up with your data model and start querying your metrics in **in under 2 minutes**.\n\n## Installation\n\nMake sure that your data warehouse is one of the supported types. Metrics Layer currently supports Snowflake, BigQuery, Postgres, Druid (only SQL compilation, not running the query), Duck DB (only SQL compilation, not running the query), and Redshift, and only works with `python >= 3.8` up to `python < 3.11`.\n\nInstall Metrics Layer with the appropriate extra for your warehouse\n\nFor Snowflake run `pip install metrics-layer[snowflake]`\n\nFor BigQuery run `pip install metrics-layer[bigquery]`\n\nFor Redshift run `pip install metrics-layer[redshift]`\n\nFor Postgres run `pip install metrics-layer[postgres]`\n\n\n## Profile set up\n\nThere are several ways to set up a profile, we're going to look at the fastest one here.\n\nThe fastest way to get connected is to pass the necessary information directly into Metrics Layer. Once you've installed the library with the warehouse you need, you should be able to run the code snippet below and start querying.\n\nYou'll pull the repo from Github for this example. For more detail on getting set up, check out the [documentation](https://docs.zenlytic.com)!\n\n\n```\nfrom metrics_layer import MetricsLayerConnection\n\n# Give metrics_layer the info to connect to your data model and warehouse\nconfig = {\n \"location\": \"https://myusername:myaccesstoken@github.com/myorg/myrepo.git\",\n \"branch\": \"develop\",\n \"connections\": [\n {\n \"name\": \"mycompany\", # The name of the connection in your data model (you'll see this in model files)\n \"type\": \"snowflake\",\n \"account\": \"2e12ewdq.us-east-1\",\n \"username\": \"demo_user\",\n \"password\": \"q23e13erfwefqw\",\n \"database\": \"ANALYTICS\",\n \"schema\": \"DEV\", # Optional\n }\n ],\n}\nconn = MetricsLayerConnection(**config)\n\n# You're off to the races. Query away!\ndf = conn.query(metrics=[\"total_revenue\"], dimensions=[\"channel\", \"region\"])\n```\n\nThat's it.\n\nFor more advanced methods of connection and more information about the project check out [the docs](https://docs.zenlytic.com).\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "The open source metrics layer.",
"version": "0.10.49",
"project_urls": {
"Documentation": "https://docs.zenlytic.com",
"Homepage": "https://github.com/Zenlytic/metrics_layer",
"Repository": "https://github.com/Zenlytic/metrics_layer"
},
"split_keywords": [
"metrics layer",
"business intelligence",
"analytics"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6aa24624b43d5166b4b675f6a6c5ec2c31c9bd5cb63071e9815422b7eb321af2",
"md5": "e53d7a3f17a76c183597d9a0e4de31f7",
"sha256": "901bb008cc478f6a6664ccb15fd79bc373f74d8b40ad9ac13e73b31fc1068ff8"
},
"downloads": -1,
"filename": "metrics_layer-0.10.49-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e53d7a3f17a76c183597d9a0e4de31f7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.1,<3.12",
"size": 101668,
"upload_time": "2023-11-18T17:29:30",
"upload_time_iso_8601": "2023-11-18T17:29:30.281744Z",
"url": "https://files.pythonhosted.org/packages/6a/a2/4624b43d5166b4b675f6a6c5ec2c31c9bd5cb63071e9815422b7eb321af2/metrics_layer-0.10.49-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a552438f9d615f88a7937b94da446d1266f4746bcb9fb4066d3fd58012e22858",
"md5": "21573ec3a348f3481e5bdc9b9923f111",
"sha256": "926d0afab2c7a115a2dbe5424955b5c8512c43458898e8e7778f67dd11773260"
},
"downloads": -1,
"filename": "metrics_layer-0.10.49.tar.gz",
"has_sig": false,
"md5_digest": "21573ec3a348f3481e5bdc9b9923f111",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.1,<3.12",
"size": 83218,
"upload_time": "2023-11-18T17:29:32",
"upload_time_iso_8601": "2023-11-18T17:29:32.736421Z",
"url": "https://files.pythonhosted.org/packages/a5/52/438f9d615f88a7937b94da446d1266f4746bcb9fb4066d3fd58012e22858/metrics_layer-0.10.49.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-18 17:29:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Zenlytic",
"github_project": "metrics_layer",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "metrics-layer"
}