Viewing OpenSearch cluster logs
Managed Service for OpenSearch allows you to get a cluster log snippet for the selected period and view logs in real time.
Getting a cluster log
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.ListLogs method and make a request, e.g., via cURL
:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-opensearch/v1/clusters/<cluster_ID>:logs' \ --url-query serviceType=<host_group_type> \ --url-query columnFilter=<column_list> \ --url-query fromTime=<time_range_left_boundary> \ --url-query toTime=<time_range_right_boundary>
Where:
-
serviceType
: Type of hosts you need the records for,OPENSEARCH
orDASHBOARDS
. -
columnFilter
: List of data columns: The list of data columns depends on the selected type of hosts, i.e.serviceType
:-
For
OpenSearch
hosts:component
: Cluster component the log entry refers to.hostname
: Host name.level
: Logging level.message
: Message output by the service.
-
For
Dashboards
hosts:hostname
: Host name.message
: Message output by the service.
-
-
fromTime
: Left boundary of a time range in RFC-3339 format, Example:2024-09-18T15:04:05Z
. -
toTime
: Right boundary of a time range, the format is the same as forfromTime
.
You can get the cluster ID with a list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.ListLogs call and make a request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/opensearch/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "service_type": "<host_group_type>", "column_filter": [ "<column_1>", "<column_2>", ..., "<column_N>" ], "from_time": "<time_range_left_boundary>", "to_time": "<time_range_right_boundary>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.opensearch.v1.ClusterService.ListLogs
Where:
-
service_type
: Type of hosts you need the records for,OPENSEARCH
orDASHBOARDS
. -
column_filter
: List of data columns: The list of data columns depends on the selected type of hosts, i.e.service_type
:-
For
OpenSearch
hosts:component
: Cluster component the log entry refers to.hostname
: Host name.level
: Logging level.message
: Message output by the service.
-
For
Dashboards
hosts:hostname
: Host name.message
: Message output by the service.
-
-
from_time
: Left boundary of a time range in RFC-3339 format, e.g.,2024-09-18T15:04:05Z
. -
to_time
: Right boundary of a time range, the format is the same as forfrom_time
.
You can get the cluster ID with a list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
Getting a cluster log stream
This method allows you to get cluster logs in real time.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.StreamLogs method and make a request, e.g., via cURL
:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-opensearch/v1/clusters/<cluster_ID>:stream_logs' \ --url-query serviceType=<host_group_type> \ --url-query columnFilter=<column_list>
Where:
-
serviceType
: Type of hosts you need the records for,OPENSEARCH
orDASHBOARDS
. -
columnFilter
: List of data columns: The list of data columns depends on the selected type of hosts, i.e.serviceType
:-
For
OpenSearch
hosts:component
: Cluster component the log entry refers to.hostname
: Host name.level
: Logging level.message
: Message output by the service.
-
For
Dashboards
hosts:hostname
: Host name.message
: Message output by the service.
-
You can get the cluster ID with a list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
Once you run the command, it does not terminate. The command output displays new logs in real time.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.StreamLogs call and make a request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/opensearch/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "service_type": "<host_group_type>", "column_filter": [ "<column_1>", "<column_2>", ..., "<column_N>" ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.opensearch.v1.ClusterService.StreamLogs
Where:
-
service_type
: Type of hosts you need the records for,OPENSEARCH
orDASHBOARDS
. -
column_filter
: List of data columns: The list of data columns depends on the selected type of hosts, i.e.service_type
:-
For
OpenSearch
hosts:component
: Cluster component the log entry refers to.hostname
: Host name.level
: Logging level.message
: Message output by the service.
-
For
Dashboards
hosts:hostname
: Host name.message
: Message output by the service.
-
You can get the cluster ID with a list of clusters in the folder.
-
-
View the server response to make sure the request was successful.
Once you run the command, it does not terminate. The command output displays new logs in real time.