-
Notifications
You must be signed in to change notification settings - Fork 68
/
vector.yaml
64 lines (62 loc) · 1.55 KB
/
vector.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
sources:
# Read logs from Docker container(s)
docker_logs:
type: docker_logs
docker_host: unix:///var/run/docker.sock
include_containers:
- demologs
transforms:
# Parse JSON logs
parse:
type: remap
inputs:
- docker_logs
source: |
msg, err = parse_json(.message)
if err != null { log(err, level: "error") }
.message = msg
# Filter for specific logs
filter_requests:
type: filter
inputs:
- parse
condition: .message.msg == "http request"
# Turn log into CloudEvents
cloudevents:
type: remap
inputs:
- filter_requests
source: |
.cloudevent.specversion = "1.0"
.cloudevent.id = uuid_v7()
.cloudevent.source = .container_id
.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.route = .message.route
. = .cloudevent
sinks:
# Log CloudEvents to console, only for debugging
console_sink:
type: console
inputs:
- cloudevents
encoding:
codec: json
# Send CloudEvents to OpenMeter ingestion API
openmeter:
type: http
inputs:
- cloudevents
uri: http://openmeter:8888/api/v1/events
method: post
request:
headers:
Content-Type: application/cloudevents-batch+json
encoding:
codec: json