Skip to main content

Metrics Layer

Github Actions codecov Code style: 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 as a BI tool.

How does it work?

Zenlytic 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), DuckDB (only SQL compilation, not running the query), SQL Server (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!

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"])

For more advanced methods of connection and more information about the project check out the docs

Metadata

Release files for metrics_layer 0.16.47

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metrics_layer 0.16.47
File Size Uploaded Provenance Actions
metrics_layer-0.16.47.tar.gz 143.6 kB Without provenance Details for metrics_layer-0.16.47.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for metrics_layer 0.16.47
File Interpreter ABI Platform Actions
metrics_layer-0.16.47-py3-none-any.whl Python 3 none any Details for metrics_layer-0.16.47-py3-none-any.whl

Total release size: 311.0 kB

Release files / metrics_layer-0.16.47.tar.gz

Download URL metrics_layer-0.16.47.tar.gz
Size 143.6 kB
Tags Source
SHA-256 checksum
How to use checksums
598fc3f571fbb19787753a49e529c6cc60408542a915fcdd0fcaf08be7493964
BLAKE2b-256 checksum
How to use checksums
0d6abee60f69967ba6ff37f3b7d7084db679fe04bb2766c7984b9702078b267b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.18 Linux/7.0.0-1019-azure

Release files / metrics_layer-0.16.47-py3-none-any.whl

Download URL metrics_layer-0.16.47-py3-none-any.whl
Size 167.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4eae8c3b89b906ea5b10c762a2424985b5e775fe2720cb1f6bc06c92fd43768
BLAKE2b-256 checksum
How to use checksums
491cbe337bb171dcc094ea1631d86677399fe4bfe16975a4361765e4e0ea2448
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.18 Linux/7.0.0-1019-azure

Security for metrics_layer 0.16.47

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.16.47 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page