-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.yaml
116 lines (89 loc) · 4.3 KB
/
example.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# This is the entry point and specifies a list of log-specific configurations.
# So, which files do you want to monitor...?
logs:
# The path to a monitored log should usually be absolute, but we are using a relative path
# here to make this example config work on different user's machines:
- path: logs/kernel.log
# For each log file, one or more patterns should be specified.
# The pattern describes how log lines are mapped to Prometheus metrics:
patterns:
# A pattern starts with a `match` key, which contains a regular expression.
# Patterns are anchored. Therefore, typically there is no need for using ^ or $ characters.
- match: 'panic:.*'
# The next step is specifying the Prometheus metric name:
metric: kernel_panics
# ... and you also have to tell us whether this is a monotonically increasing metric
# (a `counter`, as seen here) or a gauge (see below):
type: counter
# A short help text should be provided. It is included in the Prometheus metric output.
help: Number of kernel panics
# The action specifies what to do when the pattern matches.
# In this case it is set to `inc`, which means to increment the counter.
action: inc
# The counter is incremented by the content of the `value` field.
# In this case, each match would lead to the counter being increased by one:
value: 1
# If this pattern matches the current line, further pattern processing should continue.
# The default behavior would be to stop processing patterns.
continue: true
- match: 'panic:.*'
metric: kernel_panic_timestamp_seconds
type: gauge
# A short help text should be provided. It is included in the Prometheus metric output.
help: Timestamp of last kernel panic
action: set
# If the log line is found, set the metric to the current UNIX time:
value: now()
# If this pattern matches the current line, further pattern processing is stopped.
# This is the default behavior (if `continue` was omitted).
continue: false
- path: logs/instance.log
patterns:
# This match pattern shows that you can make use of capturing groups:
- match: 'copying (?P<bytes>\d+) bytes in instance (?P<instance>[^ ]+), result'
metric: copied_bytes
type: counter
help: Amount of bytes copied
# Until now, we did not encounter a metric with labels. Now, there is one.
# The provided labels will be added to the output in the typical Prometheus
# syntax:
labels:
# Results from capturing groups can be referenced in labels using the dollar sign:
instance: $instance
action: inc
# Capturing group results can also be referenced in the value field:
value: $bytes
# In this case, we want pattern processing to continue, even if this entry matched.
# This can make sense when you want to count all lines which denote a request, but
# want to add an additional metric for all lines which (in addition) contain an
# error indicator:
continue: true
- match: 'copying (?P<bytes>\d+) bytes in instance (?P<instance>[^ ]+), result'
metric: copying_requests_total
type: counter
help: Number of copying requests
labels:
instance: $instance
action: inc
value: 1
continue: true
- match: 'copying (?P<bytes>\d+) bytes in instance (?P<instance>[^ ]+), result: error'
metric: copying_errors_total
type: counter
help: Number of errors in copying requests
labels:
instance: $instance
action: inc
value: 1
- match: 'users only in pool (?P<pool>[^ ]+): (?P<count>\d+)'
metric: users_only
# Until now we have only seen counters. Now we have a gauge. In contrast to a counter,
# a gauge may fluctuate arbitrarily. Its value may also decrease.
type: gauge
help: Number of users online
labels:
pool: $pool
# In contrast to a counter, a gauge can also be set explicitly, which is what we do here.
# This is useful if the log contains some kind of current status information:
action: set
value: $count