SampleSampletypeA worked example you read or clone. Evidence: it demonstrates, it never provides.See every one →What this type is →by SAPby SAPoriginPublished by SAP itself. A visible facet, never an input to a reading — a dormant official plugin reads exactly like a dormant independent one.See every one →Reference

SAP-samples/btp-ai-core-consumption-monitor

A CAP and React dashboard that tracks SAP AI Core capacity unit consumption across SAP BTP subaccounts against a monthly spending limit.

AI Core usage is billed in capacity units, and a FinOps team wants to see the spend before the monthly bill arrives rather than after. This application reads it from the SAP BTP Usage and Accounting Service APIs and shows a technical view of capacity units and tokens per model, a commercial view of billing cost, and an AI breakdown view of cost per token and capacity units by type. Subaccounts are entered by hand, or discovered from the account hierarchy when the optional SAP Cloud Management Service integration is bound, each with its own monthly spending limit and alerts; a breach is notified by SMTP email, by an HTTP endpoint of your own or through SAP Alert Notification service. The daily check at 07:00 UTC runs by itself only once the SAP Job Scheduling service resource is uncommented in mta.yaml; without it the Run Check and Check All buttons pull fresh data on demand.

Facts

Last pushLicenceApache-2.0

Where it sits

Lives in
Demonstrates
Consumption monitoringBTPConsumption monitoringcapabilityKnowing what a cloud account consumes as it runs, in credits, capacity units and cost per service and organisational unit, and being warned before a budget is spent. [Logging](capability:logging) and [telemetry](capability:telemetry) watch what an application does; this watches what it costs.
Requires
SAP HANA CloudSAP HANA Cloudartifactthe HDI container the consumption records and the monthly history are stored inSAP Authorization and Trust Management serviceSAP Authorization and Trust Management serviceartifactthe authentication the deployed application runs behind, and the two role collections it definesSAP Usage Data Management Service for SAP BTPSAP Usage Data Management Service for SAP BTPartifactthe reporting APIs the capacity unit and billing figures are read fromSAP Destination serviceSAP Destination serviceartifacta bound service instance the deployment needs, on the lite planSAP HTML5 Application Repository service for SAP BTPSAP HTML5 Application Repository service for SAP BTPartifactwhere the React dashboard is hosted once the MTA is deployed
Optional
SAP Job Scheduling serviceSAP Job Scheduling serviceartifactthe daily cron job that fetches the month's usage and sends the notifications without anyone pressing a buttonSAP Alert Notification service for SAP BTPSAP Alert Notification service for SAP BTPartifactthe channel the threshold events are posted to, where the deployment uses it rather than SMTP or an HTTP endpointSAP Cloud Management Service for SAP BTPSAP Cloud Management Service for SAP BTPartifactreading the global account, business unit, application and subaccount hierarchy the dashboard offers instead of manual entry

Who is behind it

SAP SamplesSAP SamplesOrganisationMaintains this
In the atlas: maintains 222
@SAP-samples
maintainerSiddhartha RouthPersonContributes to this
In the atlas: contributes to 1
@SiddharthaRouth
1 contributor

Before choosing this

Conditions

PracticalFunctional boundary

Never as the figure a billing decision rests on: the repository states this is not a replacement for the official billing documents, that the information it provides is purely indicative, and that it recommends verifying against the official BTP Cockpit usage reports. It is published as a sample or reference implementation and says it is not intended for production use without review, testing and hardening.

What it declares

Every artifact

Type
Sample
Origin
By SAP
Use as
A reference

As a sample

Form
A reference application

Connections11

