Instrument any pipeline or application with the Corelayer SDK to push custom metrics, build baselines per partition, and detect anomalies in your own data.
API metrics let you track custom data quality metrics from any codebase — ETL pipelines, batch jobs, microservices, or applications. You push observations with the Corelayer SDK; Corelayer builds a statistical baseline for each partition and raises findings when values fall outside the expected band.
Anomaly rule name — a human-readable label, for example Daily Order Volume
Expected cadence — how often your application sends this metric (hourly, daily, weekly, monthly)
Detector — which statistical method scores the metric. Baseline is the default; see Detectors.
Minimum data points — how many observations to learn before flagging. Leave blank for the detector default.
Copy the Metric ID and the SDK snippet from the page
Click Save
The page also offers a Copy agent instructions button, which puts a short Markdown brief on your clipboard — paste it into a coding agent to have it wire up the SDK for you.
import { CorelayerClient } from '@corelayer-ai/sdk';const client = new CorelayerClient({ apiKey: process.env.CORELAYER_API_KEY, baseUrl: process.env.CORELAYER_BASE_URL,});client.trackMetric({ metricId: "<your-metric-id>", partitions: [ { keys: { "region": "us-east-1", "table": "orders" }, value: 1523 }, ], timestamp: "2025-01-15T00:00:00Z",});// Call at process exit to flush remaining metricsawait client.shutdown();
Parameters:
metricId — the UUID from step 4. Identifies which rule this data belongs to.
partitions — an array of partition entries. Each has keys (an object of key/value pairs identifying the partition) and value (the numeric measurement). Each unique key combination gets its own baseline.
timestamp — an ISO 8601 timestamp. Optional; defaults to now. Pass it explicitly for batch jobs so reruns bucket correctly.
Always set CORELAYER_BASE_URL. If you omit baseUrl, the SDK falls back to a built-in default that is not the production API.
From Anomaly Rules, the API section groups codebases by account and shows how many rules each has. Open a codebase to see its rules. Each row shows the rule name, its cadence, and whether the baseline is Collecting or Ready.
Stat cards — partitions observed, baselines ready, and anomalies detected in the selected range
Time range selector — presets scaled to the rule’s cadence (an hourly rule offers 1d/3d/7d, a daily rule 7d/14d/30d, a weekly rule 90d/6mo/1y, a monthly rule 6mo/1y/2y)
Partition Inspector — a searchable, paginated list of partitions showing mean, min, and max with a sparkline. Select one to load its chart, baseline state, and findings.
Anomaly findings — findings for the selected partition
Click Configure to open the Settings tab and edit the rule.
Use descriptive partition keys — keys like region, pipeline, or table_name make findings easier to diagnose.
Set explicit timestamps for batch jobs — this keeps data bucketed correctly, even during reruns.
Call client.shutdown() — always flush before your process exits, or the last batch is lost.
One rule per logical measurement — keep Order Volume and Payment Processing Time as separate rules rather than mixing them.
Do not over-partition — every unique key combination needs enough observations of its own to train. Too many partitions means none of them reach Ready.
Open the rule and switch to Settings. Changing the detector retrains from stored history automatically. Changing the expected cadence re-buckets observations, so Corelayer asks whether to keep the existing baseline or reset it — keeping it can produce noisy findings until enough new observations arrive.Reset Baseline discards learned state and rebuilds from scratch on the next run.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Corelayer","colors":{"primary":"#4a6bd9","light":"#4a6bd9","dark":"#4a6bd9"},"logo":{"light":"https://mintcdn.com/sevvy/YKD559-ekHCfmat3/logo/corelayer_wordmark_light.svg?fit=max\u0026auto=format\u0026n=YKD559-ekHCfmat3\u0026q=85\u0026s=bbbe263b6369af258800f17af292c8b5","dark":"https://mintcdn.com/sevvy/YKD559-ekHCfmat3/logo/corelayer_wordmark_dark.svg?fit=max\u0026auto=format\u0026n=YKD559-ekHCfmat3\u0026q=85\u0026s=13eece44e0ead5cadc7272fe4e9821e5"},"favicon":"https://mintcdn.com/sevvy/ffg0KUwYL86UnS6k/favicon.ico?fit=max\u0026auto=format\u0026n=ffg0KUwYL86UnS6k\u0026q=85\u0026s=cae3fb05d62f06e5a09e39947f8332e6","navbar":{"links":[{"href":"mailto:support@corelayer.com","label":"Support"}]},"footer":{"socials":{"x":"https://x.com/CorelayerAI","linkedin":"https://www.linkedin.com/company/corelayerai"}},"seo":{"metatags":{"canonical":"https://docs.corelayer.com"}},"contextual":{"options":["copy"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"sevvy","hasAudioNarration":false,"actualSubdomain":"sevvy","customDomains":["docs.corelayer.com"],"gitSource":{"type":"github","owner":"corelayers","repo":"sevvy-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae4120c34e53f17f0e16fb7","collectionId":"41af77cc-0db2-4d9d-be01-4cbc0827f55a","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae4120c34e53f17f0e16fb7"},"feedback":{"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae4120c34e53f17f0e16fb7","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"Documentation","count":34},{"language":"default","tag":"Integrations","count":19},{"language":"default","tag":"Updates","count":10},{"language":"default","tag":"Changelog","count":10},{"language":"default","tag":"Webhooks","count":6},{"language":"default","tag":"Platforms \u0026 Workflow","count":4},{"language":"default","tag":"Cloud Providers","count":4},{"language":"default","tag":"Anomaly Detection","count":3},{"language":"default","tag":"Developer Tools","count":3},{"language":"default","tag":"Databases","count":2}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"anomalies/sdk-metrics","slug":"/anomalies/sdk-metrics","pageMetadata":{"title":"API Metrics: Track Custom Pipeline Metrics","description":"Instrument any pipeline or application with the Corelayer SDK to push custom metrics, build baselines per partition, and detect anomalies in your own data.","href":"/anomalies/sdk-metrics"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Instrument any pipeline or application with the Corelayer SDK to push custom metrics, build baselines per partition, and detect anomalies in your own data.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note,Table,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`overview`,children:`Overview`}),`\n`,_jsx(_components.p,{children:`API metrics let you track custom data quality metrics from any codebase — ETL pipelines, batch jobs, microservices, or applications. You push observations with the Corelayer SDK; Corelayer builds a statistical baseline for each partition and raises findings when values fall outside the expected band.`}),`\n`,_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`A connected GitHub or GitLab integration, with the repository you want to track synced to Corelayer`}),`\n`,_jsxs(_components.li,{children:[`Node.js 18 or later (the SDK uses the built-in `,_jsx(_components.code,{children:`fetch`}),`)`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`onboarding`,children:`Onboarding`}),`\n`,_jsx(Heading,{level:`3`,id:`1-create-an-api-key`,children:`1. Create an API key`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`In your Corelayer dashboard, go to `,_jsx(_components.strong,{children:`Settings > API Keys`})]}),`\n`,_jsxs(_components.li,{children:[`Click `,_jsx(_components.strong,{children:`Create Key`})]}),`\n`,_jsxs(_components.li,{children:[`Give it a name (for example `,_jsx(_components.code,{children:`Production ETL`}),`) and choose an expiration — never, 30, 60, or 90 days, or 1 year`]}),`\n`,_jsxs(_components.li,{children:[`Click `,_jsx(_components.strong,{children:`Create`})]}),`\n`,_jsxs(_components.li,{children:[`Copy the key immediately. It starts with `,_jsx(_components.code,{children:`cl_live_`}),` and is shown only once.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`2-set-the-environment-variables`,children:`2. Set the environment variables`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` CORELAYER_API_KEY`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"cl_live_your_api_key_here\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` CORELAYER_BASE_URL`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.corelayer.com\"`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`For production, set both in your environment configuration — `,_jsx(_components.code,{children:`.env`}),`, Docker secrets, CI/CD variables, or your cloud provider’s secret manager.`]}),`\n`,_jsx(Heading,{level:`3`,id:`3-install-the-sdk`,children:`3. Install the SDK`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @corelayer-ai/sdk`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`4-create-the-rule-in-the-dashboard`,children:`4. Create the rule in the dashboard`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Go to `,_jsx(_components.strong,{children:`Anomaly Rules`}),` and click `,_jsx(_components.strong,{children:`Add`})]}),`\n`,_jsxs(_components.li,{children:[`Under `,_jsx(_components.strong,{children:`Codebases`}),`, pick the repository`]}),`\n`,_jsxs(_components.li,{children:[`Click `,_jsx(_components.strong,{children:`Add API metric`})]}),`\n`,_jsxs(_components.li,{children:[`Fill in the configuration:`,`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Anomaly rule name`}),` — a human-readable label, for example `,_jsx(_components.code,{children:`Daily Order Volume`})]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Expected cadence`}),` — how often your application sends this metric (hourly, daily, weekly, monthly)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Detector`}),` — which statistical method scores the metric. `,_jsx(_components.code,{children:`Baseline`}),` is the default; see `,_jsx(_components.a,{href:`/anomalies/overview#detectors`,children:`Detectors`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Minimum data points`}),` — how many observations to learn before flagging. Leave blank for the detector default.`]}),`\n`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`Copy the `,_jsx(_components.strong,{children:`Metric ID`}),` and the `,_jsx(_components.strong,{children:`SDK snippet`}),` from the page`]}),`\n`,_jsxs(_components.li,{children:[`Click `,_jsx(_components.strong,{children:`Save`})]}),`\n`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`The page also offers a `,_jsx(_components.strong,{children:`Copy agent instructions`}),` button, which puts a short Markdown brief on your clipboard — paste it into a coding agent to have it wire up the SDK for you.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`5-instrument-your-code`,children:`5. Instrument your code`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`17`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`CorelayerClient`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@corelayer-ai/sdk'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` client`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` CorelayerClient`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` apiKey:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`CORELAYER_API_KEY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` baseUrl:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`CORELAYER_BASE_URL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`trackMetric`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` metricId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cyour-metric-id>\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` partitions:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`keys:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"region\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"us-east-1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"table\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"orders\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`value:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1523`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` timestamp:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"2025-01-15T00:00:00Z\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Call at process exit to flush remaining metrics`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`shutdown`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Parameters`}),`:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`metricId`}),` — the UUID from step 4. Identifies which rule this data belongs to.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`partitions`}),` — an array of partition entries. Each has `,_jsx(_components.code,{children:`keys`}),` (an object of key/value pairs identifying the partition) and `,_jsx(_components.code,{children:`value`}),` (the numeric measurement). Each unique key combination gets its own baseline.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`timestamp`}),` — an ISO 8601 timestamp. Optional; defaults to now. Pass it explicitly for batch jobs so reruns bucket correctly.`]}),`\n`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Always set `,_jsx(_components.code,{children:`CORELAYER_BASE_URL`}),`. If you omit `,_jsx(_components.code,{children:`baseUrl`}),`, the SDK falls back to a built-in default that is not the production API.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`6-deploy-and-monitor`,children:`6. Deploy and monitor`}),`\n`,_jsx(_components.p,{children:`Once your code is deployed and sending data, Corelayer will:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Collect observations to build a baseline for each partition — the rule shows `,_jsx(_components.strong,{children:`Collecting`})]}),`\n`,_jsxs(_components.li,{children:[`Switch to active monitoring once a partition has enough data — it shows `,_jsx(_components.strong,{children:`Ready`})]}),`\n`,_jsx(_components.li,{children:`Flag observations that fall outside the expected band`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`client-configuration`,children:`Client Configuration`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`trackMetric`}),` queues locally and flushes in the background, so it does not block your pipeline.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Option`}),_jsx(_components.th,{children:`Default`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`apiKey`})}),_jsx(_components.td,{children:`—`}),_jsxs(_components.td,{children:[`Required. Your `,_jsx(_components.code,{children:`cl_live_`}),` API key.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`baseUrl`})}),_jsx(_components.td,{children:`—`}),_jsxs(_components.td,{children:[`Set to `,_jsx(_components.code,{children:`https://api.corelayer.com`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`flushIntervalMs`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`5000`})}),_jsx(_components.td,{children:`How often the queue is flushed.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`maxBatchSize`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`100`})}),_jsx(_components.td,{children:`Batch size. Reaching it triggers an immediate flush.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`maxQueueSize`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`1000`})}),_jsx(_components.td,{children:`Queue cap before entries are dropped.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`maxRetries`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`4`})}),_jsxs(_components.td,{children:[`Retries per batch on `,_jsx(_components.code,{children:`429`}),` and `,_jsx(_components.code,{children:`5xx`}),`, with backoff of 500ms, 1s, 2s, 4s, honoring `,_jsx(_components.code,{children:`Retry-After`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`timeoutMs`})}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`5000`})}),_jsx(_components.td,{children:`Per-request timeout.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`debug`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`false`})}),_jsx(_components.td,{children:`Log delivery failures to the console.`})]})]})]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`flush()`}),` and `,_jsx(_components.code,{children:`shutdown()`}),` do not throw on delivery failure. Set `,_jsx(_components.code,{children:`debug: true`}),` while integrating so failed batches are visible.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`environment-variables-reference`,children:`Environment Variables Reference`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Variable`}),_jsx(_components.th,{children:`Required`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`CORELAYER_API_KEY`})}),_jsx(_components.td,{children:`Yes`}),_jsxs(_components.td,{children:[`API key for authenticating SDK calls. Create one at `,_jsx(_components.strong,{children:`Settings > API Keys`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`CORELAYER_BASE_URL`})}),_jsx(_components.td,{children:`Yes`}),_jsxs(_components.td,{children:[`The Corelayer API endpoint. Set to `,_jsx(_components.code,{children:`https://api.corelayer.com`}),`.`]})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`viewing-metrics`,children:`Viewing Metrics`}),`\n`,_jsx(Heading,{level:`3`,id:`rule-listing`,children:`Rule listing`}),`\n`,_jsxs(_components.p,{children:[`From `,_jsx(_components.strong,{children:`Anomaly Rules`}),`, the `,_jsx(_components.strong,{children:`API`}),` section groups codebases by account and shows how many rules each has. Open a codebase to see its rules. Each row shows the rule name, its cadence, and whether the baseline is `,_jsx(_components.strong,{children:`Collecting`}),` or `,_jsx(_components.strong,{children:`Ready`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`rule-detail-page`,children:`Rule detail page`}),`\n`,_jsxs(_components.p,{children:[`Open a rule to see the `,_jsx(_components.strong,{children:`Overview`}),` tab:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Stat cards`}),` — partitions observed, baselines ready, and anomalies detected in the selected range`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Time range selector`}),` — presets scaled to the rule’s cadence (an hourly rule offers 1d/3d/7d, a daily rule 7d/14d/30d, a weekly rule 90d/6mo/1y, a monthly rule 6mo/1y/2y)`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Partition Inspector`}),` — a searchable, paginated list of partitions showing mean, min, and max with a sparkline. Select one to load its chart, baseline state, and findings.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Anomaly findings`}),` — findings for the selected partition`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Click `,_jsx(_components.strong,{children:`Configure`}),` to open the `,_jsx(_components.strong,{children:`Settings`}),` tab and edit the rule.`]}),`\n`,_jsx(Heading,{level:`3`,id:`anomaly-findings`,children:`Anomaly findings`}),`\n`,_jsx(_components.p,{children:`Each finding shows:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Severity`}),` — Critical, High, Medium, Low, or Info`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Detector`}),` — which method produced it`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Observed vs. Expected`}),` — the actual value against what the baseline predicted`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Expected range`}),` — the bounds that were breached`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Timestamp`}),` — when it was detected`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Linked issue`}),` — if the finding opened a Corelayer issue, a link to it and whether it is still open`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`tips`,children:`Tips`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Use descriptive partition keys`}),` — keys like `,_jsx(_components.code,{children:`region`}),`, `,_jsx(_components.code,{children:`pipeline`}),`, or `,_jsx(_components.code,{children:`table_name`}),` make findings easier to diagnose.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Set explicit timestamps for batch jobs`}),` — this keeps data bucketed correctly, even during reruns.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[`Call `,_jsx(_components.code,{children:`client.shutdown()`})]}),` — always flush before your process exits, or the last batch is lost.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`One rule per logical measurement`}),` — keep `,_jsx(_components.code,{children:`Order Volume`}),` and `,_jsx(_components.code,{children:`Payment Processing Time`}),` as separate rules rather than mixing them.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Do not over-partition`}),` — every unique key combination needs enough observations of its own to train. Too many partitions means none of them reach `,_jsx(_components.strong,{children:`Ready`}),`.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`managing-rules`,children:`Managing Rules`}),`\n`,_jsx(Heading,{level:`3`,id:`changing-the-detector-or-cadence`,children:`Changing the detector or cadence`}),`\n`,_jsxs(_components.p,{children:[`Open the rule and switch to `,_jsx(_components.strong,{children:`Settings`}),`. Changing the `,_jsx(_components.strong,{children:`detector`}),` retrains from stored history automatically. Changing the `,_jsx(_components.strong,{children:`expected cadence`}),` re-buckets observations, so Corelayer asks whether to keep the existing baseline or reset it — keeping it can produce noisy findings until enough new observations arrive.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Reset Baseline`}),` discards learned state and rebuilds from scratch on the next run.`]}),`\n`,_jsx(Heading,{level:`3`,id:`deleting-rules`,children:`Deleting rules`}),`\n`,_jsxs(_components.p,{children:[`On a codebase’s rule list, select one or more rules with the checkboxes and click `,_jsx(_components.strong,{children:`Delete`}),`. This permanently removes the rules and their history.`]}),`\n`,_jsx(Heading,{level:`3`,id:`rotating-api-keys`,children:`Rotating API keys`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Go to `,_jsx(_components.strong,{children:`Settings > API Keys`})]}),`\n`,_jsx(_components.li,{children:`Click the rotate icon next to the key`}),`\n`,_jsxs(_components.li,{children:[`Copy the new key and update `,_jsx(_components.code,{children:`CORELAYER_API_KEY`})]}),`\n`,_jsx(_components.li,{children:`The old key is revoked immediately`}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Need help? `,_jsx(_components.a,{href:`mailto:support@corelayer.com`,children:`Contact support`}),` for assistance with API metrics.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"API Metrics: Track Custom Pipeline Metrics","description":"Instrument any pipeline or application with the Corelayer SDK to push custom metrics, build baselines per partition, and detect anomalies in your own data.","href":"/anomalies/sdk-metrics"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Overview","slug":"overview","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Onboarding","slug":"onboarding","depth":2,"children":[{"title":"1. Create an API key","slug":"1-create-an-api-key","depth":3,"children":[]},{"title":"2. Set the environment variables","slug":"2-set-the-environment-variables","depth":3,"children":[]},{"title":"3. Install the SDK","slug":"3-install-the-sdk","depth":3,"children":[]},{"title":"4. Create the rule in the dashboard","slug":"4-create-the-rule-in-the-dashboard","depth":3,"children":[]},{"title":"5. Instrument your code","slug":"5-instrument-your-code","depth":3,"children":[]},{"title":"6. Deploy and monitor","slug":"6-deploy-and-monitor","depth":3,"children":[]}]},{"title":"Client Configuration","slug":"client-configuration","depth":2,"children":[]},{"title":"Environment Variables Reference","slug":"environment-variables-reference","depth":2,"children":[]},{"title":"Viewing Metrics","slug":"viewing-metrics","depth":2,"children":[{"title":"Rule listing","slug":"rule-listing","depth":3,"children":[]},{"title":"Rule detail page","slug":"rule-detail-page","depth":3,"children":[]},{"title":"Anomaly findings","slug":"anomaly-findings","depth":3,"children":[]}]},{"title":"Tips","slug":"tips","depth":2,"children":[]},{"title":"Managing Rules","slug":"managing-rules","depth":2,"children":[{"title":"Changing the detector or cadence","slug":"changing-the-detector-or-cadence","depth":3,"children":[]},{"title":"Deleting rules","slug":"deleting-rules","depth":3,"children":[]},{"title":"Rotating API keys","slug":"rotating-api-keys","depth":3,"children":[]}]}],"codeExamples":{}},"jsLinks":[],"subdomain":"sevvy","siteName":"Corelayer","title":"API Metrics: Track Custom Pipeline Metrics - Corelayer","relatedPagesConfig":{"enabled":true,"limit":3,"mode":"automatic"},"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-11T18:19:59.584Z","originalFileLocation":"anomalies/sdk-metrics.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Instrument any pipeline or application with the Corelayer SDK to push custom metrics, build baselines per partition, and detect anomalies in your own data.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Corelayer\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"API Metrics: Track Custom Pipeline Metrics - Corelayer\">\u003cmeta data-mint-head property=\"og:description\" content=\"Instrument any pipeline or application with the Corelayer SDK to push custom metrics, build baselines per partition, and detect anomalies in your own data.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Corelayer\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.corelayer.com/anomalies/sdk-metrics\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://sevvy.mintlify.app/_mintlify/api/og/v2?division=Anomaly+Detection\u0026amp;title=API+Metrics%3A+Track+Custom+Pipeline+Metrics\u0026amp;description=Instrument+any+pipeline+or+application+with+the+Corelayer+SDK+to+push+custom+metrics%2C+build+baselines+per+partition%2C+and+detect+anomalies+in+your+own+data.\u0026amp;theme=e7e58e353cdaec7c6b63ee26\u0026amp;signature=0eb9769589474b1e4434842208b6e856aae76f60722abdcbf2dc619804dc5dfd\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"API Metrics: Track Custom Pipeline Metrics - Corelayer\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Instrument any pipeline or application with the Corelayer SDK to push custom metrics, build baselines per partition, and detect anomalies in your own data.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://sevvy.mintlify.app/_mintlify/api/og/v2?division=Anomaly+Detection\u0026amp;title=API+Metrics%3A+Track+Custom+Pipeline+Metrics\u0026amp;description=Instrument+any+pipeline+or+application+with+the+Corelayer+SDK+to+push+custom+metrics%2C+build+baselines+per+partition%2C+and+detect+anomalies+in+your+own+data.\u0026amp;theme=e7e58e353cdaec7c6b63ee26\u0026amp;signature=0eb9769589474b1e4434842208b6e856aae76f60722abdcbf2dc619804dc5dfd\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/sevvy/OMjtEtL3O7qg_wIl/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Corelayer\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#4a6bd9\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.corelayer.com/anomalies/sdk-metrics\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/anomalies/sdk-metrics.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.corelayer.com/#organization\",\"name\":\"Corelayer\",\"url\":\"https://docs.corelayer.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/sevvy/YKD559-ekHCfmat3/logo/corelayer_wordmark_light.svg?fit=max\u0026auto=format\u0026n=YKD559-ekHCfmat3\u0026q=85\u0026s=bbbe263b6369af258800f17af292c8b5\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.corelayer.com#website\",\"name\":\"Corelayer\",\"url\":\"https://docs.corelayer.com\",\"publisher\":{\"@id\":\"https://docs.corelayer.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.corelayer.com/anomalies/sdk-metrics#webpage\",\"url\":\"https://docs.corelayer.com/anomalies/sdk-metrics\",\"name\":\"API Metrics: Track Custom Pipeline Metrics\",\"description\":\"Instrument any pipeline or application with the Corelayer SDK to push custom metrics, build baselines per partition, and detect anomalies in your own data.\",\"dateModified\":\"2026-09-11T18:19:59.584Z\",\"isPartOf\":{\"@id\":\"https://docs.corelayer.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.corelayer.com/anomalies/sdk-metrics#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.corelayer.com/anomalies/sdk-metrics#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anomaly Detection\",\"item\":\"https://docs.corelayer.com/anomalies/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"API Metrics: Track Custom Pipeline Metrics\",\"item\":\"https://docs.corelayer.com/anomalies/sdk-metrics\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.corelayer.com/anomalies/sdk-metrics#article\",\"headline\":\"API Metrics: Track Custom Pipeline Metrics\",\"name\":\"API Metrics: Track Custom Pipeline Metrics\",\"description\":\"Instrument any pipeline or application with the Corelayer SDK to push custom metrics, build baselines per partition, and detect anomalies in your own data.\",\"url\":\"https://docs.corelayer.com/anomalies/sdk-metrics\",\"mainEntityOfPage\":{\"@id\":\"https://docs.corelayer.com/anomalies/sdk-metrics#webpage\"},\"dateModified\":\"2026-09-11T18:19:59.584Z\",\"publisher\":{\"@id\":\"https://docs.corelayer.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.corelayer.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Corelayer\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Corelayer","nav":{"global":null,"tabs":[{"tab":"Documentation","groups":[{"group":"Get Started","pages":[{"title":"What is Corelayer? AI SRE for Production","href":""}]},{"group":"Anomaly Detection","pages":[{"title":"Anomaly Detection for Data Pipelines","href":"/anomalies/overview"},{"title":"Database Table Monitoring and Alerts","description":"Describe an anomaly in plain English, let Corelayer compile it to read-only SQL, and monitor any table in a connected PostgreSQL or ClickHouse database on a schedule.","href":"/anomalies/table-monitoring"},{"title":"API Metrics: Track Custom Pipeline Metrics","href":"/anomalies/sdk-metrics"}]},{"group":"Organization Memory","pages":[{"title":"Organization Memory: Learn From Incidents","description":"Corelayer retains feedback and prior incident context, then applies that memory to suppress repeat alert noise and sharpen future root-cause analysis.","href":"/memory/overview"}]},{"group":"Security \u0026 Privacy","pages":[{"title":"PII Masking and Data Redaction","href":"/security/pii-masking"}]},{"group":"Integrations","pages":[{"group":"Cloud Providers","pages":[{"title":"AWS Integration: CloudWatch, RDS, and S3","href":"/integrations/aws"},{"title":"GCP Integration: Cloud Run, GKE, Functions","href":"/integrations/gcp"},{"title":"Cloudflare Integration: Debug Workers","href":"/integrations/cloudflare"},{"title":"Oracle Cloud (OCI) Integration and Logs","href":"/integrations/oci"}]},{"group":"Observability","pages":[{"title":"Datadog Integration: Add an AI SRE Layer","href":"/integrations/datadog"},{"title":"Sentry Integration: AI Error Debugging","href":"/integrations/sentry"}]},{"group":"Code","pages":[{"title":"GitHub Integration: Code Context and PRs","href":"/integrations/github"},{"title":"GitLab Integration: Cloud and Self-Hosted","href":"/integrations/gitlab"}]},{"group":"Notifications","pages":[{"title":"Slack Integration: Incident Notifications","href":"/integrations/slack"},{"title":"Microsoft Teams Integration and Alerts","href":"/integrations/teams"}]},{"group":"Databases","pages":[{"title":"ClickHouse Integration: Query Analytics Data","href":"/integrations/clickhouse"},{"title":"PlanetScale Integration: Debug App Data","href":"/integrations/planetscale"}]},{"group":"Ticketing","pages":[{"title":"Linear Integration","href":"/integrations/linear"},{"title":"Jira Integration","href":"/integrations/jira"}]},{"group":"Knowledge","pages":[{"title":"Confluence Integration","href":"/integrations/confluence"}]},{"group":"Platforms \u0026 Workflow","pages":[{"title":"Apache Airflow Integration: Monitor DAGs","href":"/integrations/airflow"},{"title":"Trigger.dev Integration: Debug Background Jobs","href":"/integrations/trigger-dev"},{"title":"Vercel Integration: Monitor Deployments","href":"/integrations/vercel"},{"title":"Merge Integration: HR and HCM Data Context","href":"/integrations/merge"}]}]},{"group":"Webhooks","pages":[{"title":"Overview","href":"/webhooks/overview"},{"title":"incident.io","href":"/webhooks/incidentio"},{"title":"Honeycomb","href":"/webhooks/honeycomb"},{"title":"CloudWatch","href":"/webhooks/cloudwatch"},{"title":"Datadog","href":"/webhooks/datadog"},{"title":"Custom alerts","href":"/webhooks/custom"}]},{"group":"Developer Tools","pages":[{"title":"Corelayer CLI: Install, Auth, and Commands","href":"/cli/overview"},{"title":"Corelayer MCP Server for AI Agents","href":"/cli/mcp-server"},{"title":"Corelayer Skill for AI Coding Agents","href":"/cli/corelayer-skill"}]}]},{"tab":"Updates","pages":[{"title":"Updates","href":"/changelog/october-2026"}]}]},"basePath":"","title":"API Metrics: Track Custom Pipeline Metrics - Corelayer","buildId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","deploymentId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","dynamics":[],"chunks":[]}