0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS Elastic Beanstalk 環境状態監視

Last updated at Posted at 2019-10-11

問題

AWS EBでヘルスチェックには問題ないが、一部のインスタンスが障害のままで不安定の状態が続く。

ソリューション

インスタンスごとzabbixに自動登録で監視したが、EB環境が変わる度にインスタンスが入れ替わりゴミホストが増える。しかもzabbixの動作が不安定になったため中止した。(中止すると安定した・・・当時VER3.0.2)
環境状態をまとめ評価する監視に変更。

Zabbix

  • AWSプロファイル作成: aws configure --profile [マクロ{$ACCOUNT}]

  • マクロ

    • {$ACCOUNT}: アカウント(複数アカウントがある場合)
    • {$EB_APP}: アプリケーション名
  • アイテム

    • 名前:EnvStatus
    • タイプ:外部チェック
    • キー:cw_eb_status.sh["{$ACCOUNT}","{$EB_APP}"]
  • トリガー

    • 条件式: 3回連続「Ok」ではないと障害! {host:cw_eb_status.sh["{$ACCOUNT}","{$EB_APP}"].count(#3,'Ok')}=0
cw_eb_status.sh
# !/bin/bash

Account="$1"
AppName="$2"

export AWS_PROFILE=$Account

result=`aws elasticbeanstalk describe-environments --application-name ${AppName} \
        | jq '.Environments[0].HealthStatus' | sed 's/^.*"\(.*\)".*$/\1/'`

echo $result

その他

zabbixの経由にしないのであればEBコンソール上にある「アラーム(CloudWatch)」を利用してもよい。

参考

jq前

{
    "Environments": [
        {
            "EnvironmentName": "xxx-env-xxxxxa",
            "EnvironmentId": "e-xxxxxjvc",
            "ApplicationName": "xxxx",
            "VersionLabel": "app-xxxx-xxxxx_170739",
            "SolutionStackName": "64bit Amazon Linux 2018.03 v2.8.14 running PHP 5.6",
            "PlatformArn": "arn:aws:elasticbeanstalk:ap-northeast-1::platform/PHP 5.6 running on 64bit Amazon Linux/2.8.14",
            "Description": "Environment cloned from xxx-env-xxxxxa from the EB CLI using \"eb clone\"",
            "EndpointURL": "awseb-e-w-AWSEBLoa-xxxxxxxxx-1248087954.ap-northeast-1.elb.amazonaws.com",
            "CNAME": "xxx-env.elasticbeanstalk.com",
            "DateCreated": "2019-10-02T08:04:01.469Z",
            "DateUpdated": "2019-10-10T02:15:31.146Z",
            "Status": "Ready",
            "AbortableOperationInProgress": false,
            "Health": "Green",
            "HealthStatus": "Ok",
            "Tier": {
                "Name": "WebServer",
                "Type": "Standard",
                "Version": "1.0"
            },
            "EnvironmentLinks": [],
            "EnvironmentArn": "arn:aws:elasticbeanstalk:ap-northeast-1:xxxxxxxx396:environment/xxx/xxx-env-xxxxxa"
        }
    ]
}
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?