LoginSignup
2
0

More than 5 years have passed since last update.

CloudWatchでElasticacheのアラームを作成する

Posted at

目的

ElastiCacheのアラームを作成する

方法

code管理の為、itamaeを使用

設定

  • elasticacheの場合、ディメンションにCacheNodeId,CacheClusterIdをセットで定義する必要がある

    • idはapiで取得が可能
    $ aws elasticache describe-cache-clusters --show-cache-node-info | jq '.CacheClusters[]'
    {
    "Engine": "redis",
    "CacheNodes": [
    {
      "CacheNodeId": "****",
      "Endpoint": {
        "Port": 6379,
    (snip)
    "CacheClusterId": "example",
    "CacheSecurityGroups": [],
    (snip)
    
    
  • Redisによって割り当てられた総バイト数の監視設定

cloudwatch_metric_alarm.tf
resource "aws_cloudwatch_metric_alarm" "example-BytesUsedForCache" {
  alarm_name          = "[ElastiCache]example-BytesUsedForCache"
  comparison_operator = "GreaterThanOrEqualToThreshold"
  evaluation_periods  = "1"
  metric_name         = "BytesUsedForCache"
  namespace           = "AWS/ElastiCache"
  period              = "60"
  statistic           = "Maximum"
  threshold           = "29000000000" #29Gib
  alarm_actions       = ["arn:aws:sns:ap-northeast-1::**********::example"]
  ok_actions          = ["arn:aws:sns:ap-northeast-1::**********::example"]
  dimensions  {
    CacheClusterId = "example"
    CacheNodeId    = "****"
  }
}

確認

  • datapointから取得できている
$ aws cloudwatch describe-alarms --alarm-name-prefix "[ElastiCache]example-BytesUsedForCache"
{
    "MetricAlarms": [
        {
            "EvaluationPeriods": 1,
            "AlarmArn": "arn:aws:cloudwatch:ap-northeast-1:**********:alarm:[ElastiCache]example-BytesUsedForCache",
            "StateUpdatedTimestamp": "2017-05-24T03:46:36.581Z",
            "AlarmConfigurationUpdatedTimestamp": "2017-05-24T03:46:35.981Z",
            "ComparisonOperator": "GreaterThanOrEqualToThreshold",
            "AlarmActions": [
                "arn:aws:sns:ap-northeast-1::**********::example"
            ],
            "Namespace": "AWS/ElastiCache",
            "StateReasonData": "{\"version\":\"1.0\",\"queryDate\":\"2017-05-24T03:46:36.572+0000\",\"startDate\":\"2017-05-24T03:45:00.000+0000\",\"statistic\":\"Maximum\",\"period\":60,\"recentDatapoints\":[2.8566225048E10],\"threshold\":2.9E10}",
            "Period": 60,
            "StateValue": "OK",
            "Threshold": 29000000000.0,
            "AlarmName": "[ElastiCache]exampleBytesUsedForCache",
            "Dimensions": [
                {
                    "Name": "CacheClusterId",
                    "Value": "example"
                },
                {
                    "Name": "CacheNodeId",
                    "Value": "****"
                }
            ],
            "Statistic": "Maximum",
            "StateReason": "Threshold Crossed: 1 datapoint (2.8566225048E10) was not greater than or equal to the threshold (2.9E10).",
            "InsufficientDataActions": [],
            "OKActions": [
                "arn:aws:sns:ap-northeast-1:**********::example"
            ],
            "ActionsEnabled": true,
            "MetricName": "BytesUsedForCache"
        }
    ]
}
  • Redisのメトリクス
メトリクス 説明 単位
BytesUsedForCache Redis によって割り当てられた総バイト数 Bytes
CacheHits 成功したキー検索の数 カウント
CacheMisses 失敗したキー検索の数 カウント
CurrConnections クライアントの接続数 (リードレプリカからの接続を除く) カウント
Evictions maxmemory の制限のため排除されたキーの数 カウント
HyperLogLogBasedCmds HyperLogLog ベースのコマンドの総数。これは、Redis commandstats 統計に基づき、すべての pf 方のコマンド (pfadd、pfcount、pfmerge) を合計することで算出される カウント
NewConnections この期間内にサーバーによって受け入れられた接続の総数 カウント
Reclaimed キーの有効期限切れイベントの総数 カウント
ReplicationBytes レプリカがアタッチされたプライマリについては、ReplicationBytesは、プライマリがすべてのレプリカに対して送信するバイト数を報告。レプリケーショングループに対する書き込み負荷を表す。レプリカおよびスタンドアロンのプライマリについては、ReplicationBytesは常に0 Bytes
ReplicationLag リードレプリカとして実行中のノードにのみ適用。レプリカのプライマリノードからの変更適用の進行状況を秒で表す Seconds
SaveInProgress バックグラウンド保存 (分岐または分岐なし) が進行中の場合は常に 1 を返し、それ以外の場合は 0 を返します。バックグラウンド保存プロセスは一般に、スナップショットおよび同期の際に使用される。これらのオペレーションによりパフォーマンスが低下する可能性がある。 SaveInProgress メトリクスを使用して、パフォーマンスが低下した原因がバックグラウンド保存プロセスであるかどうかを診断 カウント
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0