Transferring Apache Hive™ Metastore cluster logs to Yandex Cloud Logging
You can set up regular collection of Apache Hive™ Metastore cluster performance logs. Logs will be delivered to a log group in Yandex Cloud Logging. You can choose between these two types of log groups:
- Default log group of the cluster folder.
- Custom log group.
Getting started
- Create a service account named
metastore-logging-sa. - Assign the
managed-metastore.integrationProviderrole to the service account. - Set up a NAT gateway in the subnet the cluster will connect to. This will enable the cluster to work with Yandex Cloud services.
- Configure the security group.
Transferring data to the default log group
-
Create a Apache Hive™ Metastore cluster:
Management consoleCLIREST APIgRPC API-
In the management console
, select the folder you need. -
Select Yandex MetaData Hub.
-
In the left-hand panel, select
Metastore. -
Click Create cluster.
-
Specify
metastore-clusteras the cluster name. -
In the Service account field, select
metastore-logging-sa. -
Under Network settings, select the network and subnet with a NAT gateway configured. Specify the security group you configured.
-
Under Logging:
-
Enable Write logs.
-
To write logs to the default log group, select Folder in the Destination field.
-
Specify the folder whose log group you want to use.
-
Select the minimum logging level.
The execution log will contain logs of this level or higher. The available levels are
TRACE,DEBUG,INFO,WARN,ERROR, andFATAL. The default isINFO.
-
-
Click Create.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idparameter.Run this command:
yc managed-metastore cluster create \ --name metastore-cluster \ --service-account-id <service_account_ID> \ --version <Apache Hive™ Metastore_version> \ --subnet-ids <subnet_IDs> \ --security-group-ids <security_group_IDs> \ --resource-preset-id <ID_of_computing_resources> \ --log-enabled \ --log-folder-id <folder_ID> \ --log-min-level <logging_level>Where:
--service-account-id: ID of themetastore-logging-saservice account you created earlier.--subnet-ids: ID of the subnet where you set up the NAT gateway.--security-group-ids: ID of the security group you configured earlier.--log-folder-id: Specify the ID of the folder whose log group you want to use.--log-min-level: Logging level. The execution log will contain logs of this level or higher. The available levels areTRACE,DEBUG,INFO,WARN,ERROR, andFATAL. The default isINFO.
-
Get an IAM token for API authentication and save it as an environment variable:
export IAM_TOKEN="<IAM_token>" -
Create a file named
body.jsonand paste the following code into it:{ "folderId": "<folder_ID>", "name": "metastore-cluster", "version": "<Apache Hive™ Metastore_version>", "configSpec": { "resources": { "resourcePresetId": "<resource_configuration_ID>" } }, "serviceAccountId": "<service_account_ID>", "logging": { "enabled": true, "folderId": "<folder_ID>", "minLevel": "<logging_level>" }, "network": { "subnetIds": [ "<list_of_subnet_IDs>" ], "securityGroupIds": [ "<list_of_security_group_IDs>" ] }, }Where:
serviceAccountId: ID of themetastore-logging-saservice account you created earlier.logging.folderId: Specify the ID of the folder whose log group you want to use.logging.minLevel: Logging level. The execution log will contain logs of this level or higher. The available levels areTRACE,DEBUG,INFO,WARN,ERROR, andFATAL. The default isINFO.network.subnetIds: ID of the subnet where you set up the NAT gateway.network.securityGroupIds: ID of the security group you configured earlier.
-
Use the Cluster.Create method and send the following request, e.g., via cURL
:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://metastore.api.cloud.yandex.net/managed-metastore/v1/clusters' \ --data '@body.json' -
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and save it as 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 the repository contents are stored in the
~/cloudapi/directory. -
Create a file named
body.jsonand paste the following code into it:{ "folder_id": "<folder_ID>", "name": "metastore-cluster", "version": "<Apache Hive™ Metastore_version>", "config_spec": { "resources": { "resource_preset_id": "<resource_configuration_ID>" } }, "service_account_id": "<service_account_ID>", "logging": { "enabled": true, "folder_id": "<folder_ID>", "min_level": "<logging_level>" }, "network": { "subnet_ids": [ "<list_of_subnet_IDs>" ], "security_group_ids": [ "<list_of_security_group_IDs>" ] }, }Where:
service_account_id: ID of themetastore-logging-saservice account you created earlier.logging.folder_id: Specify the ID of the folder whose log group you want to use.logging.min_level: Logging level. The execution log will contain logs of this level or higher. The available levels areTRACE,DEBUG,INFO,WARN,ERROR, andFATAL. The default isINFO.network.subnet_ids: ID of the subnet where you set up the NAT gateway.network.security_group_ids: ID of the security group you configured earlier.
-
Use the ClusterService.Create call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/metastore/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d @ \ metastore.api.cloud.yandex.net:443 \ yandex.cloud.metastore.v1.ClusterService.Create \ < body.json -
View the server response to make sure your request was successful.
-
-
Test the transfer of cluster logs to the log group:
Management consoleCLIAPI- In the management console, navigate to the relevant folder.
- Select Cloud Logging.
- Click the row with the
defaultlog group.
The page that opens will show the log group entries.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idparameter.To view the entries in JSON format, run this command:
yc logging read --group-name=default --format=jsonResult:
[ { "uid": "23:6d******:3", "resource": { "type": "managed-metastore.cluster", "id": "c9qcv46p3g3a********" }, "timestamp": "2024-11-18T09:45:23.092484Z", "ingested_at": "2024-11-18T09:45:24Z", "saved_at": "2024-11-18T09:45:25.559195Z", "level": "INFO", "message": "ugi=metastore\tip=10.253.89.135\tcmd=Done cleaning up thread local RawStore\t", "json_payload": { "instance": "metastore-server-5f9c7ff***-*****", "logger": "org.apache.hadoop.hive.metastore.HiveMetaStore.audit", "resource_id": "c9qcv46p3g3a********", "stream_name": "metastore-server", "thread": "pool-6-thread-79" }, "stream_name": "metastore-server" } ]To view log group entries, use the LogReadingService.Read gRPC API call.
For more information, see Reading records.
Sending data to a custom log group
-
Create a log group named
metastore-log-group. -
Create a Apache Hive™ Metastore cluster:
Management consoleCLIREST APIgRPC API-
In the management console
, select the folder you need. -
Select Yandex MetaData Hub.
-
In the left-hand panel, select
Metastore. -
Click Create cluster.
-
Specify
metastore-clusteras the cluster name. -
In the Service account field, select
metastore-logging-sa. -
Under Network settings, select the network and subnet with a NAT gateway configured. Specify the security group you configured.
-
Under Logging:
-
Enable Write logs.
-
To write logs to a custom log group, select Log group in the Destination field.
-
Specify the
metastore-log-grouplog group. -
Select the minimum logging level.
The execution log will contain logs of this level or higher. The available levels are
TRACE,DEBUG,INFO,WARN,ERROR, andFATAL. The default isINFO.
-
-
Click Create.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idparameter.Run this command:
yc managed-metastore cluster create \ --name metastore-cluster \ --service-account-id <service_account_ID> \ --version <Apache Hive™ Metastore_version> \ --subnet-ids <subnet_IDs> \ --security-group-ids <security_group_IDs> \ --resource-preset-id <ID_of_computing_resources> \ --log-enabled \ --log-group-id <log_group_ID> \ --log-min-level <logging_level>Where:
--service-account-id: ID of themetastore-logging-saservice account you created earlier.--subnet-ids: ID of the subnet where you set up the NAT gateway.--security-group-ids: ID of the security group you configured earlier.--log-group-id:metastore-log-grouplog group ID.--log-min-level: Logging level. The execution log will contain logs of this level or higher. The available levels areTRACE,DEBUG,INFO,WARN,ERROR, andFATAL. The default isINFO.
-
Get an IAM token for API authentication and save it as an environment variable:
export IAM_TOKEN="<IAM_token>" -
Create a file named
body.jsonand paste the following code into it:{ "folderId": "<folder_ID>", "name": "metastore-cluster", "version": "<Apache Hive™ Metastore_version>", "configSpec": { "resources": { "resourcePresetId": "<resource_configuration_ID>" } }, "serviceAccountId": "<service_account_ID>", "logging": { "enabled": true, "logGroupId": "<log_group_ID>", "minLevel": "<logging_level>" }, "network": { "subnetIds": [ "<list_of_subnet_IDs>" ], "securityGroupIds": [ "<list_of_security_group_IDs>" ] }, }Where:
serviceAccountId: ID of themetastore-logging-saservice account you created earlier.logging.logGroupId:metastore-log-grouplog group ID.logging.minLevel: Logging level. The execution log will contain logs of this level or higher. The available levels areTRACE,DEBUG,INFO,WARN,ERROR, andFATAL. The default isINFO.network.subnetIds: ID of the subnet where you set up the NAT gateway.network.securityGroupIds: ID of the security group you configured earlier.
-
Use the Cluster.Create method and send the following request, e.g., via cURL
:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://metastore.api.cloud.yandex.net/managed-metastore/v1/clusters' \ --data '@body.json' -
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and save it as 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 the repository contents are stored in the
~/cloudapi/directory. -
Create a file named
body.jsonand paste the following code into it:{ "folder_id": "<folder_ID>", "name": "metastore-cluster", "version": "<Apache Hive™ Metastore_version>", "config_spec": { "resources": { "resource_preset_id": "<resource_configuration_ID>" } }, "service_account_id": "<service_account_ID>", "logging": { "enabled": true, "log_group_id": "<log_group_ID>", "min_level": "<logging_level>" }, "network": { "subnet_ids": [ "<list_of_subnet_IDs>" ], "security_group_ids": [ "<list_of_security_group_IDs>" ] }, }Where:
service_account_id: ID of themetastore-logging-saservice account you created earlier.logging.log_group_id:metastore-log-grouplog group ID.logging.min_level: Logging level. The execution log will contain logs of this level or higher. The available levels areTRACE,DEBUG,INFO,WARN,ERROR, andFATAL. The default isINFO.network.subnet_ids: ID of the subnet where you set up the NAT gateway.network.security_group_ids: ID of the security group you configured earlier.
-
Use the ClusterService.Create call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/metastore/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d @ \ metastore.api.cloud.yandex.net:443 \ yandex.cloud.metastore.v1.ClusterService.Create \ < body.json -
View the server response to make sure your request was successful.
-
-
Test the transfer of cluster logs to the log group:
Management consoleCLIAPI- In the management console, navigate to the relevant folder.
- Select Cloud Logging.
- Click the row with the
metastore-log-grouplog group.
The page that opens will show the log group entries.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idparameter.To view the entries in JSON format, run this command:
yc logging read --group-name=metastore-log-group --format=jsonResult:
[ { "uid": "23:6d******:3", "resource": { "type": "managed-metastore.cluster", "id": "c9qcv46p3g3a********" }, "timestamp": "2024-11-18T09:45:23.092484Z", "ingested_at": "2024-11-18T09:45:24Z", "saved_at": "2024-11-18T09:45:25.559195Z", "level": "INFO", "message": "ugi=metastore\tip=10.253.89.135\tcmd=Done cleaning up thread local RawStore\t", "json_payload": { "instance": "metastore-server-5f9c7ff***-*****", "logger": "org.apache.hadoop.hive.metastore.HiveMetaStore.audit", "resource_id": "c9qcv46p3g3a********", "stream_name": "metastore-server", "thread": "pool-6-thread-79" }, "stream_name": "metastore-server" } ]To view log group entries, use the LogReadingService.Read gRPC API call.
For more information, see Reading records.
Apache® and Apache Hive™