Skip to content

FinOps Cost Model

This document defines the detailed internal cost model for ConnectSoft, including cost drivers, resource tagging standards, cost attribution methods, and high-level cost formulas. It is written for operations engineers, SREs, architects, and finance teams who need to understand how costs are tracked, attributed, and calculated across the ConnectSoft ecosystem.

Cost modeling at ConnectSoft enables accurate cost attribution per tenant, per product, per environment, and per component, supporting pricing decisions, capacity planning, and cost optimization efforts.

Important

Conceptual Formulas: The formulas in this document are conceptual and implementation-agnostic. They represent the cost structure model, not actual dollar amounts or specific pricing. Actual costs depend on cloud provider pricing, usage patterns, and negotiated rates.

Cost Drivers

Compute

Compute costs include all processing infrastructure:

AKS / ACA Workloads:

  • Factory workers (code generation, agent execution)
  • Platform services (Identity, Config, Audit, Documents, Communications, Billing APIs)
  • SaaS microservices (connectsoft.io modules, connectsoft.me services, vertical suite services)
  • API gateways and orchestration services

Compute Cost Factors:

  • Pod/container instance count
  • Instance size (CPU, memory)
  • Runtime duration
  • Reserved vs. on-demand pricing
  • Spot instance usage (where applicable)

Storage

Storage costs include all data persistence:

Database Storage:

  • Relational databases (SQL Server, PostgreSQL, MySQL)
  • NoSQL databases (MongoDB, Cosmos DB)
  • Database backups and retention

Blob Storage:

  • Document storage (Documents Platform)
  • Artifact storage (Factory outputs)
  • Media files and attachments

Cache Storage:

  • Redis cache instances
  • In-memory cache costs

Log Storage:

  • Application logs
  • Audit logs
  • Observability data retention

Messaging

Messaging costs include all asynchronous communication infrastructure:

Queues:

  • Service Bus queues
  • Azure Queue Storage
  • Background job queues

Topics:

  • Service Bus topics
  • Event streaming (Kafka, Event Hubs)

Message Processing:

  • Message throughput
  • Message retention
  • Dead-letter queue storage

Observability

Observability costs include monitoring and debugging infrastructure:

Log Storage:

  • Application log ingestion and storage
  • Log retention periods
  • Log query operations

Traces:

  • Distributed tracing data
  • Trace storage and retention
  • Trace query operations

Metrics:

  • Metrics collection and aggregation
  • Metrics storage and retention
  • Metrics query operations

Alerting:

  • Alert rule evaluation
  • Notification delivery

See: Observability – Dashboards and Alerts for observability details.

AI Usage

AI usage costs are a major cost driver:

Token Consumption:

  • Prompt tokens (input to AI models)
  • Completion tokens (output from AI models)
  • Context window usage

Model Selection:

  • Model pricing tiers (cheap vs. expensive models)
  • Model selection per use case
  • Model switching based on cost/performance trade-offs

AI Infrastructure:

  • AI service API calls
  • Model inference compute
  • Embedding generation costs

3rd-Party APIs

External API costs include all third-party service integrations:

Communication APIs:

  • Email providers (SendGrid, Mailgun, etc.)
  • SMS providers (Twilio, Azure Communication Services, etc.)

Marketing & CRM APIs:

  • Marketing automation platforms
  • CRM integrations
  • Analytics platforms

Payment Processing:

  • Payment gateway fees
  • Transaction processing fees

Other External Services:

  • Data enrichment APIs
  • Geocoding services
  • Identity verification services

Resource Tagging / Labeling Standard

Standard Tags

All infrastructure resources must be tagged with the following standard tags/labels:

cs_tenant_id

  • Value: Specific tenant ID (e.g., tenant-abc123) or shared/platform/global for shared infrastructure
  • Purpose: Enables per-tenant cost attribution
  • Required: Yes

cs_product

  • Value: Product identifier (e.g., factory, identity, audit, connectsoft_me, connectsoft_io_marketing, insurance_suite, etc.)
  • Purpose: Enables per-product cost attribution
  • Required: Yes

cs_environment

  • Value: dev, test, staging, prod
  • Purpose: Enables per-environment cost tracking
  • Required: Yes

cs_component

  • Value: Component type (e.g., api-gateway, orchestrator, worker, db, storage, queue, etc.)
  • Purpose: Enables per-component cost analysis
  • Required: Yes

cs_plan

  • Value: Runtime plan tier (e.g., free, pro, family, enterprise)
  • Purpose: Enables cost analysis by customer plan tier
  • Note: This tag is used for runtime metrics and usage tracking, not infrastructure tagging
  • Required: No (runtime metric only)

Tagging Examples

Example 1: Tenant-Specific Database

cs_tenant_id: tenant-abc123
cs_product: connectsoft_me
cs_environment: prod
cs_component: db

Example 2: Shared Platform Service

cs_tenant_id: shared
cs_product: identity
cs_environment: prod
cs_component: api-gateway

Example 3: Factory Worker

cs_tenant_id: shared
cs_product: factory
cs_environment: prod
cs_component: worker

Cost Attribution for Shared Resources

For shared resources (tagged with cs_tenant_id: shared), cost attribution uses:

  • Usage metrics (API calls, storage usage, message counts)
  • Runtime tags (tenantId from application logs/metrics)
  • Proportional allocation based on usage

See: Observability – Dashboards and Alerts for metrics collection.

Per-Run & Per-Tenant Cost Attribution

Factory Run Attribution

Each Factory run, agent run, or workflow run emits the following attribution data:

Run Metadata:

  • tenantId - Tenant executing the run
  • product - Product context (factory, connectsoft_me, etc.)
  • environment - Environment (dev, test, staging, prod)

