Skip to content

Commit 896ff03

Browse files
committed
updating the logstash migration example
Signed-off-by: Anton Rubin <[email protected]>
1 parent 18a8131 commit 896ff03

File tree

1 file changed

+113
-7
lines changed

1 file changed

+113
-7
lines changed

_data-prepper/migrating-from-logstash-data-prepper.md

Lines changed: 113 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,126 @@ As of the Data Prepper 1.2 release, the following plugins from the Logstash conf
2929

3030
## Running Data Prepper with a Logstash configuration
3131

32-
1. To install Data Prepper's Docker image, see Installing Data Prepper in [Getting Started with OpenSearch Data Prepper]({{site.url}}{{site.baseurl}}/data-prepper/getting-started#1-installing-data-prepper).
32+
If you have OpenSearch running on your host and want to run Data Prepper Docker container with Logstash configuration, follow these steps:
3333

34-
2. Run the Docker image installed in Step 1 by supplying your `logstash.conf` configuration.
34+
1. Update the `elasticsearch` section of `logstash.conf` to point to your OpenSearch instance. The host name has to match the OpenSearch certificate SANs, for example `node-0.example.com` if demo installation is used.
3535

36-
```
37-
docker run --name data-prepper -p 4900:4900 -v ${PWD}/logstash.conf:/usr/share/data-prepper/pipelines.conf opensearchproject/data-prepper:latest pipelines.conf
38-
```
36+
```
37+
input {
38+
http {
39+
port => 4910 # Note the port used in this example
40+
}
41+
}
42+
filter {
43+
grok {
44+
match => { "message" => "%{COMBINEDAPACHELOG}" }
45+
tag_on_failure => []
46+
}
47+
}
48+
output {
49+
# Point this at your OpenSearch/OSD endpoint
50+
elasticsearch {
51+
hosts => ["https://node-0.example.com:9200"] # change to your host:port
52+
index => "logstash-%{+YYYY.MM.dd}"
53+
user => "admin"
54+
password => "<admin_pass>"
55+
ssl => true
56+
ssl_certificate_verification => true
57+
}
58+
}
59+
```
60+
{% include copy-curl.html %}
61+
62+
1. Supply your `logstash.conf` configuration to Data Prepper Docker container, using the following command:
63+
64+
```bash
65+
docker run --rm --name data-prepper \
66+
--add-host node-0.example.com:host-gateway \
67+
-p 4910:4910 \
68+
-v "${PWD}/logstash.conf:/usr/share/data-prepper/logstash.conf" \
69+
--entrypoint bin/data-prepper \
70+
opensearchproject/data-prepper:latest \
71+
/usr/share/data-prepper/logstash.conf \
72+
/usr/share/data-prepper/config/data-prepper-config.yaml
73+
```
74+
{% include copy-curl.html %}
3975
4076
The `logstash.conf` file is converted to `logstash.yaml` by mapping the plugins and attributes in the Logstash configuration to the corresponding plugins and attributes in Data Prepper.
41-
You can find the converted `logstash.yaml` file in the same directory where you stored `logstash.conf`.
77+
You can find the converted `logstash.yaml` file in the same directory where you stored `logstash.conf`. See the converted `logstash.yaml` sample file:
78+
79+
```
80+
logstash-converted-pipeline:
81+
source:
82+
http:
83+
max_connection_count: 500
84+
request_timeout: 10000
85+
port: 4910
86+
processor:
87+
- grok:
88+
match:
89+
message:
90+
- "%{COMBINEDAPACHELOG}"
91+
sink:
92+
- opensearch:
93+
hosts:
94+
- "https://node-0.example.com:9200"
95+
username: "admin"
96+
password: "<admin_pass>"
97+
index: "logstash-%{yyyy.MM.dd}"
98+
```
4299
43100
44101
The following output in your terminal indicates that Data Prepper is running correctly:
45102
46103
```
47-
INFO org.opensearch.dataprepper.pipeline.ProcessWorker - log-pipeline Worker: No records received from buffer
104+
INFO org.opensearch.dataprepper.plugins.source.loghttp.HTTPSource - Started http source on port 4910...
48105
```
106+
107+
To test this further, run the following command on your host to push sample data to Data Prepper:
108+
109+
```bash
110+
curl -X POST "http://localhost:4910/log/ingest" \
111+
-H "Content-Type: application/json" \
112+
-d '[{"message":"hello"}]'
113+
```
114+
{% include copy-curl.html %}
115+
116+
After a couple of seconds you can query OpenSearch `logstash-*` index for this document:
117+
118+
```bash
119+
curl -k -uadmin:"<admin_pass>" "https://localhost:9200/logstash-*/_search?pretty"
120+
```
121+
{% include copy-curl.html %}
122+
123+
The sample document will be returned:
124+
125+
```json
126+
{
127+
"took" : 2,
128+
"timed_out" : false,
129+
"_shards" : {
130+
"total" : 1,
131+
"successful" : 1,
132+
"skipped" : 0,
133+
"failed" : 0
134+
},
135+
"hits" : {
136+
"total" : {
137+
"value" : 1,
138+
"relation" : "eq"
139+
},
140+
"max_score" : 1.0,
141+
"hits" : [
142+
{
143+
"_index" : "logstash-2025.10.10",
144+
"_id" : "dHnSzZkBIk7UWjH_Kjxh",
145+
"_score" : 1.0,
146+
"_source" : {
147+
"message" : "hello"
148+
}
149+
}
150+
]
151+
}
152+
}
153+
```
154+

0 commit comments

Comments
 (0)