Skip to content

Commit 9f05535

Browse files
gitlayzergitlayzer
andauthored
add logstash template (#21)
Co-authored-by: gitlayzer <18037803502@163.com>
1 parent cfba89d commit 9f05535

3 files changed

Lines changed: 377 additions & 0 deletions

File tree

template/logstash/README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Logstash
2+
3+
Logstash is part of the [Elastic Stack](https://www.elastic.co/products) along with Beats, Elasticsearch and Kibana. Logstash is a server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to your favorite "stash." (Ours is Elasticsearch, naturally.). Logstash has over 200 plugins, and you can write your own very easily as well.
4+
5+
For more info, see <https://www.elastic.co/products/logstash>
6+
7+
## Documentation and Getting Started
8+
9+
You can find the documentation and getting started guides for Logstash on the [elastic.co site](https://www.elastic.co/guide/en/logstash/current/getting-started-with-logstash.html)
10+
11+
For information about building the documentation, see the README in <https://github.com/elastic/docs>
12+
13+
## Downloads
14+
15+
You can download officially released Logstash binaries, as well as debian/rpm packages for the supported platforms, from the [downloads page](https://www.elastic.co/downloads/logstash).
16+
17+
## Need Help?
18+
19+
- [Logstash Forum](https://discuss.elastic.co/c/logstash)
20+
- [Logstash Documentation](https://www.elastic.co/guide/en/logstash/current/index.html)
21+
- [Logstash Product Information](https://www.elastic.co/products/logstash)
22+
- [Elastic Support](https://www.elastic.co/subscriptions)
23+
24+
## Logstash Plugins
25+
26+
Logstash plugins are hosted in separate repositories under the [logstash-plugins](https://github.com/logstash-plugins) GitHub organization. Each plugin is a self-contained Ruby gem which gets published to RubyGems.org.
27+
28+
### Writing Your Own Plugin
29+
30+
Logstash is known for its extensibility. There are hundreds of plugins for Logstash and you can write your own very easily. For more info on developing and testing these plugins, please see the [working with plugins section](https://www.elastic.co/guide/en/logstash/current/contributing-to-logstash.html).
31+
32+
### Plugin Issues and Pull Requests
33+
34+
Please open new issues and pull requests for plugins under their own repository.
35+
36+
For example, if you have to report an issue or enhancement for the Elasticsearch output, please do so [here](https://github.com/logstash-plugins/logstash-output-elasticsearch/issues).
37+
38+
Logstash core will continue to exist under this repository and all related issues and pull requests can be submitted there.
39+
40+
## Developing Logstash Core
41+
42+
### Prerequisites
43+
44+
- Install JDK version 21. Make sure to set the `JAVA_HOME` environment variable to the path to your JDK installation directory. For example `set JAVA_HOME=<JDK_PATH>`.
45+
- Install JRuby 10.0.5.0. It is recommended to use a Ruby version manager such as [RVM](https://rvm.io/) or [rbenv](https://github.com/rbenv/rbenv).
46+
- Install `rake` and `bundler` using `gem install rake` and `gem install bundler`.
47+
48+
### Verify the Installation
49+
50+
To verify your environment, run the following to start Logstash and send your first event:
51+
52+
```sh
53+
bin/logstash -e 'input { stdin { } } output { stdout {} }'
54+
```
55+
56+
This should start Logstash with stdin input waiting for you to enter an event:
57+
58+
```text
59+
hello world
60+
2016-11-11T01:22:14.405+0000 0.0.0.0 hello world
61+
```
62+
63+
## Testing
64+
65+
Most of the unit tests in Logstash are written using [rspec](http://rspec.info/) for the Ruby parts. For the Java parts, Logstash uses [junit](https://junit.org). For testing you can use the `rake` tasks and the `bin/rspec` command.
66+
67+
### Core Tests
68+
69+
1. Run the core tests with:
70+
71+
```sh
72+
./gradlew test
73+
```
74+
75+
2. Run Java-only tests with:
76+
77+
```sh
78+
./gradlew javaTests
79+
```
80+
81+
3. Execute the full suite including integration tests with:
82+
83+
```sh
84+
./gradlew check
85+
```
86+
87+
### Plugin Tests
88+
89+
To run the tests of all currently installed plugins:
90+
91+
```sh
92+
rake test:plugins
93+
```
94+
95+
To install the default set of plugins included in the Logstash package:
96+
97+
```sh
98+
rake test:install-default
99+
```
100+
101+
## Building Artifacts
102+
103+
Built artifacts are placed in the `LS_HOME/build` directory. You can build snapshot packages as tarball or zip:
104+
105+
```sh
106+
./gradlew assembleTarDistribution
107+
./gradlew assembleZipDistribution
108+
```
109+
110+
OSS-only artifacts can be built with:
111+
112+
```sh
113+
./gradlew assembleOssTarDistribution
114+
./gradlew assembleOssZipDistribution
115+
```
116+
117+
## Contributing
118+
119+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
120+
121+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/main/CONTRIBUTING.md) file.

template/logstash/favicon.ico

9.44 KB
Binary file not shown.

template/logstash/index.yaml

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
apiVersion: app.sealos.io/v1
2+
kind: Template
3+
metadata:
4+
name: logstash
5+
spec:
6+
title: "Logstash"
7+
url: "https://www.elastic.co/logstash"
8+
gitRepo: "https://github.com/elastic/logstash"
9+
author: "Sealos"
10+
description: "Logstash is a server-side data processing pipeline for ingesting Beats data and forwarding it to Elasticsearch."
11+
readme: "https://raw.githubusercontent.com/labring-actions/templates/main/logstash/README.md"
12+
icon: "https://raw.githubusercontent.com/labring-actions/templates/main/template/logstash/favicon.ico"
13+
templateType: inline
14+
categories:
15+
- tools
16+
defaults:
17+
app_name:
18+
type: string
19+
value: logstash-${{ random(8) }}
20+
inputs:
21+
elasticsearch_username:
22+
description: "Elasticsearch username for Logstash output"
23+
type: string
24+
default: "elastic"
25+
required: true
26+
elasticsearch_password:
27+
description: "Elasticsearch password for Logstash output"
28+
type: string
29+
default: ""
30+
required: true
31+
32+
---
33+
apiVersion: v1
34+
kind: Secret
35+
metadata:
36+
name: ${{ defaults.app_name }}-es-auth
37+
labels:
38+
cloud.sealos.io/app-deploy-manager: ${{ defaults.app_name }}
39+
type: Opaque
40+
stringData:
41+
ELASTICSEARCH_USERNAME: ${{ inputs.elasticsearch_username }}
42+
ELASTICSEARCH_PASSWORD: ${{ inputs.elasticsearch_password }}
43+
44+
---
45+
apiVersion: v1
46+
kind: ConfigMap
47+
metadata:
48+
name: ${{ defaults.app_name }}-config
49+
labels:
50+
cloud.sealos.io/app-deploy-manager: ${{ defaults.app_name }}
51+
app: ${{ defaults.app_name }}
52+
data:
53+
logstash.yml: |
54+
http.host: 0.0.0.0
55+
xpack.monitoring.enabled: false
56+
57+
queue.type: persisted
58+
path.queue: /usr/share/logstash/data/queue
59+
queue.max_bytes: 1gb
60+
61+
dead_letter_queue.enable: true
62+
path.dead_letter_queue: /usr/share/logstash/data/dead_letter_queue
63+
64+
config.reload.automatic: false
65+
config.reload.interval: 10s
66+
67+
log.level: info
68+
path.logs: /usr/share/logstash/logs
69+
70+
pipelines.yml: |
71+
- pipeline.id: main
72+
path.config: "/usr/share/logstash/pipeline/*.conf"
73+
pipeline.workers: 2
74+
pipeline.batch.size: 125
75+
pipeline.batch.delay: 50
76+
77+
logstash.conf: |
78+
input {
79+
beats {
80+
port => 5044
81+
client_inactivity_timeout => 300
82+
}
83+
}
84+
85+
filter {
86+
}
87+
88+
output {
89+
elasticsearch {
90+
hosts => ["http://elasticsearch.logging.svc.cluster.local:9200"]
91+
user => "${ELASTICSEARCH_USERNAME}"
92+
password => "${ELASTICSEARCH_PASSWORD}"
93+
index => "logstash-%{+YYYY.MM.dd}"
94+
ilm_enabled => false
95+
}
96+
97+
stdout {
98+
codec => rubydebug
99+
}
100+
}
101+
102+
---
103+
apiVersion: v1
104+
kind: Service
105+
metadata:
106+
name: ${{ defaults.app_name }}-headless
107+
labels:
108+
cloud.sealos.io/app-deploy-manager: ${{ defaults.app_name }}
109+
app: ${{ defaults.app_name }}
110+
spec:
111+
clusterIP: None
112+
selector:
113+
app: ${{ defaults.app_name }}
114+
ports:
115+
- name: beats
116+
port: 5044
117+
targetPort: 5044
118+
- name: http
119+
port: 9600
120+
targetPort: 9600
121+
122+
---
123+
apiVersion: v1
124+
kind: Service
125+
metadata:
126+
name: ${{ defaults.app_name }}
127+
labels:
128+
cloud.sealos.io/app-deploy-manager: ${{ defaults.app_name }}
129+
app: ${{ defaults.app_name }}
130+
spec:
131+
selector:
132+
app: ${{ defaults.app_name }}
133+
ports:
134+
- name: beats
135+
port: 5044
136+
targetPort: 5044
137+
- name: http
138+
port: 9600
139+
targetPort: 9600
140+
141+
---
142+
apiVersion: apps/v1
143+
kind: StatefulSet
144+
metadata:
145+
name: ${{ defaults.app_name }}
146+
annotations:
147+
originImageName: docker.elastic.co/logstash/logstash:6.8.6
148+
deploy.cloud.sealos.io/minReplicas: "1"
149+
deploy.cloud.sealos.io/maxReplicas: "1"
150+
labels:
151+
cloud.sealos.io/app-deploy-manager: ${{ defaults.app_name }}
152+
app: ${{ defaults.app_name }}
153+
spec:
154+
serviceName: ${{ defaults.app_name }}-headless
155+
replicas: 1
156+
selector:
157+
matchLabels:
158+
app: ${{ defaults.app_name }}
159+
updateStrategy:
160+
type: RollingUpdate
161+
template:
162+
metadata:
163+
labels:
164+
app: ${{ defaults.app_name }}
165+
spec:
166+
terminationGracePeriodSeconds: 120
167+
securityContext:
168+
fsGroup: 1000
169+
affinity:
170+
podAntiAffinity:
171+
preferredDuringSchedulingIgnoredDuringExecution:
172+
- weight: 100
173+
podAffinityTerm:
174+
topologyKey: kubernetes.io/hostname
175+
labelSelector:
176+
matchLabels:
177+
app: ${{ defaults.app_name }}
178+
containers:
179+
- name: ${{ defaults.app_name }}
180+
image: docker.elastic.co/logstash/logstash:6.8.6
181+
imagePullPolicy: IfNotPresent
182+
ports:
183+
- name: beats
184+
containerPort: 5044
185+
- name: http
186+
containerPort: 9600
187+
env:
188+
- name: LS_JAVA_OPTS
189+
value: "-Xms1g -Xmx1g"
190+
- name: ELASTICSEARCH_USERNAME
191+
valueFrom:
192+
secretKeyRef:
193+
name: ${{ defaults.app_name }}-es-auth
194+
key: ELASTICSEARCH_USERNAME
195+
- name: ELASTICSEARCH_PASSWORD
196+
valueFrom:
197+
secretKeyRef:
198+
name: ${{ defaults.app_name }}-es-auth
199+
key: ELASTICSEARCH_PASSWORD
200+
resources:
201+
requests:
202+
cpu: "500m"
203+
memory: "2Gi"
204+
limits:
205+
cpu: "2"
206+
memory: "2Gi"
207+
readinessProbe:
208+
httpGet:
209+
path: /
210+
port: 9600
211+
initialDelaySeconds: 60
212+
periodSeconds: 10
213+
timeoutSeconds: 5
214+
failureThreshold: 12
215+
livenessProbe:
216+
httpGet:
217+
path: /
218+
port: 9600
219+
initialDelaySeconds: 120
220+
periodSeconds: 20
221+
timeoutSeconds: 5
222+
failureThreshold: 6
223+
lifecycle:
224+
preStop:
225+
exec:
226+
command:
227+
- /bin/bash
228+
- -c
229+
- |
230+
kill -TERM 1
231+
sleep 60
232+
volumeMounts:
233+
- name: config
234+
mountPath: /usr/share/logstash/config/logstash.yml
235+
subPath: logstash.yml
236+
- name: config
237+
mountPath: /usr/share/logstash/config/pipelines.yml
238+
subPath: pipelines.yml
239+
- name: config
240+
mountPath: /usr/share/logstash/pipeline/logstash.conf
241+
subPath: logstash.conf
242+
- name: data
243+
mountPath: /usr/share/logstash/data
244+
volumes:
245+
- name: config
246+
configMap:
247+
name: ${{ defaults.app_name }}-config
248+
volumeClaimTemplates:
249+
- metadata:
250+
name: data
251+
spec:
252+
accessModes:
253+
- ReadWriteOnce
254+
resources:
255+
requests:
256+
storage: 1Gi

0 commit comments

Comments
 (0)