Compare commits
2 Commits
337fd19dc7
...
90a0f6514d
| Author | SHA1 | Date | |
|---|---|---|---|
| 90a0f6514d | |||
| 372376b445 |
82
ElasticSearch-Common-Commands.md
Normal file
82
ElasticSearch-Common-Commands.md
Normal file
@ -0,0 +1,82 @@
|
||||
# ElasticSearch Commands to get you into using it.
|
||||
|
||||
Personally, I run Elasticsearch, Kibana, Metricbeat, and Filebeat in a single docker-compose stack managed with Portainer. Kibana is useful for viewing data, although I don't like that it doesn't let you edit data. I connect TubeArchivist using the `elastic` password generated by the compose stack. I also want to use Elasticsearch for other purposes and avoid running a separate instance.
|
||||
|
||||
From kibana i just created an api key for ta_channels to update data within them. Here's a curl command to generate an api key without kibana below.
|
||||
|
||||
## Create API key scoped to specific indices (HTTP)
|
||||
```
|
||||
curl -s -u 'elastic:ELASTIC_PASS' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-X POST 'http://localhost:9200/_security/api_key' \
|
||||
-d '{
|
||||
"name": "ta_scoped_key",
|
||||
"expiration": "30d",
|
||||
"role_descriptors": {
|
||||
"ta_scoped_role": {
|
||||
"cluster": ["monitor"],
|
||||
"index": [
|
||||
{ "names": ["ta_channels_*"], "privileges": ["read","write"] },
|
||||
{ "names": ["ta_metadata"], "privileges": ["read","write","create_index"] }
|
||||
]
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### HTTPS (with CA)
|
||||
```
|
||||
curl -s --cacert /path/to/chain.pem -u 'elastic:ELASTIC_PASS' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-X POST 'https://localhost:9200/_security/api_key' \
|
||||
-d '{"name":"ta_scoped_key","expiration":"30d","role_descriptors":{"ta_scoped_role":{"cluster":["monitor"],"index":[{"names":["ta_channels_*"],"privileges":["read","write"]}]}}}'
|
||||
```
|
||||
|
||||
Save the JSON response (it contains id and api_key), then build the ApiKey header:
|
||||
|
||||
Looks like this:
|
||||
```
|
||||
{"id":"F0eWBJ0BLX_vEATxQJuu","name":"ta_scoped_key","expiration":1763932732593,"api_key":"39RandomLettersandNumbers","encoded":"60RandomNumbersandLettsasldkfjwithA=="}
|
||||
```
|
||||
Use the 'encoded' key and not the 'api_key'. Not sure why, but that's what I had to use to work.
|
||||
|
||||
## Test using the API key
|
||||
curl -s -H "Authorization: ApiKey $AUTH" http://localhost:9200/_security/_authenticate
|
||||
|
||||
|
||||
## Creating Another User
|
||||
```
|
||||
curl -u 'elastic:Yourhardrandompassword' \
|
||||
-X POST "http://localhost:9200/_security/user/sickprodigy" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"password":"PasswordforUser","roles":["my_readonly_role"],"full_name":"Sick Prodigy","email":"sick@sickgaming.net"}'
|
||||
```
|
||||
|
||||
## Creating another user with full Privs (SuperUser)
|
||||
I prefer to have a user with full privs other than elastic, although TubeArchivist apparently uses elastic(default superuser)
|
||||
```
|
||||
curl -u 'elastic:Yourhardrandompassword' -X POST "http://localhost:9200/_security/user/sickprodigy" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"password": "SomeHardPassword",
|
||||
"roles": ["superuser"],
|
||||
"full_name": "SickProdigy",
|
||||
"email": "sickprodigy@sickgaming.net"
|
||||
}'
|
||||
```
|
||||
|
||||
### Query certain channel within ta_channel:
|
||||
The channel ID can be found on TubeArchivist, got to channel and in URL "https://tubearchivist.rcs1.top/channel/UChOve2dsTRMrW8DslLKJ9eg" after channel/ is channel ID. You can test around with query and see what comes back, but this usually bring back the exact channel you want.
|
||||
```
|
||||
curl -X POST "http://es:9200/ta_channel/_search?pretty" \
|
||||
-H "Authorization: ApiKey "YourRandomAPIkey123455123123=="" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d'
|
||||
{
|
||||
"query": {
|
||||
"query_string": {
|
||||
"query": "Channel ID"
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
64
Example-channel-info-elasticsearch.json
Normal file
64
Example-channel-info-elasticsearch.json
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"_index" : "ta_channel",
|
||||
"_id" : "UC1ORA3oNGYuQ8yQHrC7MzBg",
|
||||
"_score" : 6.799427,
|
||||
"_source" : {
|
||||
"channel_name" : "syncbricks",
|
||||
"channel_thumb_url" : "https://yt3.googleusercontent.com/ytc/AIdro_k5ySAgLYNTLWCkt7ZNBCpQLgEdh8nd2HbVf93PIYm8qQ=s900-c-k-c0x00ffffff-no-rj",
|
||||
"channel_active" : true,
|
||||
"channel_description" : "syncbricks offers training, reviews, tutorials and guides on core IT, Application development, Application Maintenance, Data Centre , Cloud Services, Automation, IoT, Cyber security, Infrastructure Management, Business Intelligence, Business Process Management, Project Management, IT consulting, Open source, brands, products, servers, hosting, gadgets, service providers and much more.\nWe are focused on innovation and integration. \nOn timely basis we will be uploading Training Video, Tutorials, Speeches, Tech and Business Reviews, Product Reviews, Travel and More.",
|
||||
"channel_subscribed" : false,
|
||||
"channel_subs" : 35600,
|
||||
"channel_views" : 0,
|
||||
"channel_tabs" : [
|
||||
"videos",
|
||||
"streams",
|
||||
"shorts"
|
||||
],
|
||||
"channel_last_refresh" : 1746300537,
|
||||
"channel_banner_url" : "https://yt3.googleusercontent.com/oOzViYjjHZb1XKBhEhAkp36062e2NUJiS37InRd6JBhmXeba-n8QXl2YZSMB9HdUvT8_5_59=w2560-fcrop64=1,00005a57ffffa5a8-k-c0xffffffff-no-nd-rj",
|
||||
"channel_tvart_url" : "https://yt3.googleusercontent.com/oOzViYjjHZb1XKBhEhAkp36062e2NUJiS37InRd6JBhmXeba-n8QXl2YZSMB9HdUvT8_5_59=s0",
|
||||
"channel_id" : "UC1ORA3oNGYuQ8yQHrC7MzBg",
|
||||
"channel_tags" : [
|
||||
"tech tutorials",
|
||||
"self-hosted automation",
|
||||
"n8n",
|
||||
"docker",
|
||||
"proxmox",
|
||||
"home lab",
|
||||
"network security",
|
||||
"open source tools",
|
||||
"IT infrastructure",
|
||||
"AI automation",
|
||||
"sysadmin tips",
|
||||
"Linux",
|
||||
"server virtualization",
|
||||
"pfSense",
|
||||
"OPNSense",
|
||||
"SyncBricks",
|
||||
"automation tools",
|
||||
"Proxmox VE",
|
||||
"tech setup",
|
||||
"n8n",
|
||||
"firewall",
|
||||
"tech tutorials",
|
||||
"n8n",
|
||||
"docker",
|
||||
"home lab",
|
||||
"IT infrastructure",
|
||||
"AI automation",
|
||||
"server virtualization",
|
||||
"pfSense",
|
||||
"SyncBricks",
|
||||
"Amjid Ali",
|
||||
"Proxmox VE",
|
||||
"docker compose",
|
||||
"n8n",
|
||||
"tutorial",
|
||||
"linux",
|
||||
"open source",
|
||||
"ngw",
|
||||
"firewall"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user