Viewing OpenSearch cluster logs
Managed Service for OpenSearch allows you to get a cluster log snippet for the selected time period and view logs in real time.
Getting a cluster log
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.ListLogs method, e.g., via the following cURL
request: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_start> \ --url-query toTime=<time_range_end>Where:
-
serviceType: Type of hosts you need the records for,OPENSEARCHorDASHBOARDS. -
columnFilter: List of output data columns: The list of data columns depends on the selected type of hosts,serviceType:-
For
OpenSearchhosts:component: Cluster component the log entry refers to.hostname: Host name.level: Logging level.message: Message output by the service.
-
For
Dashboardshosts:hostname: Host name.message: Message output by the service.
-
-
fromTime: Start of the time range in RFC-3339 format, e.g.,2024-09-18T15:04:05Z. -
toTime: End of the time range in the same format asfromTime.
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService.ListLogs method, e.g., via the following gRPCurl
request: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_start>", "to_time": "<time_range_end>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.opensearch.v1.ClusterService.ListLogsWhere:
-
service_type: Type of hosts you need the records for,OPENSEARCHorDASHBOARDS. -
column_filter: List of output data columns: The list of data columns depends on the selected type of hosts,service_type:-
For
OpenSearchhosts:component: Cluster component the log entry refers to.hostname: Host name.level: Logging level.message: Message output by the service.
-
For
Dashboardshosts:hostname: Host name.message: Message output by the service.
-
-
from_time: Start of the time range in RFC-3339 format, e.g.,2024-09-18T15:04:05Z. -
to_time: End of the time range in the same format asfrom_time.
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your 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 in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.StreamLogs method, e.g., via the following cURL
request: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,OPENSEARCHorDASHBOARDS. -
columnFilter: List of output data columns: The list of data columns depends on the selected type of hosts,serviceType:-
For
OpenSearchhosts:component: Cluster component the log entry refers to.hostname: Host name.level: Logging level.message: Message output by the service.
-
For
Dashboardshosts:hostname: Host name.message: Message output by the service.
-
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
Once you launch the command, it will continue running, displaying new logs in its output in real time.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the ClusterService.StreamLogs method, e.g., via the following gRPCurl
request: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.StreamLogsWhere:
-
service_type: Type of hosts you need the records for,OPENSEARCHorDASHBOARDS. -
column_filter: List of output data columns: The list of data columns depends on the selected type of hosts,service_type:-
For
OpenSearchhosts:component: Cluster component the log entry refers to.hostname: Host name.level: Logging level.message: Message output by the service.
-
For
Dashboardshosts:hostname: Host name.message: Message output by the service.
-
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
Once you launch the command, it will continue running, displaying new logs in its output in real time.