Run Identifiers:

  • agentId - Specific agent executing
  • packId - Agent pack or template used
  • workflowId - Workflow or orchestration identifier
  • runId - Unique run identifier

Usage Metrics:

  • tokenUsage - AI token consumption (prompt + completion)
  • runtimeSeconds - Execution duration
  • connectorApiCalls - External API calls made
  • computeResourceUsage - CPU, memory usage

Cost Aggregation

Costs are aggregated at multiple levels:

Per-Agent:

  • Total cost for all runs of a specific agent
  • Average cost per run
  • Cost trends over time

Per-Pack:

  • Total cost for all runs using a specific agent pack
  • Cost per pack across all tenants

Per-Product:

  • Total cost for all runs within a product (factory, connectsoft_me, etc.)
  • Cost breakdown by product component

Per-Tenant:

  • Total cost to serve a specific tenant
  • Cost breakdown by product, environment, component
  • Cost per tenant plan tier

Per-Environment:

  • Total cost for dev, test, staging, production
  • Cost comparison across environments

High-Level Cost Formulas

Agent Run Cost

Approximate cost for a single agent run:

agent_run_cost ≈ ai_token_cost + (compute_cost_per_second * runtime_seconds) + connector_api_cost

Components:

  • ai_token_cost - Cost of AI token consumption (see AI Token Cost formula)
  • compute_cost_per_second - Cost per second of compute resource usage
  • runtime_seconds - Duration of agent execution
  • connector_api_cost - Cost of external API calls made during execution

AI Token Cost

Cost of AI token consumption:

ai_token_cost = ((prompt_tokens + completion_tokens) / 1000) * model_price_per_1k_tokens

Components:

  • prompt_tokens - Number of input tokens
  • completion_tokens - Number of output tokens
  • model_price_per_1k_tokens - Model-specific pricing per 1,000 tokens

Model Selection Impact:

  • Different models have different pricing (cheap vs. expensive)
  • Model selection affects both cost and performance
  • Cost optimization may involve model switching based on use case

Factory Run Cost

Cost for a Factory run (code generation, orchestration):

factory_run_cost ≈ ai_token_cost + orchestration_compute + storage_io

Components:

  • ai_token_cost - AI token consumption for code generation and planning
  • orchestration_compute - Compute cost for orchestration services
  • storage_io - Storage I/O costs for reading/writing artifacts

Per-Tenant Monthly Cost

Total monthly cost to serve a tenant:

tenant_monthly_cost = Σ(resource_costs_with_tenant_tag) + Σ(agent_run_costs_for_tenant) + Σ(third_party_api_costs_for_tenant)

Components:

  • resource_costs_with_tenant_tag - Infrastructure costs tagged with tenant ID
  • agent_run_costs_for_tenant - All agent/Factory run costs for the tenant
  • third_party_api_costs_for_tenant - External API costs attributed to the tenant

Shared Resource Allocation:

  • For shared resources, tenant cost = proportional share based on usage metrics
  • Usage metrics (API calls, storage usage, message counts) determine allocation

Cost Surfaces & Reporting

Cost Dashboards

Internal cost dashboards provide visibility at multiple levels:

Cost per Product:

  • Total cost by product (factory, identity, audit, connectsoft_me, connectsoft_io, vertical suites)
  • Cost trends over time
  • Cost breakdown by component (compute, storage, messaging, AI, 3rd-party)

Cost per Tenant:

  • Total cost to serve each tenant
  • Cost breakdown by product and environment
  • Cost per tenant plan tier (free, pro, family, enterprise)
  • Tenant profitability analysis

Cost per Feature:

  • Cost per agent type
  • Cost per agent pack
  • Cost per SaaS module (connectsoft.io modules)
  • Cost per workflow type

Cost per Environment:

  • Total cost for dev, test, staging, production
  • Cost comparison across environments
  • Environment efficiency metrics

Cost Reporting

Regular Reports:

  • Monthly cost summaries by product and tenant
  • Cost variance analysis (actual vs. budget)
  • Cost trend analysis and forecasting

Ad-Hoc Analysis:

  • Cost attribution for specific time periods
  • Cost analysis for pricing decisions
  • Cost optimization opportunity identification

See: FinOps Budgets & Alerts for budget tracking and alerts.

Cost Attribution Flow

The following diagram illustrates how metrics and usage data flow through cost attribution to produce product and tenant reports:

flowchart TD
    A[Infrastructure Resources] -->|Tagged with cs_* labels| B[Resource Cost Collection]
    C[Agent Runs] -->|Emit tenantId product environment| D[Usage Metrics Collection]
    E[3rd-Party APIs] -->|Track per tenant/product| D

    B --> F[Cost Attribution Engine]
    D --> F

    F --> G[Cost Aggregation]
    G --> H[Per-Tenant Reports]
    G --> I[Per-Product Reports]
    G --> J[Per-Environment Reports]
    G --> K[Per-Component Reports]

    H --> L[Cost Dashboards]
    I --> L
    J --> L
    K --> L

    L --> M[Budget Evaluation]
    M --> N[Alerts & Actions]
Hold "Alt" / "Option" to enable pan & zoom

Flow Description:

  1. Infrastructure resources are tagged with standard labels (cs_tenant_id, cs_product, cs_environment, cs_component)
  2. Agent runs and workflows emit usage metrics with tenant/product/environment context
  3. 3rd-party API calls are tracked per tenant/product
  4. Cost Attribution Engine combines resource costs and usage metrics
  5. Costs are aggregated at multiple levels (tenant, product, environment, component)
  6. Reports are generated for different cost views
  7. Cost dashboards provide visibility
  8. Budget evaluation triggers alerts and operational actions

See: FinOps Budgets & Alerts for budget and alerting details.

Governance & Overview

Operations FinOps Documents

Operations & Observability