forked from jfrog/log-analytics-prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfluent.conf.rt6
More file actions
194 lines (176 loc) · 5.06 KB
/
fluent.conf.rt6
File metadata and controls
194 lines (176 loc) · 5.06 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
## Prometheus Input Plugin Configuration
# input plugin that exports metrics
<source>
@type prometheus
</source>
<source>
@type monitor_agent
</source>
<source>
@type forward
</source>
# input plugin that collects metrics from MonitorAgent
<source>
@type prometheus_monitor
<labels>
host ${hostname}
</labels>
</source>
# input plugin that collects metrics for output plugin
<source>
@type prometheus_output_monitor
<labels>
host ${hostname}
</labels>
</source>
# input plugin that collects metrics for in_tail plugin
<source>
@type prometheus_tail_monitor
<labels>
host ${hostname}
</labels>
</source>
<source>
@type tail
@id artifactory_service_tail
path "#{ENV['ARTIFACTORY_HOME']}/logs/artifactory.log"
pos_file "#{ENV['ARTIFACTORY_HOME']}/logs/artifactory.log.pos"
tag jfrog.rt.artifactory.service
<parse>
@type multiline
format_firstline /\d{4}-\d{1,2}-\d{1,2}/
format1 /^(?<timestamp>[^.*]*) \[(?<service_type>[^\]]*)\] \[(?<log_level>[^\]]*)\] (?<class_line_number>.*) - (?<message>.+)$/
time_key timestamp
time_format %Y-%m-%d %H:%M:%S,%L
</parse>
</source>
<source>
@type tail
@id artifactory_request_tail
path "#{ENV['ARTIFACTORY_HOME']}/logs/request.log"
pos_file "#{ENV['ARTIFACTORY_HOME']}/logs/request.log.pos"
tag jfrog.rt.artifactory.request
<parse>
@type regexp
expression ^(?<timestamp>[^ ]*)\|(?<trace_id>[^\|]*)\|(?<type>[^\|]*)\|(?<remote_address>[^\|]*)\|(?<username>[^\|]*)\|(?<request_method>[^\|]*)\|(?<request_url>[^\|]*)\|(?<request_user_agent>[^\|]*)\|(?<return_status>[^\|]*)\|(?<request_duration>.+)$
time_key timestamp
time_format %Y%m%d%H%M%S
</parse>
</source>
<filter jfrog.rt.artifactory.request>
@type record_transformer
enable_ruby true
<record>
repo ${!record["request_url"].strip().start_with?("/api") ? (record["request_url"].strip().split('/')[1]) : ("")}
artifact ${!record["request_url"].strip().start_with?("/api") ? (val = record["request_url"].strip().split('/'); val[val.length()-1]) : ("")}
docker_repo ${record["request_url"].strip().include?("/api/docker") && !record["request_url"].include?("/api/docker/null") && !record["request_url"].include?("/api/docker/v2") ? (record["request_url"].strip().split('/')[3]) : ("")}
docker_image ${record["request_url"].strip().include?("/api/docker") && !record["request_url"].include?("/api/docker/null") && !record["request_url"].include?("/api/docker/v2") ? (record["request_url"].strip().split('/')[5]) : ("")}
</record>
</filter>
<source>
@type tail
@id artifactory_access_tail
path "#{ENV['ARTIFACTORY_HOME']}/logs/access.log"
pos_file "#{ENV['ARTIFACTORY_HOME']}/logs/access.log.pos"
tag jfrog.rt.artifactory.access
<parse>
@type regexp
expression ^(?<timestamp>[^.*]*) \[(?<action_response>[^\]]*)\] (?<repo_path>.*) for client : (?<username>.+) / (?<ip>.+).$
time_key timestamp
time_format %Y-%m-%d %H:%M:%S,%L
</parse>
</source>
<filter jfrog.**>
@type record_transformer
<record>
hostname "#{Socket.gethostname}"
log_source ${tag}
</record>
</filter>
#JFROG CALL HOME
<source>
@type exec
tag jfrog.callhome
command "#{ENV['ARTIFACTORY_HOME']}/fluentd-1.11.0-linux-x86_64/lib/ruby/bin/gem list --local | grep fluent | sed 's/ (/:/g' | sed 's/)//g' | sed ':a;N;$!ba;s/\n/\t/g'"
run_interval 1d
<parse>
@type ltsv
</parse>
</source>
<source>
@type exec
tag jfrog.callhome
command /opt/td-agent/embedded/bin/gem list --local | grep fluent | sed 's/ (/:/g' | sed 's/)//g' | sed ':a;N;$!ba;s/\n/\t/g'
run_interval 1d
<parse>
@type ltsv
</parse>
</source>
<filter jfrog.callhome>
@type record_transformer
renew_record true
keep_keys 'productId,features'
enable_ruby true
<record>
productId 'jfrogLogAnalytics/v0.1.0'
features ${return(record.map { |k,v| { "featureId" => (k + ':' + v).to_sym} })}
</record>
</filter>
<match jfrog.callhome>
@type http
endpoint http://localhost:8081/artifactory/api/system/usage
open_timeout 5
content_type application/json
<format>
@type json
</format>
<buffer>
flush_interval 5s
</buffer>
</match>
#END CALL HOME
<filter jfrog.rt.artifactory.request>
@type prometheus
<metric>
name jfrog_rt_req_total
type counter
desc artifactory requests
<labels>
host ${hostname}
request_url ${request_url}
return_status ${return_status}
repo ${repo}
artifact ${artifact}
docker_image ${docker_image}
docker_repo ${docker_repo}
remote_address ${remote_address}
method ${request_method}
</labels>
</metric>
</filter>
<filter jfrog.rt.artifactory.service>
@type prometheus
<metric>
name jfrog_rt_log_level_total
type counter
desc artifactory log_levels
<labels>
host ${hostname}
log_level ${log_level}
</labels>
</metric>
</filter>
<filter jfrog.rt.artifactory.access>
@type prometheus
<metric>
name jfrog_rt_access_total
type counter
desc artifactory access
<labels>
host ${hostname}
username ${username}
action_response ${action_response}
ip ${ip}
</labels>
</metric>
</filter>