
ज़ीक लॉग को फ़िल्टर करके Elastic/OpenSearch+Humio में स्थानांतरित करने के लिए एक Python एप्लिकेशन। यह ऐप आगे की प्रोसेसिंग के लिए शुद्ध JSON लॉग को stdout पर आउटपुट भी कर सकता है!
यह Python एप्लिकेशन Zeek के ASCII TSV और JSON लॉग्स को ElasticSearch के bulk load JSON प्रारूप में अनुवादित करता है।

क्या आप एक ही कनेक्शन ID (uid) के लिए कई Zeek लॉग देखना चाहते हैं या फ़ाइल ID (fuid)? यहाँ files.log, http.log, और conn.log एक ही uid के लिए दिए गए परिणाम हैं:

आप Zeek के 'addr' प्रकार पर सबनेट खोज कर सकते हैं:

आप समय-श्रृंखला ग्राफ़ बना सकते हैं, जैसे यह NTP और HTTP ग्राफ़:

IP पते -g कमांड लाइन विकल्प के साथ जियोलोकेट किए जा सकते हैं:

एग्रीगेशन सरल और त्वरित हैं:

यह एप्लिकेशन Zeek लॉग प्रारूप बदलने पर "बस काम करेगा"। तर्क फ़ील्ड नामों और संबंधित प्रकारों को पढ़ता है ताकि ElasticSearch में मैपिंग सही ढंग से सेट की जा सके।
यह एप्लिकेशन gzip या असम्पीडित लॉग्स को पहचान लेगा। यह एप्लिकेशन मानता है
कि आपने अपने localhost पर डिफ़ॉल्ट पोर्ट पर ElasticSearch सेट किया है।
यदि आपके पास ElasticSearch नहीं है, तो आप JSON को -s -b कमांड लाइन विकल्पों के साथ stdout पर आउटपुट कर सकते हैं
ताकि jq एप्लिकेशन से प्रोसेस किया जा सके।
आप -k कमांड लाइन विकल्प के साथ टेक्स्ट फ़ील्ड्स में keyword सबफ़ील्ड जोड़ सकते हैं। यह
Kibana में एग्रीगेशन के लिए उपयोगी है।
यदि आपके सिस्टम पर Python पहले से है, तो आपको अपनी मशीन पर Elasticsearch, Kibana और zeek2es.py के अलावा कुछ भी अतिरिक्त कॉपी करने की आवश्यकता नहीं है, यदि आपके पास पहले से requests लाइब्रेरी स्थापित है।
यह मानते हुए कि आप आवश्यकताओं को पूरा करते हैं, कुछ भी स्थापित करने की आवश्यकता नहीं है। आपको बस
zeek2es.py को अपने होस्ट पर कॉपी करके Python के साथ चलाना है। एक बार Zeek
लॉग्स को स्वचालित इंडेक्स नाम जनरेशन के साथ आयात किया जाता है (अर्थात, आपने -i विकल्प नहीं दिया था),
तो आपको अपने इंडेक्स "zeek_zeeklogname_date" नाम से मिलेंगे, जहाँ zeeklogname एक लॉग नाम है जैसे conn
और date YYYY-MM-DD प्रारूप में होता है। इस स्थिति में अपना Kibana इंडेक्स पैटर्न zeek* से मेल खाने के लिए सेट करें। यदि
आपने -i विकल्प के साथ अपना इंडेक्स नाम दिया है, तो आपको एक Kibana इंडेक्स पैटर्न बनाने की आवश्यकता होगी जो
आपकी नामकरण योजना से मेल खाता हो।
यदि आप zeek2es को अपग्रेड कर रहे हैं, तो कृपया zeek2es को अपग्रेड करने वाला अनुभाग देखें।
चूँकि इंडेक्स में दिनांक जोड़ दी जाती है, आप निम्न कमांड से 31 दिसंबर, 2021 को हटा सकते हैं:``` curl -X DELETE http://localhost:9200/zeek_*_2021-12-31
आप इस कमांड से सभी conn.log प्रविष्टियाँ हटा सकते हैं:```
curl -X DELETE http://localhost:9200/zeek_conn_*
optional arguments:
-h, --help show this help message and exit
-i ESINDEX, --esindex ESINDEX
The Elasticsearch index/data stream name.
-u ESURL, --esurl ESURL
The Elasticsearch URL. Use ending slash. Use https for Elastic v8+. (default: http://localhost:9200)
--user USER The Elasticsearch user. (default: disabled)
--passwd PASSWD The Elasticsearch password. Note this will put your password in this shell history file. (default: disabled)
-l LINES, --lines LINES
Lines to buffer for RESTful operations. (default: 10,000)
-n NAME, --name NAME The name of the system to add to the index for uniqueness. (default: empty string)
-k KEYWORDS [KEYWORDS ...], --keywords KEYWORDS [KEYWORDS ...]
A list of text fields to add a keyword subfield. (default: service)
-a LAMBDAFILTER, --lambdafilter LAMBDAFILTER
A Python lambda function, when eval'd will filter your output JSON dict. (default: empty string)
-f FILTERFILE, --filterfile FILTERFILE
A Python function file, when eval'd will filter your output JSON dict. (default: empty string)
-y OUTPUTFIELDS [OUTPUTFIELDS ...], --outputfields OUTPUTFIELDS [OUTPUTFIELDS ...]
A list of fields to keep for the output. Must include ts. (default: empty string)
-d DATASTREAM, --datastream DATASTREAM
Instead of an index, use a data stream that will rollover at this many GB.
Recommended is 50 or less. (default: 0 - disabled)
--compress If a datastream is used, enable best compression.
-o fieldname filename, --logkey fieldname filename
A field to log to a file. Example: uid uid.txt.
Will append to the file! Delete file before running if appending is undesired.
This option can be called more than once. (default: empty - disabled)
-e fieldname filename, --filterkeys fieldname filename
A field to filter with keys from a file. Example: uid uid.txt. (default: empty string - disabled)
-g, --ingestion Use the ingestion pipeline to do things like geolocate IPs and split services. Takes longer, but worth it.
-p SPLITFIELDS [SPLITFIELDS ...], --splitfields SPLITFIELDS [SPLITFIELDS ...]
A list of additional fields to split with the ingestion pipeline, if enabled.
(default: empty string - disabled)
-j, --jsonlogs Assume input logs are JSON.
-r, --origtime Keep the numerical time format, not milliseconds as ES needs.
-t, --timestamp Keep the time in timestamp format.
-s, --stdout Print JSON to stdout instead of sending to Elasticsearch directly.
-b, --nobulk Remove the ES bulk JSON header. Requires --stdout.
--humio HUMIO HUMIO First argument is the Humio URL, the second argument is the ingest token.
-c, --cython Use Cython execution by loading the local zeek2es.so file through an import.
Run python setup.py build_ext --inplace first to make your zeek2es.so file!
-w, --hashdates Use hashes instead of dates for the index name.
-z, --supresswarnings
Supress any type of warning. Die stoically and silently.
To delete indices:
curl -X DELETE http://localhost:9200/zeek*?pretty
To delete data streams:
curl -X DELETE http://localhost:9200/_data_stream/zeek*?pretty
To delete index templates:
curl -X DELETE http://localhost:9200/_index_template/zeek*?pretty
To delete the lifecycle policy:
curl -X DELETE http://localhost:9200/_ilm/policy/zeek-lifecycle-policy?pretty
You will need to add -k -u elastic_user:password if you are using Elastic v8+.
## आवश्यकताएँ <a name="requirements" />
- एक यूनिक्स-जैसा वातावरण (MacOS भी काम करता है!)
- Python
- [requests](https://docs.python-requests.org/en/latest/) Python लाइब्रेरी इंस्टॉल हो, जैसे कि `pip` के साथ।
## नोट्स <a name="notes" />
### Humio <a name="humio" />
अपने डेटा को Humio में आयात करने के लिए आपको `corelight-json` पार्सर के साथ एक रिपॉज़िटरी सेट अप करनी होगी। रिपॉज़िटरी के लिए इन्जेस्ट टोकन प्राप्त करें और आप अपने डेटा को इस तरह के कमांड से आयात कर सकते हैं:```
python3 zeek2es.py -s -b --humio http://localhost:8080 b005bf74-1ed3-4871-904f-9460a4687202 http.log
The URL इस प्रारूप में होना चाहिए: http://yourserver:8080, क्योंकि शेष पथ आपके लिए zeek2es.py स्क्रिप्ट द्वारा स्वचालित रूप से जोड़ा जाता है।
आप -d कमांड लाइन विकल्प के साथ बड़े लॉग के लिए इंडेक्स के बजाय डेटा स्ट्रीम का उपयोग कर सकते हैं। यह विकल्प zeek_ से शुरू होने वाले इंडेक्स टेम्पलेट बनाता है। यह zeek-lifecycle-policy नामक एक लाइफसाइकिल नीति भी बनाता है। यदि आप अपनी सभी डेटा स्ट्रीम, लाइफसाइकिल नीतियों और इंडेक्स टेम्पलेट्स को हटाना चाहते हैं, तो ये कमांड आपके लिए ऐसा कर देंगे:```
curl -X DELETE http://localhost:9200/_data_stream/zeek*?pretty
curl -X DELETE http://localhost:9200/_index_template/zeek*?pretty
curl -X DELETE http://localhost:9200/_ilm/policy/zeek-lifecycle-policy?pretty
### Helper Scripts <a name="helperscripts" />
ऐसी दो स्क्रिप्ट्स हैं जो आपके लॉग्स को डेटा स्ट्रीम्स बनाने में मदद करेंगी, जैसे `logs-zeek-conn`।
पहली स्क्रिप्ट [process_logs_as_datastream.sh](https://github.com/corelight/zeek2es/blob/master/process_logs_as_datastream.sh) है और लॉग्स और डायरेक्टरीज़ की सूची दिए जाने पर उन्हें इस रूप में आयात करेगी। दूसरी स्क्रिप्ट [process_log.sh](https://github.com/corelight/zeek2es/blob/master/process_log.sh) है, और इसका उपयोग लॉग्स को एक-एक करके आयात करने के लिए किया जा सकता है।
इस स्क्रिप्ट का उपयोग [fswatch](https://emcrisostomo.github.io/fswatch/) के साथ किसी डायरेक्टरी में बनाए गए लॉग्स की निगरानी के लिए भी किया जा सकता है। दोनों स्क्रिप्ट्स में उदाहरण कमांड लाइनें होती हैं यदि आप उन्हें बिना किसी पैरामीटर के चलाते हैं।```
$ ./process_logs_as_datastream.sh
Usage: ./process_logs_as_datastream.sh NJOBS "ADDITIONAL_ARGS_TO_ZEEK2ES" "LIST_OF_LOGS_DELIMITED_BY_SPACES" DIR1 DIR2 ...
Example:
time ./process_logs_as_datastream.sh 16 "" "amqp bgp conn dce_rpc dhcp dns dpd files ftp http ipsec irc kerberos modbus modbus_register_change mount mqtt mysql nfs notice ntlm ntp ospf portmap radius reporter rdp rfb rip ripng sip smb_cmd smb_files smb_mapping smtp snmp socks ssh ssl stun syslog tunnel vpn weird wireguard x509" /usr/local/var/logs
I apologize, but I don't see any content to translate in this chunk. The input after "INPUT:" appears to be empty.
Could you please provide the actual Markdown content for chunk 37 of 43? I'll be happy to translate it to Hindi (hi) following all the specified rules.``` $ ./process_log.sh Usage: ./process_log.sh LOGFILENAME "ADDITIONAL_ARGS_TO_ZEEK2ES"
Example: fswatch -m poll_monitor --event Created -r /data/logs/zeek | awk '/^./(conn|dns|http)...log.gz$/' | parallel -j 16 ./process_log.sh {} "" :::: -
आपको अपने वातावरण के अनुसार इन स्क्रिप्ट्स और कमांड लाइनों को संपादित करने की आवश्यकता होगी।
`lambda_filter_file_dir` में, जो डिफ़ॉल्ट रूप से आपकी होम डायरेक्टरी है, किसी भी फ़ाइल का नाम जो किसी लॉग के नाम जैसा है, जैसे `conn_filter.txt`, लैम्ब्डा
फ़िल्टर फ़ाइल के रूप में संबंधित लॉग इनपुट पर लागू किया जाएगा। यह आपको अपने सभी फ़िल्टर एक निर्देशिका में सेट करने और कई लॉग फ़ाइलों को
उस फ़िल्टर सेट के साथ एक कमांड में [process_logs_as_datastream.sh](https://github.com/corelight/zeek2es/blob/master/process_logs_as_datastream.sh) के साथ आयात करने की अनुमति देता है।
निम्नलिखित पंक्तियों को सभी Zeek डेटा को ElasticSearch से हटा देना चाहिए, चाहे आप इंडेक्स या
डेटा स्ट्रीम का उपयोग करें, या इन हेल्पर स्क्रिप्ट्स का:```
curl -X DELETE http://localhost:9200/zeek*?pretty
curl -X DELETE http://localhost:9200/_data_stream/zeek*?pretty
curl -X DELETE http://localhost:9200/_data_stream/logs-zeek*?pretty
curl -X DELETE http://localhost:9200/_index_template/zeek*?pretty
curl -X DELETE http://localhost:9200/_index_template/logs-zeek*?pretty
curl -X DELETE http://localhost:9200/_ilm/policy/zeek-lifecycle-policy?pretty
... या यदि Elastic v8+ का उपयोग कर रहे हैं ...``` curl -X DELETE -k -u elastic:password https://localhost:9200/zeek*?pretty curl -X DELETE -k -u elastic:password https://localhost:9200/_data_stream/zeek*?pretty curl -X DELETE -k -u elastic:password https://localhost:9200/_data_stream/logs-zeek*?pretty curl -X DELETE -k -u elastic:password https://localhost:9200/_index_template/zeek*?pretty curl -X DELETE -k -u elastic:password https://localhost:9200/_index_template/logs-zeek*?pretty curl -X DELETE -k -u elastic:password https://localhost:9200/_ilm/policy/zeek-lifecycle-policy?pretty
लेकिन v8+ में ऐसा करने में सक्षम होने के लिए आपको Elastic को कॉन्फ़िगर करना होगा जैसा
अनुभाग [Elastic v8.0+](#elastic80) में वर्णित है।
### Cython <a name="cython" />
यदि आप [Cython](https://cython.org/) आज़माना चाहते हैं, तो आपको `python setup.py build_ext --inplace` चलाना होगा
पहले अपनी संकलित फ़ाइल उत्पन्न करने के लिए। जब भी आप zeek2es अपडेट करें, आपको ऐसा करना होगा!