[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eThe Observability platform aggregates logs from various project components, indexes them, and associates them with labels for comprehensive data observability.\u003c/p\u003e\n"],["\u003cp\u003eYou can query and view both operational and audit logs within the system monitoring instance's logs panel, accessible via the Grafana UI.\u003c/p\u003e\n"],["\u003cp\u003eAccess to view logs requires the Project Grafana Viewer (\u003ccode\u003eproject-grafana-viewer\u003c/code\u003e) role, managed by the Project IAM Admin.\u003c/p\u003e\n"],["\u003cp\u003eLogs can be filtered using LogQL expressions, searching by labels like \u003ccode\u003ecluster\u003c/code\u003e, \u003ccode\u003enamespace\u003c/code\u003e, \u003ccode\u003enode\u003c/code\u003e, \u003ccode\u003epod\u003c/code\u003e, and \u003ccode\u003econtainer\u003c/code\u003e to refine your query results.\u003c/p\u003e\n"],["\u003cp\u003eAfter querying, you can export logs in plain text or CSV format, and adjust the time range of logs displayed by selecting the time picker drop-down.\u003c/p\u003e\n"]]],[],null,["# Query and view logs\n\nAfter the log collector pulls data from various project components, the Observability platform aggregates logs from all log sources, adds indexes, and associates logs with labels according to the configuration for data observability. You can then query and view logs on the logs panel of the system monitoring instance.\n\nQuery and view logs on the logs panel\n-------------------------------------\n\nYou can query logs through the user interface (UI) of the\n\nsystem monitoring instance of your project.\n\nThe system monitoring instance includes project-level measures to monitor infrastructure components, such as CPU utilization, storage consumption, network monitoring, server monitoring, logs, alerts, and metrics from the GDC components.\n\nYou can view logs on the logs panel of the system monitoring instance of your project. Then, you can make queries to view specific logs for data observability of your use case needs.\n\n### Before you begin\n\nBefore querying and viewing logs on the logs panel, you must obtain access to the system monitoring instance. For more information, see [Get access to dashboards](/distributed-cloud/hosted/docs/latest/appliance/admin/get-access-dashboards).\n\nTo sign in and view logs in Grafana, ask your Project IAM Admin to grant you the Project Grafana Viewer (`project-grafana-viewer`) role. This role-based access control process lets you access data visualizations safely.\n\n### Build queries for your logs\n\nQuerying logs from the UI of the system monitoring instance lets you choose the data source to retrieve operational logs from your project and get an integrated view of your queries. To filter results, search for logs by labels using query language expressions. For example, you can set the `cluster` and `namespace` labels in your queries to the values that identify your cluster and project namespace, respectively.\n\n#### System monitoring instance endpoint\n\n**For Application Operator (AO)**\n\nThe following URL is the endpoint of the monitoring instance of your project: \n\n https://\u003cvar translate=\"no\"\u003eGDC_URL\u003c/var\u003e/\u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e/grafana\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eGDC_URL\u003c/var\u003e: The URL of your organization in GDC.\n- \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e: The namespace of your project.\n\n**For Platform Admin (PA)**\n\nThe following URL is the endpoint of the monitoring instance of your project: \n\n https://\u003cvar translate=\"no\"\u003eGDC_URL\u003c/var\u003e/platform-obs/grafana\n\nReplace \u003cvar translate=\"no\"\u003eGDC_URL\u003c/var\u003e with the URL of your organization in GDC.\n\n#### Query operational logs\n\n1. In the GDC console, select a project.\n2. On the navigation menu, click **Operations** \\\u003e **Logging**.\n3. Click **View all in Grafana Loki**.\n\n A new page opens the [URL of the monitoring instance of your project](#monitoring-instance-endpoint).\n4. On the UI of the monitoring instance, click explore **Explore**\n from the navigation menu to open the **Explore** page.\n\n5. From the drop-down menu at the **Explore** bar, select **Operational Logs**\n as the data source to retrieve operational logs.\n\n6. Enter a query to search for logs by labels using\n [LogQL](https://grafana.com/docs/loki/latest/logql/) (Log Query\n Language) expressions. You can do this step in either of the following ways:\n\n - Use the interactive query-builder UI. Then, click **Run query**.\n - Enter your query using LogQL expressions directly in the text field and press \u003ckbd\u003eShift+Enter\u003c/kbd\u003e to run the query.\n\n The page displays the logs matching your query.\n\nAfter querying logs, you can export them. Click **Export** to download logs in plain text or CSV formats.\n\n**Figure 1.** Menu option to query logs from the UI of the system monitoring instance.\n\nIn figure 1, the **Operational Logs** option displays the interface that lets you build log queries from the UI to retrieve operational logs.\n\nTo query audit logs instead of operational logs, select **Audit Logs** as the data source from the drop-down menu at the **Explore** bar in the previous step.\n\n**Figure 2.** Menu option to query audit logs from the UI of the monitoring instance.\n\nIn figure 2, the **Audit Logs** option displays the interface that lets you build queries from the UI to retrieve audit logs.\n\nAfter querying logs, you can export them. Click the **Export** button to download logs in plain text or CSV formats.\n\nComplete the following steps to retrieve operational logs:\n\n1. In the GDC console, select a project.\n2. On the navigation menu, click **Operations** \\\u003e **Logging**.\n3. Click **View all in Grafana Loki**.\n\n A new page opens the [URL of the monitoring instance of your project](#monitoring-instance-endpoint).\n4. On the UI of the monitoring instance, click explore **Explore**\n from the navigation menu to open the **Explore** page.\n\n5. From the drop-down menu at the **Explore** bar, select **Operational Logs**\n as the data source to retrieve operational logs.\n\n6. Enter a query to search for logs by labels using\n [LogQL](https://grafana.com/docs/loki/latest/logql/) (Log Query\n Language) expressions. You can do this step in either of the following ways:\n\n - Use the interactive query-builder UI. Then, click **Run query**.\n - Enter your query using LogQL expressions directly in the text field and press \u003ckbd\u003eShift+Enter\u003c/kbd\u003e to run the query.\n\n The page displays the logs matching your query.\n\nAfter querying logs, you can export them. Click **Export** to download logs in plain text or CSV formats.\n\n#### Query audit logs\n\nComplete the following steps to retrieve audit logs:\n\n1. In the GDC console, select a project.\n2. On the navigation menu, click **Operations** \\\u003e **Audit Logging**.\n3. Click **View all in Grafana Loki**.\n\n A new page opens the [URL of the monitoring instance of your project](#monitoring-instance-endpoint).\n4. On the UI of the monitoring instance, click explore **Explore**\n from the navigation menu to open the **Explore** page.\n\n5. From the drop-down menu at the **Explore** bar, select **Audit Logs**\n as the data source to retrieve audit logs.\n\n6. Enter a query to search for logs by labels using\n [LogQL](https://grafana.com/docs/loki/latest/logql/) (Log Query\n Language) expressions. You can do this step in either of the following ways:\n\n - Use the interactive query-builder UI. Then, click **Run query**.\n - Enter your query using LogQL expressions directly in the text field and press \u003ckbd\u003eShift+Enter\u003c/kbd\u003e to run the query.\n\n The page displays the logs matching your query.\n\nAfter querying logs, you can export them. Click **Export** to download logs in plain text or CSV formats.\n\n#### Select a time range for your logs\n\nTo query logs in a time range from the UI of the monitoring instance, follow these steps:\n\n1. Click the schedule **Time Picker** drop-down menu.\n\n2. From the menu, perform one of the following actions:\n\n - Select relative time range options, for example, the last 30 minutes.\n - Set custom absolute time ranges by choosing specific dates and times from the calendar and clicking **Apply time range**.\n3. Optionally, click **Change time settings** to change the **Timezone** and **Fiscal year** settings from the time range controls.\n\nTime settings are saved on a per-dashboard basis. For more information about queries over a range of time, see \u003chttps://grafana.com/docs/loki/latest/reference/api/#query-loki-over-a-range-of-time\u003e.\n\n### Sample queries and labels\n\nThe following are some of the default labels that you can use to query logs:\n\n- `cluster`: The name of the cluster\n- `resources`: The list of resources\n- `namespace`: Your project namespace\n- `node`: The node name prefix\n- `pod`: The pod name prefix\n- `container`: The container name prefix\n\nThe following table describes each of the default labels that you can use to query logs from the Observability platform:\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nQueries use the LogQL query language \u003chttps://grafana.com/docs/loki/latest/logql/\u003e.\nThe following code samples show the use of labels and values to query different logs:\n\n- Select all logs from a project:\n\n {cluster=\"user-vm-1-cluster\", namespace=\"\u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e\"}\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e with the namespace of your project.\n- Select project logs from a service:\n\n {cluster=\"user-vm-1-cluster\", namespace=\"\u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e\", container=\"my-service\"}\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e with the namespace of your project.\n- Select Kubernetes API server logs:\n\n {cluster=\"admin\", namespace=\"kube-system\", resources=\"k8s_container\", container=\"kube-apiserver\"}\n\n- Select cluster bootstrap logs:\n\n {cluster=\"admin\", namespace=\"\u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e\"}\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e with the name of your project namespace. For example, `cluster-user-test`.\n- Select node journald logs:\n\n {cluster=\"admin\", resources=\"k8s_node\"}\n\n- Select cluster audit logs:\n\n {cluster=\"admin\", resources=\"k8s_audit\"}"]]