Skip to main content

Logging with Opensearch on Docker

In this guide you will learn how to quickstart with detailed logging using opensearch.

Setup Opensearch on Docker locally

Pull OpenSearch Images

OpenSearch

docker pull opensearchproject/opensearch:latest

OpenSearch Dashboard

docker pull opensearchproject/opensearch-dashboards:latest

Start Opensearch Containers

OpenSearch

docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e "plugins.security.disabled=true" opensearchproject/opensearch:latest 

OpenSearch Dashboard

docker run -it -d --network="host" -e "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true" opensearchproject/opensearch-dashboards:latest

Verify if the containers are up & running

Send a request to port 9200

curl http://127.0.0.1:9200

List Indices through curl

curl -X GET "http://127.0.0.1:9200/_cat/indices?v"

Create Indices through Curl

curl -X PUT "http://127.0.0.1:9200/your_index_name"

Delete Index

curl --location --request DELETE 'http://127.0.0.1:9200/index_name'

Fetch logs for an index_name

curl --location --request GET 'http://127.0.0.1:9200/ethereal/_search' \
--header 'Content-Type: application/json' \
--data '{
"query": {
"match_all": {}
},
"size": 10000
}'

Enable logging

Configure these variables in the .env.local file to ensure proper communication with OpenSearch and to enable client and server log aggregation

Enable Client Logging

Set VITE_FORCE_CLIENT_LOG_AGGREGATE to true to enable client log aggregation

VITE_FORCE_CLIENT_LOG_AGGREGATE=true

Enable Server Logging

Set DISABLE_SERVER_LOG to false to enable server log aggregation

DISABLE_SERVER_LOG=false