Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
fix(examples): query and tables
Browse files Browse the repository at this point in the history
  • Loading branch information
tothandras committed Jan 15, 2024
1 parent 2f3ead7 commit b40f850
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
1 change: 0 additions & 1 deletion examples/database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ Launch the example (database, event collector and seeder):
docker compose up -d
```


## Checking events

Read more in the general examples [README](../README.md#Checking-events-in-OpenMeter).
Expand Down
6 changes: 3 additions & 3 deletions examples/database/config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
input:
sql_select:
driver: clickhouse
dsn: "${CLICKHOUSE_DSN}"
driver: "${DATABASE_DRIVER}"
dsn: "${DATABASE_DSN}"
table: messages
columns:
- message_id
- account_id
- message
- time
where: time >= ?
args_mapping: root = [ now().ts_unix() - 30 ]
args_mapping: 'root = [ (now().ts_unix() - 30).ts_format(format: "2006-01-02 15:04:05", tz: "UTC") ]'

pipeline:
processors:
Expand Down
2 changes: 2 additions & 0 deletions examples/database/docker-compose.common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: "3.9"
services:
collector:
image: ghcr.io/openmeterio/benthos-openmeter
pull_policy: always
command: benthos -c /etc/benthos/config.yaml
restart: always
env_file:
Expand All @@ -12,6 +13,7 @@ services:

seeder:
image: ghcr.io/openmeterio/benthos-openmeter
pull_policy: always
command: benthos -c /etc/benthos/config.yaml
restart: always
volumes:
Expand Down
2 changes: 1 addition & 1 deletion examples/database/seed/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ output:
this.sender,
this.recipient,
this.message,
this.time.ts_format("2006-01-02 15:04:05"),
this.time.ts_format(format: "2006-01-02 15:04:05", tz: "UTC"),
]
init_files:
- init.sql
Expand Down
18 changes: 9 additions & 9 deletions examples/database/seed/init.clickhouse.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CREATE TABLE IF NOT EXISTS messages (
message_id UUID,
account_id String,
sender String,
recipient String,
message String,
time DateTime
) ENGINE = MergeTree()
PRIMARY KEY (message_id);
CREATE TABLE
IF NOT EXISTS messages (
message_id UUID,
account_id String,
sender String,
recipient String,
message String,
time DateTime('UTC')
) ENGINE = MergeTree() PRIMARY KEY (message_id);
17 changes: 9 additions & 8 deletions examples/database/seed/init.postgres.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CREATE TABLE IF NOT EXISTS messages (
message_id UUID PRIMARY KEY,
account_id TEXT,
sender TEXT,
recipient TEXT,
message TEXT,
time TIMESTAMP
);
CREATE TABLE
IF NOT EXISTS messages (
message_id UUID PRIMARY KEY,
account_id TEXT,
sender TEXT,
recipient TEXT,
message TEXT,
time TIMESTAMPTZ
);

0 comments on commit b40f850

Please sign in to comment.