File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed
bash-basic/validate-logstash
python-basic/elasticsearch-get-all-role Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change
1
+ ` ` `
2
+ #! /bin/bash
3
+
4
+ NAME_LOGSTASH=' logstash.conf'
5
+
6
+ PATH_LOGSTASH=' /etc/logstash/conf.d'
7
+
8
+ echo " The check command verifies the syntax of Logstash configuration files:"
9
+ mustache check " ${PATH_LOGSTASH} /${NAME_LOGSTASH} "
10
+
11
+ echo " The lint command checks for problems in Logstash configuration files: "
12
+ mustache lint --auto-fix-id " ${PATH_LOGSTASH} /${NAME_LOGSTASH} "
13
+
14
+ echo " The format command, mustache returns the provided configuration files in a standardized format: "
15
+ # mustache format --write-to-source "${PATH_LOGSTASH}/${NAME_LOGSTASH}"
16
+ ` ` `
17
+
18
+ ` ` `
19
+ /usr/share/logstash/bin/logstash --config.test_and_exit -f /etc/logstash/conf.d/logstash.conf
20
+ ` ` `
Original file line number Diff line number Diff line change
1
+ from elasticsearch import Elasticsearch
2
+ import json
3
+
4
+ # Configure Elasticsearch client
5
+ es = Elasticsearch (
6
+ ["https://localhost:9200" ],
7
+ http_auth = ("username" , "password" ),
8
+ scheme = "https" ,
9
+ port = 9200 ,
10
+ )
11
+
12
+ # Fetch all roles
13
+ roles = es .security .get_role ()
14
+
15
+ # Save roles to a JSON file
16
+ with open ("roles_export.json" , "w" ) as f :
17
+ json .dump (roles , f , indent = 4 )
18
+
19
+ print ("Roles have been exported to roles_export.json" )
Original file line number Diff line number Diff line change
1
+ ### setup lib elasticsearch
2
+ ```
3
+ pip install elasticsearch
4
+ ```
5
+ ```
6
+ from elasticsearch import Elasticsearch
7
+ import json
8
+
9
+ # Configure Elasticsearch client
10
+ es = Elasticsearch(
11
+ ["https://localhost:9200"],
12
+ http_auth=("username", "password"),
13
+ scheme="https",
14
+ port=9200,
15
+ )
16
+
17
+ # Fetch all roles
18
+ roles = es.security.get_role()
19
+
20
+ # Save roles to a JSON file
21
+ with open("roles_export.json", "w") as f:
22
+ json.dump(roles, f, indent=4)
23
+
24
+ print("Roles have been exported to roles_export.json")
25
+ ```
You can’t perform that action at this time.
0 commit comments