From 1dd86dc3fadeb14558b87100330ffdfa2ab42bce Mon Sep 17 00:00:00 2001 From: ycz008 Date: Fri, 27 Oct 2023 17:54:59 +0800 Subject: [PATCH] add logstash ngx --- dev-upgrade/elastic/logstash-ngx.yaml | 92 +++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 dev-upgrade/elastic/logstash-ngx.yaml diff --git a/dev-upgrade/elastic/logstash-ngx.yaml b/dev-upgrade/elastic/logstash-ngx.yaml new file mode 100644 index 0000000..fa133d5 --- /dev/null +++ b/dev-upgrade/elastic/logstash-ngx.yaml @@ -0,0 +1,92 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: logstash-ngx-config +data: + logstash.conf: |- + input { + beats { + port => 5044 + } + } + + filter { + mutate { + add_field => { "env" => "%{[tags][0]}" } + remove_field => [ "tags" ] + } + } + + output { + elasticsearch { + hosts => ["http://elastic:9200"] + index => "%{[env]}-nginx-%{+YYYY.MM.dd}" + } + } + logstash.yml: |- + http.host: "0.0.0.0" + xpack.monitoring.elasticsearch.hosts: [ "http://elastic:9200" ] + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: logstash-ngx + labels: + app: logstash-ngx +spec: + replicas: 1 + selector: + matchLabels: + app: logstash-ngx + template: + metadata: + labels: + app: logstash-ngx + spec: + containers: + - name: logstash-ngx + image: docker.elastic.co/logstash/logstash:7.16.3 + 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 + - name: config + mountPath: /usr/share/logstash/config/logstash.yml + subPath: logstash.yml + readOnly: true + volumes: + - name: config + configMap: + name: logstash-ngx-config + items: + - key: logstash.conf + path: logstash.conf + - key: logstash.yml + path: logstash.yml + +--- +apiVersion: v1 +kind: Service +metadata: + name: logstash-ngx + labels: + app: logstash-ngx +spec: + ports: + - port: 5044 + targetPort: 5044 + nodePort: 35044 + selector: + app: logstash-ngx + type: NodePort \ No newline at end of file