You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the `—debug` flag to see a more detailed output.
139
169
140
170
2. Enter "hello world"in your terminal. Logstash processes the text and outputs it back to the terminal:
@@ -162,6 +192,7 @@ If you already have a Logstash process running, you’ll get an error. To fix th
162
192
cd data
163
193
rm -rf .lock
164
194
```
195
+
{% include copy.html %}
165
196
166
197
2. Restart Logstash.
167
198
@@ -171,7 +202,7 @@ To define a pipeline that handles JSON requests:
171
202
172
203
1. Open the `config/pipeline.conf` file in any text editor you like. You can create a pipeline configuration file with any extension, the `.conf` extension is a Logstash convention. Add the `json` codec to accept JSON as the input and the `file` plugin to output the processed events to a `.txt` file:
173
204
174
-
```yml
205
+
```json
175
206
input {
176
207
stdin {
177
208
codec => json
@@ -183,22 +214,25 @@ To define a pipeline that handles JSON requests:
183
214
}
184
215
}
185
216
```
217
+
{% include copy.html %}
186
218
187
219
To process inputs from a file, add an input file to the `events-data` directory and then pass its path to the `file` plugin at the input:
188
220
189
-
```yml
221
+
```json
190
222
input {
191
223
file {
192
224
path =>"events-data/input_data.log"
193
225
}
194
226
}
195
227
```
228
+
{% include copy.html %}
196
229
197
230
2. Start Logstash:
198
231
199
232
```bash
200
-
$ bin/logstash -f config/pipeline.conf
233
+
bin/logstash -f config/pipeline.conf
201
234
```
235
+
{% include copy.html %}
202
236
203
237
`config/pipeline.conf` is a relative path to the `pipeline.conf` file. You can use an absolute path as well.
204
238
@@ -207,14 +241,18 @@ To define a pipeline that handles JSON requests:
207
241
```json
208
242
{ "amount": 10, "quantity": 2}
209
243
```
244
+
{% include copy.html %}
210
245
211
246
The pipeline only handles a single line of input. If you paste some JSON that spans multiple lines, you’ll get an error.
212
247
213
248
4. Check that the fields from the JSON object are added to the `output.txt` file:
214
249
215
-
```json
216
-
$ cat output.txt
250
+
```bash
251
+
cat output.txt
252
+
```
253
+
{% include copy.html %}
217
254
255
+
```json
218
256
{
219
257
"@version": "1",
220
258
"@timestamp": "2021-05-30T05:52:52.421Z",
@@ -230,7 +268,7 @@ To define a pipeline that handles HTTP requests:
230
268
231
269
1. Use the `http` plugin to send events to Logstash through HTTP:
232
270
233
-
```yml
271
+
```json
234
272
input {
235
273
http {
236
274
host =>"127.0.0.1"
@@ -244,31 +282,34 @@ To define a pipeline that handles HTTP requests:
244
282
}
245
283
}
246
284
```
285
+
{% include copy.html %}
247
286
248
287
If you don’t specify any options, the `http` plugin binds to `localhost` and listens on port 8080.
249
288
250
289
2. Start Logstash:
251
290
252
291
```bash
253
-
$ bin/logstash -f config/pipeline.conf
292
+
bin/logstash -f config/pipeline.conf
254
293
```
294
+
{% include copy.html %}
255
295
256
296
3. Use Postman to send an HTTP request. Set `Content-Type` to an HTTP header with a value of `application/json`:
Even though we haven't added the `json` plugin to the input, the pipeline configuration still works because the HTTP plugin automatically applies the appropriate codec based on the `Content-Type` header.
274
315
If you specify a value of `applications/json`, Logstash parses the request body as JSON.
Logstash only processes any new events added to the input file and ignores the ones that it has already processed to avoid processing the same event more than once on restart.
0 commit comments