Skip to content

Commit

Permalink
fix(examples): update vector example
Browse files Browse the repository at this point in the history
  • Loading branch information
tothandras committed Aug 2, 2024
1 parent e8f65d1 commit 58168ad
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/ingest-logs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Transformations in Vector uses the [Vector Remap Language](https://vector.dev/do

1. First, start OpenMeter. Refer to the [quickstart guide](/quickstart) for instructions.
2. Execute `docker compose up` within this example directory.
3. To query meters, use the following command: `curl http://localhost:8888/api/v1/meters/api_requests_total/values`.
3. To query meters, use the following command: `curl 'http://localhost:8888/api/v1/meters/api_requests_duration/query?groupBy=subject'`.

Note: It's important that you run quickstart's `docker compose` first.
4 changes: 2 additions & 2 deletions examples/ingest-logs/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.9'
version: "3.9"

services:
# Container to generate demo logs
Expand All @@ -19,7 +19,7 @@ services:
sleep 1;
done'
vector:
image: timberio/vector:0.32.X-alpine
image: timberio/vector:0.40.X-alpine
hostname: vector
container_name: vector
command: --config /etc/vector/vector.yaml
Expand Down
8 changes: 4 additions & 4 deletions examples/ingest-logs/vector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ transforms:
- filter_requests
source: |
.cloudevent.specversion = "1.0"
.cloudevent.id = .timestamp
.cloudevent.id = uuid_v7()
.cloudevent.source = .container_id
.cloudevent.type = "api-calls"
.cloudevent.type = "request"
.cloudevent.subject = .message.user
.cloudevent.time = .timestamp
response_time, err = to_string(.message.response_time)
if err != null { log(err, level: "error") }
.cloudevent.data.duration_ms = response_time
.cloudevent.data.method = .message.method
.cloudevent.data.path = .message.path
.cloudevent.data.route = .message.route
. = .cloudevent
sinks:
Expand All @@ -55,7 +55,7 @@ sinks:
type: http
inputs:
- cloudevents
uri: http://openmeter:8888/api/v1alpha1/events
uri: http://openmeter:8888/api/v1/events
method: post
request:
headers:
Expand Down
12 changes: 11 additions & 1 deletion quickstart/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ sink:

meters:
# Sample meter to count API requests
- slug: api_requests_total # Unique identifier for the meter
- slug: api_requests_total # Unique identifier for the meter
description: API Requests
eventType: request # Filter events by type
aggregation: COUNT # Aggregation method: COUNT, SUM, etc.
groupBy:
method: $.method # HTTP Method: GET, POST, etc.
route: $.route # Route: /products/:product_id

# Sample meter to sum API request duration
- slug: api_requests_duration
description: API Request Duration
eventType: request
aggregation: SUM
valueProperty: $.duration_ms # JSONPath to parse usage value
groupBy:
method: $.method
route: $.route

# Sample meter to count LLM Token Usage
- slug: tokens_total
description: AI Token Usage
Expand Down

0 comments on commit 58168ad

Please sign in to comment.