Set up logging and analyze performance
The guide in this checklist item will help you set up operations with logs and analyze performance.
Create a log group
-
In the management console
, select the folder where you want to create your log group. -
Open Cloud Logging.
-
Click Create group.
-
(Optional) Enter a name and description for the log group. The name format is as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
Set the log group record retention period.
-
Click Create group.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
Note
The record retention period can only be specified in hours, minutes, or seconds. For example, 1h
or 1440m
.
To create a log group, run the command:
yc logging group create --name=group --retention-period=1h
--name
: Log group name.--retention-period
: Log group record retention period. This is an optional parameter.
Result:
done (1s)
id: af3flf29t8**********
folder_id: aoek6qrs8t**********
cloud_id: aoegtvhtp8**********
created_at: "2021-06-24T09:56:38.970Z"
name: group
status: ACTIVE
retention_period: 3600s
You can create a custom log group using the create API method.
Assign roles for a log group
To assign a role to a custom log group, run this command:
- User:
yc logging group add-access-binding \ --name <log_group_name> \ --user-account-id <user_ID> \ --role <role> ``` Result:
done (1s) ```
- Service account:
yc logging group add-access-binding \ --name <log_group_name> \ --service-account-id <service_account_ID> \ --role <role>
done (1s)
- All authorized users (
allAuthenticatedUsers
system group):yc logging group add-access-binding \ --name <log_group_name> \ --all-authenticated-users \ --role <role>
done (1s)
- Service account:
To assign roles for a custom log group, use the API setAccessBindings method.
View charts
- In the management console
, select the folder containing your log group. - Open Cloud Logging.
- Select a log group.
- Go to the Monitoring tab.
- The following charts will open on the page:
- Records successfully ingested: Number of records delivered to the Cloud Logging system. Only user logs are counted.
- Records saved: Number of records saved to the Cloud Logging system. Service and user logs are counted.
- Records read: Number of records read.
- Records ingest errors: Number of errors when adding records.
- Records save lag: Difference between the time of record delivery and its saving to the Cloud Logging system.