Elastic Stack 8.0 終于于最近發(fā)布了。在我之前的文章 “Elastic Stack 8.0 安裝 - 保護(hù)你的 Elastic Stack 現(xiàn)在比以往任何時(shí)候都簡單” 我已經(jīng)詳細(xì)地描述了如何在本地部署 Elasticsearch 及 Kibana。設(shè)置 Elasticsearch 的最簡單方法是使用 Elastic Cloud 上的 Elasticsearch Service 創(chuàng)建托管部署。?如果你更喜歡管理自己的測試環(huán)境,可以使用 Docker 安裝和運(yùn)行 Elasticsearch。在今天的演示中,我將使用 Docker 來安裝 Elastic Stack 8.0,并對它的使用進(jìn)行展示。
使用 Docker 安裝 Elastic Stack 8.x 并開始使用
運(yùn)行 Elasticsearch
我們需要在自己的電腦上安裝好 Docker Desktop。接著我們運(yùn)行如下的命令:
docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.3.3
docker run --name es-node01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.3.3
?當(dāng)我們第一次啟動(dòng) Elasticsearch 時(shí),以下安全配置會(huì)自動(dòng)發(fā)生:
- 為傳輸層和 HTTP 層生成證書和密鑰。
- 傳輸層安全 (TLS) 配置設(shè)置寫入 elasticsearch.yml。
- 為彈性用戶生成密碼。
- 為 Kibana 生成一個(gè)注冊令牌。
--------------------------------------------------------------------------------
-> Elasticsearch security features have been automatically configured!
-> Authentication is enabled and cluster connections are encrypted.
-> Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
21=0VbI9nz+kjR69l1WT
-> HTTP CA certificate SHA-256 fingerprint:
05661cff7bef5f59ae84442e25d9f1821662f82ed958b1b1da6147950943ecc3
-> Configure Kibana to use this cluster:
* Run Kibana and click the configuration link in the terminal when Kibana starts.
* Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxNzIuMjQuMC4yOjkyMDAiXSwiZmdyIjoiMDU2NjFjZmY3YmVmNWY1OWFlODQ0NDJlMjVkOWYxODIxNjYyZjgyZWQ5NThiMWIxZGE2MTQ3OTUwOTQzZWNjMyIsImtleSI6Ilc5TWktMzRCTVZaSFJZRHZXc3piOmk5b1RXWkdFUV95VVoxeUFtU0N0bFEifQ==
-> Configure other nodes to join this cluster:
* Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjAuMCIsImFkciI6WyIxNzIuMjQuMC4yOjkyMDAiXSwiZmdyIjoiMDU2NjFjZmY3YmVmNWY1OWFlODQ0NDJlMjVkOWYxODIxNjYyZjgyZWQ5NThiMWIxZGE2MTQ3OTUwOTQzZWNjMyIsImtleSI6IlhkTWktMzRCTVZaSFJZRHZXc3pvOnRoQWxhcmxYU3Myb0ZHX2g5czA1Z1EifQ==
If you're running in Docker, copy the enrollment token and run:
`docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.0.0`
--------------------------------------------------------------------------------
你可能需要向上翻滾才能在 terminal 中看到 password 及 enrollment token(注冊令牌)。
復(fù)制生成的密碼和注冊令牌并將其保存在安全位置。 這些值僅在你第一次啟動(dòng) Elasticsearch 時(shí)顯示。 你將使用這些將 Kibana 注冊到你的 Elasticsearch 集群并登錄。
注意:如果需要重置 elastic 用戶或其他內(nèi)置用戶的密碼,請運(yùn)行 elasticsearch-reset-password 工具。 要為 Kibana 或 Elasticsearch 節(jié)點(diǎn)生成新的注冊令牌,請運(yùn)行 elasticsearch-create-enrollment-token 工具。 這些工具在 Elasticsearch bin 目錄中可以找到。
如果我們需要訪問 Elasticsearch,請參閱我之前的文章 “Elastic Stack 8.0 安裝 - 保護(hù)你的 Elastic Stack 現(xiàn)在比以往任何時(shí)候都簡單”。
如果你想修改超級用戶的密碼,你可以通過如下的命令來進(jìn)行修改:
docker exec -it es-node01 /usr/share/elasticsearch/bin/elasticsearch-rest-password -u elastic
請注意上面的 es-node01 是上面的 docker 的名稱。
安裝及運(yùn)行 Kibana
要使用直觀的 UI 分析、可視化和管理 Elasticsearch 數(shù)據(jù),請安裝 Kibana。
在新的終端會(huì)話中,運(yùn)行:
docker pull docker.elastic.co/kibana/kibana:8.3.3
docker run --name kib-01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.3.3
請注意在上面,我們使用了 --net 來定義 network。請使用和上面在 Elasticsearch 安裝中一樣的 network。
當(dāng)我們上面的命令成功運(yùn)行后,我們可以看到如下的輸出:
在上面,它讓我到地址?http://0.0.0.0:5601/?code=915472 去配置 Kibana。在瀏覽器中打開上面的地址:
我們把在 Elasticsearch 啟動(dòng)時(shí)的 Kibana enrollment token 拷貝進(jìn)上面的輸入框,并點(diǎn)擊 Configure Elastic:
等配置完畢后,我們把之前生成的 elastic 超級用戶的密碼輸入進(jìn)如下的登錄頁面:
點(diǎn)擊 Log in,這樣我們就進(jìn)行入到 Kibana 的界面:
在上面,默認(rèn)的情況是添加 integrations。這個(gè)是用來攝入數(shù)據(jù)到 Elasticsearch 中的。在今天的展示中,我就先不進(jìn)行展示了。我們點(diǎn)擊 Explore on my own:
這樣我們就成功地進(jìn)入到 Kibana 界面了。
至此,我們已經(jīng)成功地通過 docker 啟動(dòng)了 Elasticsearch 及 Kibana。我們可以通過如下的命令來進(jìn)行查看:
docker ps
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7ad78365a6a4 docker.elastic.co/kibana/kibana:8.0.0 "/bin/tini -- /usr/l…" 13 minutes ago Up 13 minutes 0.0.0.0:5601->5601/tcp kib-01
438986615af6 docker.elastic.co/elasticsearch/elasticsearch:8.0.0 "/bin/tini -- /usr/l…" 24 minutes ago Up 24 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp es-node01
我們可以看到名叫??kib-01 及?es-node01 的兩個(gè)容器已經(jīng)在成功運(yùn)行。
如果你想了解如何使用 docker-compose 來一鍵啟動(dòng) Elastic Stack 8.x, 請閱讀另外一篇文章 “Elasticsearch:使用 Docker compose 來一鍵部署 Elastic Stack 8.x”。
發(fā)送請求到 Elasticsearch?
你使用 REST API 向 Elasticsearch 發(fā)送數(shù)據(jù)和其他請求。 這使你可以使用任何發(fā)送 HTTP 請求的客戶端(例如 curl)與 Elasticsearch 交互。 你還可以使用 Kibana 的控制臺向 Elasticsearch 發(fā)送請求。
比如,我們可以嘗試如下的命令來查看請求的結(jié)果:
也許很多開發(fā)者想知道如何使用 curl 來得到請求的數(shù)據(jù)。我們不能像之前的這種方法來獲取數(shù)據(jù):
curl -X GET http://localhost:9200/
這其中的原因是 Elasticsearch 由于啟動(dòng)了 https 連接,我們必須使用證書來訪問 Elasticsearch。Elasticsearch 的訪問地址為 https://localhost:9200,而不是 http://localhost:9200。那么我們該如何獲取這個(gè)證書呢?
我們可以通過如下的命令來獲取 Elasticsearch 容器的名稱:
docker ps
我們可以通過如下的命令來登錄容器:
docker exec -it es-node01 /bin/bash
我們可以通過如下的方式來找到 Elasticsearch 在啟動(dòng)時(shí)生成的證書位置:
在上面,我們可以看到 Elasticsearch 所生成的證書。這個(gè)證書的名稱叫做 http_ca.crt。我們可以通過如下的方式來把這個(gè)證書拷貝出來:
docker cp es-node01:/usr/share/elasticsearch/config/certs/http_ca.crt .
$ pwd
/Users/liuxg/data/elastic8
$ docker cp es-node01:/usr/share/elasticsearch/config/certs/http_ca.crt .
$ ls
http_ca.crt
有了這個(gè)證書,我們可以使用如下的命令通過 curl 來訪問 Elasticsearch:
curl -X GET --cacert ./http_ca.crt -u elastic:21=0VbI9nz+kjR69l1WT https://localhost:9200/
在上面的命令中,請記住需要替換上面的 -u 中的用戶名及密碼。另外注意的是我們訪問的地址是?https://localhost:9200/?而不是以前的 http://localhost:9200。
上面的命令執(zhí)行的結(jié)果為:
$ curl -X GET --cacert ./http_ca.crt -u elastic:21=0VbI9nz+kjR69l1WT https://localhost:9200/
{
"name" : "438986615af6",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "STCnb4M6SMmvzEmFf6bwmw",
"version" : {
"number" : "8.0.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "1b6a7ece17463df5ff54a3e1302d825889aa1161",
"build_date" : "2022-02-03T16:47:57.507843096Z",
"build_snapshot" : false,
"lucene_version" : "9.0.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
添加數(shù)據(jù)
你將數(shù)據(jù)作為稱為文檔的 JSON 對象添加到 Elasticsearch。 Elasticsearch 將這些文檔存儲在可搜索的索引中。
對于時(shí)間序列數(shù)據(jù),例如日志和指標(biāo),你通常將文檔添加到由多個(gè)自動(dòng)生成的支持索引組成的數(shù)據(jù)流中。
數(shù)據(jù)流需要與其名稱匹配的索引模板。 Elasticsearch 使用這個(gè)模板來配置流的后備索引。 發(fā)送到數(shù)據(jù)流的文檔必須具有 @timestamp 字段。
添加單個(gè)文檔
提交以下索引請求以將單個(gè)日志條目添加到 logs-my_app-default 數(shù)據(jù)流。 由于 logs-my_app-default 不存在,請求會(huì)使用內(nèi)置的 logs-*-* 索引模板自動(dòng)創(chuàng)建它。
POST logs-my_app-default/_doc
{
"@timestamp": "2099-05-06T16:21:15.000Z",
"event": {
"original": "192.0.2.42 - - [06/May/2099:16:21:15 +0000] \"GET /images/bg.jpg HTTP/1.0\" 200 24736"
}
}
響應(yīng)包括 Elasticsearch 為文檔生成的元數(shù)據(jù):
- 包含文檔的支持 _index。 Elasticsearch 會(huì)自動(dòng)生成支持索引的名稱。
- 索引中文檔的唯一 _id。
添加多個(gè)文檔
使用 _bulk 端點(diǎn)在一個(gè)請求中添加多個(gè)文檔。 批量數(shù)據(jù)必須是換行符分隔的 JSON (NDJSON)。 每行必須以換行符 (\n) 結(jié)尾,包括最后一行。
PUT logs-my_app-default/_bulk
{ "create": { } }
{ "@timestamp": "2099-05-07T16:24:32.000Z", "event": { "original": "192.0.2.242 - - [07/May/2020:16:24:32 -0500] \"GET /images/hm_nbg.jpg HTTP/1.0\" 304 0" } }
{ "create": { } }
{ "@timestamp": "2099-05-08T16:25:42.000Z", "event": { "original": "192.0.2.255 - - [08/May/2099:16:25:42 +0000] \"GET /favicon.ico HTTP/1.0\" 200 3638" } }
如果這個(gè)時(shí)候我們使用如下的命令來查看當(dāng)前的索引:
GET _cat/indices
我們會(huì)發(fā)現(xiàn):
yellow open .ds-logs-my_app-default-2022.02.15-000001 a4I6Rzj_S6yPC0Dww6OzTg 1 1 3 0 8.3kb 8.3kb
我們可以看到?jīng)]有我們之前的那種我們想要的?logs-my_app-default 索引名,這是因?yàn)槲覀兊乃饕ヅ鋬?nèi)置的索引模板 logs-*-*:
有關(guān)索引模板的內(nèi)容,請參閱我之前的另外一篇文章 “Elastic:Data stream 在索引生命周期管理中的應(yīng)用”。 有關(guān) data stream 的命令請閱讀文章 “Elastic data stream 命名方案介紹”
搜索數(shù)據(jù)
索引文檔可用于近乎實(shí)時(shí)的搜索。 以下搜索匹配 logs-my_app-default 中的所有日志條目,并按 @timestamp 降序?qū)λ鼈冞M(jìn)行排序。
GET logs-my_app-default/_search
{
"query": {
"match_all": { }
},
"sort": [
{
"@timestamp": "desc"
}
]
}
默認(rèn)情況下,響應(yīng)的 hits 部分最多包含與搜索匹配的前 10 個(gè)文檔。 每個(gè)命中的 _source 包含索引期間提交的原始 JSON 對象。
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : null,
"hits" : [
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "ctNa-34BMVZHRYDvfszg",
"_score" : null,
"_source" : {
"@timestamp" : "2099-05-08T16:25:42.000Z",
"event" : {
"original" : """192.0.2.255 - - [08/May/2099:16:25:42 +0000] "GET /favicon.ico HTTP/1.0" 200 3638"""
}
},
"sort" : [
4081940742000
]
},
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "cdNa-34BMVZHRYDvfszg",
"_score" : null,
"_source" : {
"@timestamp" : "2099-05-07T16:24:32.000Z",
"event" : {
"original" : """192.0.2.242 - - [07/May/2020:16:24:32 -0500] "GET /images/hm_nbg.jpg HTTP/1.0" 304 0"""
}
},
"sort" : [
4081854272000
]
},
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "bdNY-34BMVZHRYDv98zk",
"_score" : null,
"_source" : {
"@timestamp" : "2099-05-06T16:21:15.000Z",
"event" : {
"original" : """192.0.2.42 - - [06/May/2099:16:21:15 +0000] "GET /images/bg.jpg HTTP/1.0" 200 24736"""
}
},
"sort" : [
4081767675000
]
}
]
}
}
獲得特定的字段
對于大型文檔,解析整個(gè) _source 很麻煩。 要將其從響應(yīng)中排除,請將 _source 參數(shù)設(shè)置為 false。 相反,請使用 fields 參數(shù)來檢索你想要的字段。
GET logs-my_app-default/_search
{
"query": {
"match_all": { }
},
"fields": [
"@timestamp"
],
"_source": false,
"sort": [
{
"@timestamp": "desc"
}
]
}
響應(yīng)包含每個(gè)命中的字段值作為數(shù)組。
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : null,
"hits" : [
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "ctNa-34BMVZHRYDvfszg",
"_score" : null,
"fields" : {
"@timestamp" : [
"2099-05-08T16:25:42.000Z"
]
},
"sort" : [
4081940742000
]
},
...
搜索 date range
要在特定時(shí)間或 IP 范圍內(nèi)進(jìn)行搜索,請使用范圍查詢。
GET logs-my_app-default/_search
{
"query": {
"range": {
"@timestamp": {
"gte": "2099-05-05",
"lt": "2099-05-08"
}
}
},
"fields": [
"@timestamp"
],
"_source": false,
"sort": [
{
"@timestamp": "desc"
}
]
}
上面的命令執(zhí)行的結(jié)果為:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : null,
"hits" : [
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "cdNa-34BMVZHRYDvfszg",
"_score" : null,
"fields" : {
"@timestamp" : [
"2099-05-07T16:24:32.000Z"
]
},
"sort" : [
4081854272000
]
},
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "bdNY-34BMVZHRYDv98zk",
"_score" : null,
"fields" : {
"@timestamp" : [
"2099-05-06T16:21:15.000Z"
]
},
"sort" : [
4081767675000
]
}
]
}
}
你可以使用日期數(shù)學(xué)來定義相對時(shí)間范圍。 以下查詢搜索過去一天的數(shù)據(jù),這些數(shù)據(jù)不會(huì)匹配 logs-my_app-default 中的任何日志條目。
GET logs-my_app-default/_search
{
"query": {
"range": {
"@timestamp": {
"gte": "now-1d/d",
"lt": "now/d"
}
}
},
"fields": [
"@timestamp"
],
"_source": false,
"sort": [
{
"@timestamp": "desc"
}
]
}
從非結(jié)構(gòu)化內(nèi)容中提取字段
你可以在搜索期間從非結(jié)構(gòu)化內(nèi)容(例如日志消息)中提取運(yùn)行時(shí)字段。
使用以下搜索從 event.original 中提取 source.ip 運(yùn)行時(shí)字段。 要將其包含在響應(yīng)中,請將 source.ip 添加到 fields 參數(shù)。
GET logs-my_app-default/_search
{
"runtime_mappings": {
"source.ip": {
"type": "ip",
"script": """
String sourceip=grok('%{IPORHOST:sourceip} .*').extract(doc[ "event.original" ].value)?.sourceip;
if (sourceip != null) emit(sourceip);
"""
}
},
"query": {
"range": {
"@timestamp": {
"gte": "2099-05-05",
"lt": "2099-05-08"
}
}
},
"fields": [
"@timestamp",
"source.ip"
],
"_source": false,
"sort": [
{
"@timestamp": "desc"
}
]
}
上面命令運(yùn)行的結(jié)果為:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : null,
"hits" : [
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "cdNa-34BMVZHRYDvfszg",
"_score" : null,
"fields" : {
"@timestamp" : [
"2099-05-07T16:24:32.000Z"
],
"source.ip" : [
"192.0.2.242"
]
},
"sort" : [
4081854272000
]
},
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "bdNY-34BMVZHRYDv98zk",
"_score" : null,
"fields" : {
"@timestamp" : [
"2099-05-06T16:21:15.000Z"
],
"source.ip" : [
"192.0.2.42"
]
},
"sort" : [
4081767675000
]
}
]
}
}
在上面的命令中,它是用來 runtime fields 來提前我們需要的字段。有關(guān) runtime fields 的更多知識請閱讀文章 “Elastic:開發(fā)者上手指南” 里的 runtime fields 文章。
Combine queries
你可以使用 bool 查詢來組合多個(gè)查詢。 以下搜索結(jié)合了兩個(gè)范圍查詢:一個(gè)在 @timestamp 上,一個(gè)在 source.ip 運(yùn)行時(shí)字段上。
GET logs-my_app-default/_search
{
"runtime_mappings": {
"source.ip": {
"type": "ip",
"script": """
String sourceip=grok('%{IPORHOST:sourceip} .*').extract(doc[ "event.original" ].value)?.sourceip;
if (sourceip != null) emit(sourceip);
"""
}
},
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "2099-05-05",
"lt": "2099-05-08"
}
}
},
{
"range": {
"source.ip": {
"gte": "192.0.2.0",
"lte": "192.0.2.240"
}
}
}
]
}
},
"fields": [
"@timestamp",
"source.ip"
],
"_source": false,
"sort": [
{
"@timestamp": "desc"
}
]
}
上面的命令執(zhí)行的結(jié)果為:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : null,
"hits" : [
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "bdNY-34BMVZHRYDv98zk",
"_score" : null,
"fields" : {
"@timestamp" : [
"2099-05-06T16:21:15.000Z"
],
"source.ip" : [
"192.0.2.42"
]
},
"sort" : [
4081767675000
]
}
]
}
}
聚合數(shù)據(jù)
使用聚合將數(shù)據(jù)匯總為指標(biāo)、統(tǒng)計(jì)數(shù)據(jù)或其他分析。
以下搜索使用聚合來使用 http.response.body.bytes 運(yùn)行時(shí)字段計(jì)算 average_response_size。 聚合僅在與查詢匹配的文檔上運(yùn)行。
GET logs-my_app-default/_search
{
"runtime_mappings": {
"http.response.body.bytes": {
"type": "long",
"script": """
String bytes=grok('%{COMMONAPACHELOG}').extract(doc[ "event.original" ].value)?.bytes;
if (bytes != null) emit(Integer.parseInt(bytes));
"""
}
},
"aggs": {
"average_response_size":{
"avg": {
"field": "http.response.body.bytes"
}
}
},
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "2099-05-05",
"lt": "2099-05-08"
}
}
}
]
}
},
"fields": [
"@timestamp",
"http.response.body.bytes"
],
"_source": false,
"sort": [
{
"@timestamp": "desc"
}
]
}
上面的命令運(yùn)行的結(jié)果為:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : null,
"hits" : [
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "cdNa-34BMVZHRYDvfszg",
"_score" : null,
"fields" : {
"@timestamp" : [
"2099-05-07T16:24:32.000Z"
],
"http.response.body.bytes" : [
0
]
},
"sort" : [
4081854272000
]
},
{
"_index" : ".ds-logs-my_app-default-2022.02.15-000001",
"_id" : "bdNY-34BMVZHRYDv98zk",
"_score" : null,
"fields" : {
"@timestamp" : [
"2099-05-06T16:21:15.000Z"
],
"http.response.body.bytes" : [
24736
]
},
"sort" : [
4081767675000
]
}
]
},
"aggregations" : {
"average_response_size" : {
"value" : 12368.0
}
}
}
了解更多的搜索選項(xiàng)
要繼續(xù)探索,請將更多數(shù)據(jù)索引到你的數(shù)據(jù)流并查看常用搜索選項(xiàng)。
清理
當(dāng)我們已經(jīng)完成了我們的練習(xí)后,我們可以使用如下的命令來進(jìn)行清理:
DELETE _data_stream/logs-my_app-default
上述命令將刪除你的測試 data stream 及相關(guān)的支撐索引。
當(dāng)然我們甚至可以使用如下的命令來徹底地刪除你的測試環(huán)境以節(jié)省存儲空間:文章來源:http://www.zghlxwxcb.cn/news/detail-594482.html
docker stop es-node01
docker stop kib-01
上述兩個(gè)命令將停止 Elasticsearch 及 Kibana 容器。我們可以使用如下的命令來徹底刪除容器及網(wǎng)絡(luò):文章來源地址http://www.zghlxwxcb.cn/news/detail-594482.html
docker network rm elastic
docker rm es-node01
docker rm kib-01
到了這里,關(guān)于Elastic:使用 Docker 安裝 Elastic Stack 8.x 并開始使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!