OKR/dev-upgrade/elastic/logstash-alert.yaml

165 lines
3.7 KiB
YAML
Raw Normal View History

2024-02-26 14:45:35 +08:00
apiVersion: v1
kind: ConfigMap
metadata:
2024-02-26 15:06:26 +08:00
name: logstash-config-alert
2024-02-26 14:45:35 +08:00
data:
logstash.conf: |-
input {
kafka{
bootstrap_servers => "10.2.0.12:30002,10.2.0.12:30003,10.2.0.12:30004"
topics => ["beaconfire-logback-prod"]
2024-02-26 16:00:48 +08:00
group_id => "logstash-app-alert"
2024-02-26 14:45:35 +08:00
auto_offset_reset => "latest"
codec => json
}
}
filter {
if [tags][json] {
json {
source => "message"
}
}
if [level] == "TRACE" {
drop {}
}
if [level] == "DEBUG" {
drop {}
}
if [level] == "INFO" {
drop {}
}
if [level] == "WARN" {
drop {}
}
if [message] =~ "Fail to parse JWT due to: Jwt expired at" {
drop {}
}
if [message] =~ "Unauthorized access" {
drop {}
}
2024-02-28 21:22:34 +08:00
if [message] =~ "exchange refresh token" {
drop {}
}
2024-03-01 14:35:39 +08:00
if [message] =~ "No sess token provided" {
drop {}
}
2024-03-01 16:31:16 +08:00
if [message] =~ "Servlet.service" {
drop {}
}
2024-03-01 17:01:40 +08:00
if [message] =~ "no data hit with the given appCode" {
drop {}
}
2024-02-26 14:45:35 +08:00
mutate {
split => { "[log][file][path]" => "/" }
add_field => { "env" => "%{[log][file][path][3]}" }
}
mutate {
join => { "[log][file][path]" => "/" }
}
2024-03-05 16:30:00 +08:00
mutate {
gsub => [
2024-03-05 16:48:34 +08:00
"message", "\n", " "
2024-03-05 16:30:00 +08:00
]
}
2024-02-29 14:25:49 +08:00
if [stack_trace] {
mutate {
gsub => [
2024-02-29 17:45:13 +08:00
"stack_trace", "\n", "_"
2024-02-29 14:25:49 +08:00
]
}
mutate {
split => { "stack_trace" => "_" }
add_field => { "stackFirst" => "%{[stack_trace][0]}" }
}
}
2024-02-26 14:45:35 +08:00
}
output {
2024-02-29 14:25:49 +08:00
#stdout { codec => json }
# if [stack_trace] {
# file {
# path => "1.json"
# codec => "json_lines"
# }
2024-02-26 14:45:35 +08:00
# }
2024-02-29 14:25:49 +08:00
if [stack_trace] {
exec {
command => "/usr/local/bin/log-alert.sh '%{@timestamp}' '%{serviceName}' '%{env}' '%{level}' '%{message}' '%{stackFirst}' "
}
} else {
exec {
command => "/usr/local/bin/log-alert.sh '%{@timestamp}' '%{serviceName}' '%{env}' '%{level}' '%{message}' '-' "
}
2024-02-26 14:45:35 +08:00
}
}
2024-02-29 14:33:59 +08:00
logstash.yml: |-
http.host: "0.0.0.0"
xpack.monitoring.elasticsearch.hosts: [ "http://elastic:9200" ]
2024-02-26 14:45:35 +08:00
---
apiVersion: apps/v1
kind: Deployment
metadata:
2024-02-26 15:34:17 +08:00
name: logstash-alert
2024-02-26 14:45:35 +08:00
labels:
2024-02-26 15:34:17 +08:00
app: logstash-alert
2024-02-26 14:45:35 +08:00
spec:
replicas: 1
selector:
matchLabels:
2024-02-26 15:34:17 +08:00
app: logstash-alert
2024-02-26 14:45:35 +08:00
template:
metadata:
labels:
2024-02-26 15:34:17 +08:00
app: logstash-alert
2024-02-26 14:45:35 +08:00
spec:
2024-02-26 15:06:26 +08:00
imagePullSecrets:
2024-02-26 15:34:17 +08:00
- name: deploy-regcred
2024-02-26 14:45:35 +08:00
containers:
2024-02-26 15:34:17 +08:00
- name: logstash-alert
2024-02-26 14:45:35 +08:00
image: beaconfireiic/logstash:7.16.3
2024-02-26 16:25:42 +08:00
imagePullPolicy: Always
2024-02-26 14:45:35 +08:00
ports:
- containerPort: 5044
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 1
memory: 1Gi
volumeMounts:
- name: config
mountPath: /usr/share/logstash/pipeline/logstash.conf
subPath: logstash.conf
readOnly: true
2024-02-29 14:33:59 +08:00
- name: config
mountPath: /usr/share/logstash/config/logstash.yml
subPath: logstash.yml
readOnly: true
2024-02-26 14:45:35 +08:00
volumes:
- name: config
configMap:
2024-02-26 15:39:36 +08:00
name: logstash-config-alert
2024-02-26 14:45:35 +08:00
items:
- key: logstash.conf
path: logstash.conf
2024-02-29 14:33:59 +08:00
- key: logstash.yml
path: logstash.yml
2024-02-26 14:45:35 +08:00
---
apiVersion: v1
kind: Service
metadata:
2024-02-26 15:34:17 +08:00
name: logstash-alert
2024-02-26 14:45:35 +08:00
labels:
2024-02-26 15:34:17 +08:00
app: logstash-alert
2024-02-26 14:45:35 +08:00
spec:
ports:
- port: 5044
targetPort: 5044
selector:
2024-02-26 15:34:17 +08:00
app: logstash-alert
2024-03-01 14:35:39 +08:00
type: ClusterIP