VSHN Based AppCat Services

This page explains how VSHN based services handle usage reporting.

Data Flow Overview

VSHN

The usage reporting process involves four main steps, where data is gathered and transferred across multiple applications:

Data is gathered and exposed through AppCat composition functions. Data is sent to Prometheus at the cluster level. Data is sent to Mimir at the organization level. Data is sent to Odoo using CronJobs on the APPUiO Cloudscale cluster.

Data in AppCat Composition Functions

Service usage data is collected via the AddBilling() composition function for each service instance. A PrometheusRule is created with the following example rule:

  - expr: vector(1) (1)
    labels: (2)
      label_appcat_vshn_io_claim_name: my-postgres-name
      label_appcat_vshn_io_claim_namespace: my-postgres-namespace
      label_appcat_vshn_io_sla: besteffort
      label_appuio_io_billing_name: appcat-postgresql
      label_appuio_io_organization: vshn
    record: appcat:metering (3)
1 Instant Vector: Wraps the number of nodes for the service instance (for example - 3 for HA setups, 1 for single-node setups).
2 Labels: Identify the service instance and are essential for usage reporting.
3 Recording Rule: Name of the precomputed Prometheus query.

The distinction between Cloud and Managed services is made using the salesOrder parameter, passed via a component from the cluster’s facts. If this parameter exists, the service is considered APPUiO Managed, and the sales_order label is added to the appcat:metering recording rule.

Data in Prometheus

Service usage data is stored in Prometheus and is accessible through the appcat:metering recording rule. A time series is created for each service instance, capturing the usage metrics.

Data in Mimir

The data is then collected in the centralized time-series database, Mimir. In the Explore tab, the appcat:metering recording rule displays metrics from all clusters using AppCat services. The rule is enriched with additional labels, such as tenant_name, tenant_id, cluster_id, and cluster_name.

APPUiO Cloudscale CronJobs

The component-appcat creates CronJobs that run every hour, as specified by the default cron expression 30 * * * *. These jobs are organized by service type (for example - Redis, MinIO), service category (APPUiO Managed or Cloud), and SLA (best-effort or guaranteed).

Example: A CronJob for Redis on APPUiO Managed with a best-effort SLA is named appcat-vshn-redis-besteffort-managed.

Since billing is calculated per minute, the data from the initial recording rule is adjusted. The following query ensures minute-based billing:

sum_over_time(appcat:metering{labels...}[59m:1m]) / 60

The CronJobs are configurable via component-appcat.

Example Configuration

This configuration is abridged from the existing config.

billing:
  vshn:
    enableCronjobs: false
    schedule: 30 * * * * (1)
    meteringRules: true (2)
1 Data is collected every hour from 00:30.
2 Whether to deploy deploy metering rules.

Odoo Integration

Data is processed in Odoo via a Job Queue. Each job corresponds to a CronJob, and you can view messages that are either accepted or rejected. If accepted, data is accessible and filterable on the Sales webpage.

Some links may require permissions and might not be accessible if you lack the necessary rights.

Data Model and Flow

See the Data Model and Flow for a generic overview of the data flow for Odoo.

Special testing namespace

On each APPUiO cluster there’s a special testing namespace that will not create any usage reporting.

It’s usually vshn-test, it’s defined in appcat.billing.ignoreNamespace in the component-appcat.