Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(examples): update vector example #1292

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 1 addition & 3 deletions examples/ingest-logs/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.9'

services:
# Container to generate demo logs
demologs:
Expand All @@ -19,7 +17,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
Loading