🎉 Announcing our $3 million seed round
Logo
Getting Started

ClickHouse

OpenMeter can integrate with your ClickHouse database to collect usage data directly from your database. By leveraging your existing data source for usage metering, you can significantly decrease the upfront cost of changing your data collection strategy.

This is a Benthos-based collector.

Configuration

First, create a new YAML file for the collector configuration. You will have to use the sql_select Benthos input:

input:
  sql_select:
    driver: clickhouse
    dsn: 'clickhouse://[username[:password]@][netloc][:port]/dbname[?param1=value1&...&paramN=valueN]'
    table: YOUR_TABLE
    columns:
      - id
      - data_column
      - subject_column
      - time
    where: time >= ?
    args_mapping: root = [ now().ts_unix() - 30 ]

The above section will tell Benthos how to read data from your database.

Next, you need to configure the mapping from your database schema to CloudEvents using bloblang:

pipeline:
  processors:
    - mapping: |
        root = {
          "id": this.id,
          "specversion": "1.0",
          "type": "your-usage-event-type",
          "source": "clickhouse",
          "time": this.time,
          "subject": this.subject_column,
          "data": {
            "data": this.data_column,
          },
        }

Finally, you need to configure the OpenMeter output:

output:
  openmeter:
    url: https://openmeter.cloud # optional
    token: '<YOUR OPENMETER CLOUD TOKEN>'

Read more about configuring Benthos in the Benthos-based collector guide.

Installation

Check out the Benthos-based collector guide for installation instructions.

Last edited on June 24, 2024