SAP-samples/btp-ai-core-consumption-monitor connectionsSAP-samples/btp-ai-core-consumption-monitorPROVIDES→ demonstrates1demonstrates authoredConsumption monitoringNEEDS→ connects to2connects to stated If: the SAP ANS notification channel is enabled; the application also notifies by SMTP email and by an HTTP endpoint posts the threshold event so that the service routes it to whatever action is subscribed SAP-samples/btp-ai-core-consumption-monitor — README, Notifications: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP Alert Notification service for SAPBTPifconnects to stated fetches the capacity unit consumption and the billing cost per subaccount that every view is built from SAP-samples/btp-ai-core-consumption-monitor — README, Description: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP Usage Data Management Service forSAP BTP→ needs5needs stated the authentication the deployed application runs behind, and the two role collections it defines SAP-samples/btp-ai-core-consumption-monitor — README, Requirements: https://github.com/SAP-samples/btp-ai-core-consumption-monitor SAP-samples/btp-ai-core-consumption-monitor — README, Security – Roles & Authorization: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP Authorization and Trust Managementserviceneeds stated a bound service instance the deployment needs, on the lite plan SAP-samples/btp-ai-core-consumption-monitor — README, Requirements: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP Destination serviceneeds stated the HDI container the consumption records and the monthly history are stored in SAP-samples/btp-ai-core-consumption-monitor — README, Requirements: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP HANA Cloudneeds stated where the React dashboard is hosted once the MTA is deployed SAP-samples/btp-ai-core-consumption-monitor — README, Requirements: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP HTML5 Application Repositoryservice for SAP BTPneeds stated the reporting APIs the capacity unit and billing figures are read from SAP-samples/btp-ai-core-consumption-monitor — README, Requirements: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP Usage Data Management Service forSAP BTP→ optionally needs3optionally needs stated If: notifications are routed through SAP Alert Notification service; the requirements table marks the service Optional the channel the threshold events are posted to, where the deployment uses it rather than SMTP or an HTTP endpoint SAP-samples/btp-ai-core-consumption-monitor — README, Requirements: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP Alert Notification service for SAPBTPifoptionally needs stated If: subaccounts are discovered from the account hierarchy; the requirements table marks the service Optional and the application boots in manual mode without it reading the global account, business unit, application and subaccount hierarchy the dashboard offers instead of manual entry SAP-samples/btp-ai-core-consumption-monitor — README, Requirements: https://github.com/SAP-samples/btp-ai-core-consumption-monitor SAP-samples/btp-ai-core-consumption-monitor — README, Fallback Behavior: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP Cloud Management Service for SAPBTPifoptionally needs stated If: the scheduler resource is uncommented in mta.yaml; the requirements table marks the service Optional (Recommended) and the default deployment has no schedule the daily cron job that fetches the month's usage and sends the notifications without anyone pressing a button SAP-samples/btp-ai-core-consumption-monitor — README, Requirements: https://github.com/SAP-samples/btp-ai-core-consumption-monitor SAP-samples/btp-ai-core-consumption-monitor — README, Job Scheduling: https://github.com/SAP-samples/btp-ai-core-consumption-monitorSAP Job Scheduling serviceif

README

quoted from SAP-samples/btp-ai-core-consumption-monitor under Apache-2.0, read
SAP-samples/btp-ai-core-consumption-monitor/README.mdOn GitHub

SAP BTP AI Core Consumption Monitor

REUSE status

Disclaimer: This tool is provided as-is and is not covered by SAP Support. This is not a replacement of the official billing documents you receive from SAP. The information provided by this tool is purely indicative. SAP does not guarantee the accuracy of the data displayed.

Description

This application monitors and visualizes SAP AI Core capacity unit (CU) consumption across multiple BTP subaccounts. It fetches data from the SAP BTP Usage and Accounting Service (UAS) APIs and provides a Technical View (CU per model, tokens), a Commercial View (billing costs), and an AI Breakdown View (cost per token, CU by type) of AI Core usage — across a full BTP account hierarchy when the optional Cloud Management Service integration is enabled.

The application helps FinOps teams and platform administrators to:

  • Discover BTP subaccounts automatically via the Cloud Management Service (CMS) hierarchy, or manage them manually
  • Track AI Core spending against monthly budgets with per-subaccount alerts
  • Identify which models consume the most capacity units and at what cost per token
  • Get notified when consumption approaches configured thresholds (SMTP email or SAP ANS)
  • View historical consumption trends month over month with Recharts visualizations
  • Navigate the account hierarchy — Business Unit → Application → Subaccount — from the header

