Skip to main content

The open source metrics layer.

Project description

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metrics_layer-0.12.44.tar.gz (112.8 kB view details)

Uploaded Source

Built Distribution

metrics_layer-0.12.44-py3-none-any.whl (133.9 kB view details)

Uploaded Python 3

File details

Details for the file metrics_layer-0.12.44.tar.gz.

File metadata

  • Download URL: metrics_layer-0.12.44.tar.gz
  • Upload date:
  • Size: 112.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.8.18 Linux/6.5.0-1025-azure

File hashes

Hashes for metrics_layer-0.12.44.tar.gz
Algorithm Hash digest
SHA256 4d8471c8d2b97f1327ee30b277d8a99a5f8bae7a227d339a71814c44f63ddb85
MD5 e9f39efe5f3a771bd26e4ef71eed08f1
BLAKE2b-256 77910c170a8e415ffdd32106ad6daea134a8aa6ba377df2c7c54defead51218a

See more details on using hashes here.

File details

Details for the file metrics_layer-0.12.44-py3-none-any.whl.

File metadata

  • Download URL: metrics_layer-0.12.44-py3-none-any.whl
  • Upload date:
  • Size: 133.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.8.18 Linux/6.5.0-1025-azure

File hashes

Hashes for metrics_layer-0.12.44-py3-none-any.whl
Algorithm Hash digest
SHA256 3ce5354a8a1ce44e6f46560fbae787bea8289e1c9bab3591dd66d8bff6092274
MD5 99ea3dffb45ad9569d38a833502ca0e3
BLAKE2b-256 d4786d45e3a0691cef266644786ca5d2f9b7340992206d78741d3b6031cc13b6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page