Overview
SDK Metrics let you track custom data quality metrics from any codebase — ETL pipelines, batch jobs, microservices, or applications. Corelayer builds statistical baselines for each metric partition and alerts you when values deviate from expected ranges.Prerequisites
- A GitHub integration connected to Corelayer (the repository you want to track must be linked)
- Node.js 18+ (for the SDK)
Onboarding
1. Create an API Key
You need an API key to authenticate SDK calls.- In your Corelayer dashboard, go to Settings > API Keys
- Click Create Key
- Give the key a name (e.g.,
Production ETL) and set an expiration (optional) - Copy the key immediately — it will only be shown once
2. Set the Environment Variable
Add the API key as an environment variable in your runtime environment:.env, Docker secrets, CI/CD variables, or your cloud provider’s secret manager).
3. Install the SDK
4. Create a Metric in the Dashboard
- Go to the Anomalies page in your Corelayer dashboard
- Click Add Rule and select a codebase (repository)
- On the metrics listing page, click Create Metric
- Fill in the configuration:
- Metric Name — A human-readable label (e.g.,
Daily Order Volume) - Frequency — How often data is reported (hourly, daily, weekly, monthly)
- Metric Name — A human-readable label (e.g.,
- Copy the Metric ID and the SDK Snippet provided on the page
- Click Save Metric
5. Instrument Your Code
Add the SDK to your pipeline or application:metricId— The UUID from step 4. Identifies which metric this data belongs to.partitions— An array of partition entries. Each entry haskeys(an object of key-value pairs that define the partition) andvalue(the numeric count or measurement).timestamp— An ISO 8601 timestamp. Pass an explicit timestamp for batch jobs to ensure correct ordering, especially for reruns.
6. Deploy and Monitor
Once your code is deployed and sending data, Corelayer will:- Collect data to build a baseline for each partition (status shows Collecting)
- Switch to active monitoring once the baseline is ready (status shows Ready)
- Flag anomalies when values fall outside the expected range
Environment Variables Reference
| Variable | Required | Description |
|---|---|---|
CORELAYER_API_KEY | Yes | API key for authenticating SDK calls. Create one at Settings > API Keys. |
CORELAYER_BASE_URL | Yes | The Corelayer API endpoint. Set to https://api.corelayer.com. |
Viewing Metrics
Metrics Listing
Navigate to Anomalies and click on a codebase to see all SDK metrics for that repository. Each metric card shows:- The metric name (or ID if no name was set)
- Baseline status (Collecting or Ready)
Metric Detail Page
Click on a metric to see the full detail view:- Stat Cards — Total partitions, baselines ready, and anomalies detected in the selected time range
- Time-Series Chart — Visualize metric values over time for up to 10 partitions. Switch between count, min, max, and avg using the dropdown.
- Partition Table — Browse all partitions with search and pagination. Each row shows the partition keys, current metric values, baseline statistics, and anomaly count.
Anomaly Findings
When anomalies are detected, they appear in the Anomalies column of the partition table. Click the count badge to expand and see detailed findings:- Severity — Critical, High, Medium, Low, or Info
- Observed vs. Expected — The actual value compared to what the baseline predicted
- Bounds — The upper and lower thresholds that were breached
- Timestamp — When the anomaly was detected
Tips
- Use descriptive partition keys — Keys like
region,pipeline, ortable_namemake findings easier to diagnose. - Set explicit timestamps for batch jobs — This ensures data is bucketed correctly, even during reruns.
- Call
client.shutdown()— Always call shutdown before your process exits to flush any buffered metrics. - One metric per logical measurement — Create separate metrics for different measurements (e.g.,
Order VolumeandPayment Processing Time) rather than mixing them.
Managing Metrics
Deleting Metrics
On the metrics listing page, select one or more metrics using the checkboxes and click Delete Selected. This removes the metric configuration and all associated baselines and findings.Rotating API Keys
If you need to rotate your API key:- Go to Settings > API Keys
- Click the rotate icon next to the key
- Copy the new key and update your environment variable
- The old key is revoked immediately

