

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 Amazon CloudWatch Logs 查詢編輯器
<a name="CloudWatch-using-the-logs-query-editor"></a>

 若要查詢 CloudWatch Logs，請選取您要查詢的區域和最多 20 個日誌群組。使用主要輸入區域來撰寫查詢。如需詳細資訊，請參閱 [CloudWatch Logs Insights 查詢語法](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html)。

 您也可以使用 CloudWatch Logs Insights 中的 `stats`命令，撰寫傳回時間序列資料的查詢。在探索中進行`stats`查詢時，您必須確定您處於指標探索模式。

 查詢輸入欄位右側有一個 CloudWatch Logs Insights 連結，可使用您的查詢開啟 CloudWatch Logs Insights 主控台。如有必要，您可以繼續探索。

## 使用範本變數
<a name="cloudwatch-using-template-variables"></a>

 如同數個其他資料來源，CloudWatch 資料來源支援在查詢中使用範本變數。如需詳細資訊，請參閱[範本和變數](templates-and-variables.md)。

## 從 Grafana 面板深度連結至 CloudWatch Logs 主控台
<a name="deep-linking-from-grafana-panels-to-the-cloudwatch-console-2"></a>

 如果您想要在 CloudWatch Logs Insights 主控台中檢視查詢，請選擇查詢編輯器旁的 **CloudWatch Logs Insights** 按鈕。如果您目前尚未登入 CloudWatch 主控台，連結會將您轉送至登入頁面。提供的連結適用於任何 ， AWS 帳戶 但只有在您登入對應至 Grafana 中所選資料來源的 時 AWS 帳戶 ，才會顯示正確的指標。

## 提醒
<a name="cloudwatch-alerting"></a>

 由於 CloudWatch Logs 查詢可以傳回數值資料，例如透過使用 `stats`命令，因此支援警示。如需詳細資訊，請參閱[Grafana 提醒](alerts-overview.md)。