Skip to content

Continuous Monitoring of Dockerhub and public ECR #169274

Continuous Monitoring of Dockerhub and public ECR

Continuous Monitoring of Dockerhub and public ECR #169274

name: Continuous Monitoring of Dockerhub and public ECR
on:
workflow_dispatch:
schedule:
- cron: '*/10 * * * *'
permissions:
id-token: write
contents: read
jobs:
monitor-ecr:
name: Monitor public ECR
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_INTEG_TEST_ROLE_ARN }}
aws-region: us-east-1
- name: Login to Public ECR
uses: docker/login-action@v1
with:
registry: public.ecr.aws
- name: Pull an image from public ECR
id: pull-from-ecr
run: docker pull public.ecr.aws/xray/aws-xray-daemon:latest
- name: Publish metric on pulling an image
if: ${{ always() }}
run: |
if [[ "${{ steps.pull-from-ecr.outcome }}" == "failure" ]]; then
aws cloudwatch put-metric-data --metric-name PullImageFailureFromECR --dimensions failure=rate --namespace MonitorDaemon --value 1 --timestamp $(date +%s)
else
aws cloudwatch put-metric-data --metric-name PullImageFailureFromECR --dimensions failure=rate --namespace MonitorDaemon --value 0 --timestamp $(date +%s)
fi
- name: Run daemon image
run: |
docker run --name xray-daemon public.ecr.aws/xray/aws-xray-daemon:latest -o -n us-west-2 &
sleep 30
- name: Publish metrics on daemon startup
if: ${{ always() }}
run: |
if [[ "$(docker container inspect -f '{{.State.Status}}' xray-daemon )" != "running" ]]; then
aws cloudwatch put-metric-data --metric-name DaemonImageStartupFailureFromECR --dimensions failure=rate --namespace MonitorDaemon --value 1 --timestamp $(date +%s)
else
aws cloudwatch put-metric-data --metric-name DaemonImageStartupFailureFromECR --dimensions failure=rate --namespace MonitorDaemon --value 0 --timestamp $(date +%s)
fi
monitor-dockerhub:
name: Monitor docker hub
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_INTEG_TEST_ROLE_ARN }}
aws-region: us-east-1
- name: Pull an image from docker hub
id: pull-from-dockerhub
run: docker pull amazon/aws-xray-daemon:latest
- name: Publish metric on pulling an image
if: ${{ always() }}
run: |
if [[ "${{ steps.pull-from-dockerhub.outcome }}" == "failure" ]]; then
aws cloudwatch put-metric-data --metric-name PullImageFailureFromDockerhub --dimensions failure=rate --namespace MonitorDaemon --value 1 --timestamp $(date +%s)
else
aws cloudwatch put-metric-data --metric-name PullImageFailureFromDockerhub --dimensions failure=rate --namespace MonitorDaemon --value 0 --timestamp $(date +%s)
fi
- name: Run daemon image
run: |
docker run --name xray-daemon amazon/aws-xray-daemon:latest -o -n us-west-2 &
sleep 30
- name: Publish metrics on daemon startup
if: ${{ always() }}
run: |
if [[ "$(docker container inspect -f '{{.State.Status}}' xray-daemon )" != "running" ]]; then
aws cloudwatch put-metric-data --metric-name DaemonImageStartupFailureFromDockerhub --dimensions failure=rate --namespace MonitorDaemon --value 1 --timestamp $(date +%s)
else
aws cloudwatch put-metric-data --metric-name DaemonImageStartupFailureFromDockerhub --dimensions failure=rate --namespace MonitorDaemon --value 0 --timestamp $(date +%s)
fi