Skip to content

Commit 1a0525d

Browse files
authored
Merge pull request #11 from tainguyenbp/feat/learning-python-lang02
Feat/learning python lang02
2 parents 45a505c + 56e3a83 commit 1a0525d

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
```

0 commit comments

Comments
 (0)