Dashboard Overview

Detail View

Architecture

Architecture Diagram

LayerTechnology
BackendSAP Cloud Application Programming Model (CAP) — Node.js
DatabaseSAP HANA Cloud (HDI Container)
FrontendReact 18, Vite, Tailwind CSS, Recharts, Lucide Icons
AuthenticationSAP XSUAA
Data SourceBTP Usage & Accounting Service (UAS) APIs
Account DiscoverySAP Cloud Management Service (CMS) — optional
NotificationsSMTP (Nodemailer), HTTP API endpoint, SAP Alert Notification Service

Requirements

SAP BTP Services
ServicePlanRequired
SAP HANA Cloudhdi-shared✅ Yes
XSUAAapplication✅ Yes
UAS (Usage & Accounting)reporting-ga-admin✅ Yes
Destination Servicelite✅ Yes
HTML5 Application Repositoryapp-host✅ Yes
Job Scheduling Servicestandard❌ Optional (Recommended)
Alert Notification Servicestandard❌ Optional
Cloud Management Service (CIS)central-viewer❌ Optional
Development Tools
  • Node.js >= 20
  • SAP Cloud Application Programming Model (CAP) — @sap/cds-dk
  • Cloud Foundry CLI (cf)
  • MBT Build Tool (mbt) — for MTA builds
  • SAP BTP Cloud Foundry environment with HANA Cloud

Download and Installation

1. Clone
git clone https://github.com/SAP-samples/btp-ai-core-consumption-monitor.git
cd btp-ai-core-consumption-monitor
2. Install Dependencies
npm install
cd app/dashboard && npm install && cd ../..
3. Build & Deploy

The project uses scripts defined in package.json. Execute them with npm run <script>:

ScriptCommandDescription
buildnpm run buildBuild the MTA archive (ai-core-finops.mtar)
deploynpm run deployDeploy the MTA archive to Cloud Foundry
undeploynpm run undeployRemove all deployed apps and services
# Build MTA archive
npm run build

# Deploy to Cloud Foundry
npm run deploy

# Undeploy (removes all services)
npm run undeploy

Configuration

Without CMS (Manual Mode)

After deployment, subaccounts are managed manually:

  1. Open the application and navigate to Configuration
  2. Under Subaccount Discovery, click Add Subaccount Manually
  3. Enter the Subaccount ID (UUID), display name, and monthly spending limit
  4. Click "Run Check" on the Overview page to fetch current data
  5. Click "Load Historical" to backfill historical consumption data
With CMS (Auto-Discovery Mode)

When the Cloud Management Service binding is present (see CMS Account Discovery), the app discovers your BTP account hierarchy automatically:

  1. On startup, the app syncs your Global Account hierarchy into the Subaccounts master list
  2. Navigate to Configuration → Subaccount Discovery to see all discovered subaccounts grouped by Business Unit and Application
  3. Click Enable Monitoring on a subaccount to opt it in and set a spending limit and alert thresholds
  4. Use the Sync from CMS button to refresh the hierarchy at any time

A subaccount that has not been opted in is visible in the discovery list but will not appear in the monitoring overview or trigger alerts.

Security – Roles & Authorization

The application defines two role templates in xs-security.json:

Role CollectionRole TemplateAccess
AICore_FinOps_AdminAdminFull access — manage configuration, trigger checks, view all data, manage notifications
AICore_FinOps_ViewerViewerRead-only — view dashboards, monthly data, and alert history

Role-based authorization is enforced via @requires annotations in srv/service.cds. Assign the role collections to users or user groups in the BTP Cockpit after deployment.

In local development (cds watch), a dummy auth provider is used — all users are treated as Admin. In production ([production] profile in package.json), XSUAA is enforced.

CMS Account Hierarchy Discovery

The optional Cloud Management Service (service: cis, plan: central-viewer) integration lets the app discover your full BTP account hierarchy — Global Account → Business Units (L1 directories) → Applications (L2 directories) → Subaccounts — without any manual data entry.

