Prometheus
OpenMeter Collector can query Prometheus to collect metrics for billing and invoicing. This is useful for companies using Prometheus to monitor their infrastructure and want to bill and invoice their customers based on already collected metrics.
How it works
OpenMeter periodically queries your Prometheus instance using PromQL queries and emits the results as CloudEvents to your OpenMeter instance. This allows you to track usage and billing for your Prometheus workloads.
Sending Prometheus metrics into OpenMeter as billing events also helps to have an auditable record of the billing events as most Prometheus instances keep metrics only for a short period of time while OpenMeter can keep the billing events for a long time, providing a record of the usage and billing for auditing and accounting purposes.
Examples
For example if you already have a Prometheus metrics about the number of API requests your application serving for your customers, you can use the OpenMeter Collector to turn the Prometheus metrics into billable events and send them to OpenMeter for billing.
Billing from Prometheus Metrics?
Re-using existing Prometheus metrics can save you a lot of time and effort. But be aware that Prometheus metrics are not designed for billing and can lead inaccuracies due to the following reasons:
- Metrics can be lost when the app restarts and the metrics wasn't collected by the Prometheus scraper.
- Metrics are not deduplicated, so you can get multiple metrics for the same event.
For these reasons, we recommend using Prometheus metrics for billing only for long running workloads where the impacts of these inaccuracies is insignificant on the total bill.
Getting Started
The OpenMeter Collector is powered by Redpanda Connect.
First, create a new YAML file for the collector configuration. You will have to use the prometheus Redpanda Connect input:
Be sure to keep the collector's schedule interval in sync with the PromQL interval. If the query interval is not for the same period as the collector runs for you can miss or double collect metrics.
The above section will tell Redpanda Connect how to query metrics from your Prometheus instance.
Configuration Options
Option | Description | Default | Required |
---|---|---|---|
url | Prometheus server URL | - | Yes |
schedule | Cron expression for the scrape interval | 0 * * * * * | No |
query_offset | Time offset for queries to account for delays in metric availability | 0s | No |
queries | List of PromQL queries to execute | - | Yes |
Each query in the queries
list requires a name
(unique identifier for the
query results) and a promql
expression to execute.
Next, you need to configure the mapping from the Prometheus metrics to CloudEvents using bloblang:
Finally, you need to configure the OpenMeter output:
Read more about configuring Redpanda Connect in the OpenMeter Collector guide.
Scheduling
The collector runs on a schedule defined by the schedule
parameter using cron
syntax. It supports:
- Standard cron expressions (e.g.,
0 * * * * *
for once per minute) - Duration syntax with the
@every
prefix (e.g.,@every 1m
)
Query Offset
The query_offset
parameter allows you to query for data from a point in the
past, which is useful when metrics have a delay before they're available in
Prometheus. For example, setting query_offset: "1m"
means each query will be
executed against data from 1 minute ago.
Installation
Check out the OpenMeter Collector guide for installation instructions.