Skip to content

Commit

Permalink
Introduce log analysis language (LAL) (apache#6388)
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 authored Feb 23, 2021
1 parent 1d4ff66 commit 96f1c12
Show file tree
Hide file tree
Showing 42 changed files with 1,890 additions and 40 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Release Notes.
* Storage plugin supports postgresql.
* Fix kubernetes.client.opeanapi.ApiException.
* Remove filename suffix in the meter active file config.
* Introduce log analysis language (LAL).

#### UI
* Update selector scroller to show in all pages.
Expand Down
10 changes: 9 additions & 1 deletion apm-dist-es7/src/main/assembly/binary-es7.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@
<includes>
<include>log4j2.xml</include>
<include>alarm-settings.yml</include>
<include>alarm-settings-sample.yml</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../dist-material</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>config-examples/*</include>
</includes>
</fileSet>
<fileSet>
Expand All @@ -59,6 +65,8 @@
<include>zabbix-rules/*.yaml</include>
<include>otel-oc-rules/*</include>
<include>ui-initialized-templates/*</include>
<include>lal/*</include>
<include>log-mal-rules/*</include>
</includes>
<outputDirectory>/config</outputDirectory>
</fileSet>
Expand Down
10 changes: 9 additions & 1 deletion apm-dist/src/main/assembly/binary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@
<includes>
<include>log4j2.xml</include>
<include>alarm-settings.yml</include>
<include>alarm-settings-sample.yml</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/../dist-material</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>config-examples/*</include>
</includes>
</fileSet>
<fileSet>
Expand All @@ -59,6 +65,8 @@
<include>zabbix-rules/*.yaml</include>
<include>otel-oc-rules/*</include>
<include>ui-initialized-templates/*</include>
<include>lal/*</include>
<include>log-mal-rules/*</include>
</includes>
<outputDirectory>/config</outputDirectory>
</fileSet>
Expand Down
File renamed without changes.
50 changes: 50 additions & 0 deletions dist-material/config-examples/lal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Example config file of path: config/lal/config.yaml
rules:
- name: example
dsl: |
filter {
if (log.service == "TestService") {
abort {}
}
text {
if (!regexp($/(?s)(?<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}) \[TID:(?<tid>.+?)] \[(?<thread>.+?)] (?<level>\w{4,}) (?<logger>.{1,36}) (?<msg>.+)/$)) {
abort {}
}
}
extractor {
metrics {
timestamp log.timestamp
labels level: parsed.level, service: log.service, instance: log.serviceInstance
name "log_count"
value 1
}
}
sink {
sampler {
if (log.service == "ImportantApp") {
rateLimit("ImportantAppSampler") {
qps 300
}
} else {
rateLimit("OtherSampler") {
qps 30
}
}
}
}
}
37 changes: 37 additions & 0 deletions dist-material/config-examples/log-mal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This will parse a textual representation of a duration. The formats
# accepted are based on the ISO-8601 duration format {@code PnDTnHnMn.nS}
# with days considered to be exactly 24 hours.
# <p>
# Examples:
# <pre>
# "PT20.345S" -- parses as "20.345 seconds"
# "PT15M" -- parses as "15 minutes" (where a minute is 60 seconds)
# "PT10H" -- parses as "10 hours" (where an hour is 3600 seconds)
# "P2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
# "P2DT3H4M" -- parses as "2 days, 3 hours and 4 minutes"
# "P-6H3M" -- parses as "-6 hours and +3 minutes"
# "-P6H3M" -- parses as "-6 hours and -3 minutes"
# "-P-6H+3M" -- parses as "+6 hours and -3 minutes"
# </pre>

# Example config file of path: config/log-mal-rules/config.yaml
expSuffix: instance(['service'], ['instance'])
metricPrefix: log
metricsRules:
- name: count_info
exp: log_count.tagEqual('level', 'INFO').sum(['service', 'instance'])
Loading

0 comments on commit 96f1c12

Please sign in to comment.