wiki:logstash_setup
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
wiki:logstash_setup [2024/08/27 13:00] – created antisa | wiki:logstash_setup [2024/10/17 13:05] (current) – [nginx logs using regular indices] add info about multiple file inputs antisa | ||
---|---|---|---|
Line 10: | Line 10: | ||
===== Examples ===== | ===== Examples ===== | ||
- | ==== nginx logs ==== | + | ==== nginx logs using regular indices |
< | < | ||
input { | input { | ||
Line 46: | Line 46: | ||
</ | </ | ||
+ | <WRAP center round tip 60%> | ||
+ | You can also use multiple file inputs like so: | ||
+ | < | ||
+ | input { | ||
+ | file { path => [ | ||
+ | "/ | ||
+ | "/ | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | ... | ||
+ | </ | ||
+ | </ | ||
Above we're using a grok pattern named **NGINX_ACCESS** stored in patterns directory. Example of pattern: | Above we're using a grok pattern named **NGINX_ACCESS** stored in patterns directory. Example of pattern: | ||
Line 167: | Line 179: | ||
'' | '' | ||
+ | |||
+ | ==== nginx logs using datastreams ==== | ||
+ | This is perhaps a better approach, using [[https:// | ||
+ | |||
+ | Change the logstash '' | ||
+ | |||
+ | < | ||
+ | ... | ||
+ | output { | ||
+ | opensearch { | ||
+ | hosts => " | ||
+ | user => " | ||
+ | password | ||
+ | ssl_certificate_verification => false | ||
+ | action | ||
+ | index => " | ||
+ | } | ||
+ | }... | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | In Opensearch you need to create a datastream, but first you need to create a template. | ||
+ | |||
+ | **1.** Go to Index Management > Templates > Create template | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | **2.** Add template name, select type "Data streams" | ||
+ | {{ : | ||
+ | |||
+ | **3.** You can add an alias if you want, replicas are set to 0 here to save some space. | ||
+ | {{ : | ||
+ | |||
+ | **4.** In field mappings you need to map the fields sent by logstash. Easiest is to c/p the json into json editor from existing index, like the one that would be created by logstash using the regular index (see above). | ||
+ | {{ : | ||
+ | |||
+ | **5.** When creating datastream the name must match the pattern from step 2 above, but it doesn' | ||
+ | {{ : | ||
+ | |||
+ | |||
+ | |||
====== Tested on ====== | ====== Tested on ====== | ||
- | * | + | * logstash-8.14.3 |
+ | * Opensearch 2.15 | ||
====== See also ====== | ====== See also ====== | ||
+ | * [[wiki: | ||
* [[wiki: | * [[wiki: | ||
| |
wiki/logstash_setup.1724763617.txt.gz · Last modified: 2024/08/27 13:00 by antisa