Enabling CMS
  1. Ensure cis central-viewer is entitled in your subaccount (BTP Cockpit → Entitlements)

  2. Create the service instance:

    cf create-service cis central-viewer ai-core-finops-cms
  3. In mta.yaml, uncomment the CMS resource and its binding:

    # modules > ai-core-finops-srv > requires:
    - name: ai-core-finops-cms
    
    # resources:
    - name: ai-core-finops-cms
      type: org.cloudfoundry.managed-service
      parameters:
        service: cis
        service-plan: central-viewer
  4. Rebuild and redeploy.

The app reads the CMS API endpoint and OAuth token URL directly from the service binding (credentials.endpoints.accounts_service_url and credentials.uaa.url) — no manual region configuration is needed.

Fallback Behavior

If the CMS service is not bound, the app boots normally and operates in manual mode. The Subaccount Discovery UI will show the Add Manually form instead of the hierarchy browser.

The application can use the SAP BTP Job Scheduling Service for automated daily monitoring checks. Without it, use the "Run Check" or "Check All" buttons in the UI to pull fresh data on demand.

Enabling Job Scheduler
  1. In mta.yaml, uncomment the scheduler resource and binding:
# modules > ai-core-finops-srv > requires:
- name: ai-core-finops-scheduler

# resources:
- name: ai-core-finops-scheduler
  type: org.cloudfoundry.managed-service
  parameters:
    service: jobscheduler
    service-plan: standard
    config:
      enable-xsuaa-support: true
  1. Rebuild and redeploy.

The application will automatically register a daily cron job (07:00 UTC) that:

  • Fetches current month usage for all active subaccounts (technical + commercial)
  • Stores/updates consumption records in HANA
  • Sends notifications (email/ANS) if thresholds are breached
  • On days 1–3 of a new month, also finalizes the previous month's commercial data

Notifications

The application supports three notification channels, all configurable from the Configuration → Notification Settings section:

ChannelDescription
SMTP EmailRich HTML emails with CU breakdown, progress bars, and model details. Supports TLS/STARTTLS.
API EndpointPosts a JSON alert payload to any HTTP endpoint (e.g. a webhook, a custom notification bus). Supports Bearer token and custom header auth.
SAP ANSStructured events posted to the SAP Alert Notification Service.

All channels can be independently enabled/disabled. Use the Send Test buttons in the UI to verify connectivity before enabling live alerts.

Known Issues

  • Token data (input/output) is only available for GenAI models (GPT, Claude, etc.) — vector_storage and retrieval_text show "—" for tokens
  • Commercial cost data from monthlySubaccountsCost may not be immediately available for the current month (SAP processes with a delay)
  • The "Projected" metric uses simple linear extrapolation and may not reflect actual month-end usage
  • CMS sync discovers only subaccounts that are children of L1 (Business Unit) and L2 (Application) directories; subaccounts placed directly under the Global Account are not picked up

How to Obtain Support

This is an open-source sample application. SAP does not provide official support.

If you encounter issues or have questions:

For additional support, ask a question in SAP Community.

Please check existing issues before creating new ones.

Contributing

If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.

Code of Conduct

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. Please read and follow our Code of Conduct.

License

Copyright 2026 SAP SE or an SAP affiliate company and btp-ai-core-consumption-monitor contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.


Note: This application is provided as a sample/reference implementation. It is not intended for production use without proper review, testing, and hardening. SAP does not guarantee the accuracy of the data displayed and recommends verifying against the official BTP Cockpit usage reports.

Apache-2.0, read

Details

Sources3
Added by handdiscovered herechecked
github.com/SAP-samples/btp-ai-core-consumption-monitortree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
discovered viaAdded by hand
first seen in the atlas
ecosystem and domainbtp, operations-and-runtime
Contributors1

From the repository’s contributor list, .

History in the atlas1
  1. First seen.
For your agent
Ref
artifact:sap-samples-btp-ai-core-consumption-monitor
JSON
/artifacts/sap-samples-btp-ai-core-consumption-monitor.json
MCP
Connecting an agent