CloudWatch Logs のエラーを自動で GitHub Issues に課題化する

CloudWatch Logs のエラーを自動で GitHub Issues に課題化する ECS で稼働するWebアプリケーションのエラーログを自動的に GitHub Issues に報告する仕組みを構築しました。手動でログを監視する必要がなくなり、エラー発生時に即座にチームが認識・対応できるようになります。 背景 マルチテナントの業務システムを ECS Fargate 上で運用しています。アプリケーションは2つあり、それぞれ異なるフレームワークで構築されています。 アプリ フレームワーク 用途 web Laravel (PHP) 業務管理システム api Django (Python) API サーバー これまで CloudWatch Logs にログは収集していたものの、エラーの検知は手動確認に頼っていました。500エラーや例外発生を見逃すリスクがあり、自動検知の仕組みが必要でした。 アーキテクチャ Subscription Filter + Lambda + GitHub Issues API の構成を採用しました。 CloudWatch Logs (/ecs/{prefix}-ecs-{app}) └── Subscription Filter (エラーパターンマッチ) └── Lambda Function (Docker/arm64, Python 3.12) ├── エラー解析 (HTTP 5xx, 例外, スタックトレース) ├── ±5秒のログコンテキスト取得 ├── 既存 Open Issue 検索 └── 新規 Issue 作成 or 既存 Issue にコメント追加 この構成を選んだ理由 方式 リアルタイム性 柔軟性 コスト Subscription Filter + Lambda (採用) 高 高 中 Metric Filter + Alarm + SNS 中 (1分以上遅延) 低 低 CloudWatch Logs Insights (定期実行) 低 高 低 Subscription Filter はログ出力時にほぼリアルタイムで Lambda を起動するため、エラー発生から数秒で Issue が作成されます。 ...

2026年2月24日 · 4 分

PGVector

PGVector ニューラルネットワークの知識の蒸留 distilling the knowledge in a neural networkPGVector (Postgres) Rails/PostgreSQL/pgvector を組み合わせてベクトル検索をする。 https://github.com/yassun/sample-pgvector https://hub.docker.com/r/pgvector/pgvector https://github.com/pgvector/pgvector-python LangChain と pgvector(Postgres)を用いて関連性の高いドキュメントを手軽に検索する 生成 AI でテキスト分類やってみた SentenceTransformer Python の SentenceTransformer を用いた文章類似度比較 sentence transformers で日本語を扱えるモデルのまとめ transformers 多言語モデル中の日本語語彙調査 知識蒸留 ニューラルネットワークの知識の蒸留 distilling the knowledge in a neural network 知識蒸留で効果的な教師の条件とは? 教師データとは?学習データとの違いや作り方をわかりやすく紹介 ディープラーニングを軽量化する「モデル圧縮」3手法 MUSE Muse: Text-To-Image Generation via Masked Generative Transformers を読んだメモ

2024年7月31日 · 1 分

サイトセキュリティチェック

サイトセキュリティチェック Mozilla: https://observatory.mozilla.org/ トレンドマイクロ: https://global.sitesafety.trendmicro.com/?cc=jp Google: https://www.virustotal.com/gui/home/upload OWASP Zap Docker 版 OWASP ZAP を M1 Mac で動かす。 問題: : Cookie No HttpOnly Flag [10010] : Re-examine Cache-control Directives [10015] : Cross-Domain JavaScript Source File Inclusion [10017] : Missing Anti-clickjacking Header [10020] : X-Content-Type-Options Header Missing [10021] : [Information Disclosure - Suspicious Comments]https://www.zaproxy.org/docs/alerts/10027/ : [Cookie Poisoning]https://www.zaproxy.org/docs/alerts/10029/ : User Controllable HTML Element Attribute (Potential XSS) [10031] : Strict-Transport-Security Header Not Set [10035] : Content Security Policy (CSP) Header Not Set [10038] : Secure Pages Include Mixed Content [10040] : Storable and Cacheable Content [10049] : Cookie without SameSite Attribute [10054] : Permissions Policy Header Not Set [10063] : Timestamp Disclosure - Unix [10096] : Modern Web Application [10109] (対応しなくてもよい) : Dangerous JS Functions [10110] : Session Management Response Identified [10112] : Absence of Anti-CSRF Tokens [10202] : Sub Resource Integrity Attribute Missing [90003] : Charset Mismatch [90011] VIRUSTOTAL https://www.virustotal.com/gui/home/upload SUURI https://sitecheck.sucuri.net/

2024年7月22日 · 1 分

Terraform and others

Terraform , CloudFormation 関連 OpenTofu https://opentofu.org/ troposphere https://github.com/cloudtools/troposphere troposphere で CloudFormation のテンプレートを作成する。 former2 https://github.com/iann0036/former2 Former2 から CloudFormation を生成してみた インストール: 1 2 3 4 git clone https://github.com/iann0036/former2.git sudo /Applications/Docker.app/Contents/MacOS/install remove-vmnetd sudo /Applications/Docker.app/Contents/MacOS/install vmnetd docker-compose up -d

2024年6月25日 · 1 分

ECS: aws-cli

ECS: aws-cli curl, unzip は入っていること 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 ARG BASE_IMAGE=myimage-cicd-appbase ARG TAG=latest FROM ${BASE_IMAGE}:${TAG} as server ARG USERNAME=ubuntu ARG GROUPNAME=ubuntu ARG PASSWORD=ubuntu ARG UID=1000 ARG GID=1000 ENV APP_BASE=/usr/src/app \ LIB_BASE=/usr/src/lib \ POETRY_VERSION=1.0.10 \ PATH="/root/.poetry/bin:$PATH" RUN mkdir -p /var/run/gunicorn && mkdir -p /storage RUN apt-get update && apt-get install -y sudo RUN groupadd -g ${GID} ${GROUPNAME} && \ useradd -m -s /bin/bash -u ${UID} -g ${GID} -G sudo ${USERNAME} --home-dir ${APP_BASE} && \ echo ${USERNAME}:${PASSWORD} | chpasswd && \ echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers # aws-cli RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" RUN unzip awscliv2.zip RUN sudo ./aws/install # Application COPY . ${APP_BASE} WORKDIR ${APP_BASE} RUN pip install pip poetry urllib3==1.26.15 -U && \ poetry config virtualenvs.create false && \ poetry install && pip install urllib3==1.26.15 pyOpenSSL -U RUN chown -R ${USERNAME}:${GROUPNAME} ${APP_BASE} RUN chmod 777 /run/gunicorn USER ${USERNAME} CMD ["/usr/src/app/docker/codebuild/entry_web.sh", "/usr/src/app"]

2024年1月7日 · 1 分

macOS: ls: .: Operation not permitted

macOS: ls: .: Operation not permitted このエラーは、macOSのセキュリティ機能によって、ターミナルのコマンドが特定のディレクトリに対して制限されている可能性があります¹²。例えば、DownloadsやDocumentsなどのディレクトリは、プライバシー保護のためにアクセス権が制限されています²。 この場合、システム環境設定から、ターミナルに対してフルディスクアクセスを許可する必要があります¹²。具体的な手順は以下の通りです。 システム環境設定を開きます。 セキュリティとプライバシーを選択します。 プライバシータブをクリックします。 左側のメニューからフルディスクアクセスを選択します。 鍵のアイコンをクリックしてロックを解除します。 パスワードを入力します。 +ボタンをクリックしてターミナルを追加します。 ターミナルを再起動します。 これで、lsコマンドなどが正常に動作するはずです。試してみてください。 ソース: Bing との会話 2023/5/3 (1) macOS の「Operation not permitted」を回避する【du/ls/mv/cp …. https://qiita.com/KEINOS/items/0366f1c281b574a79cfb. (2) ターミナルでコマンド実行時に「Operation not permitted」が出 …. https://qiita.com/Tatsu88/items/f50f850b0c8f4a2c1bf2. (3) unix - ls: Operation not Permitted - Stack Overflow. https://stackoverflow.com/questions/25717501/ls-operation-not-permitted. (4) 突然の「Operation not permitted」-Dockerが採用する …. https://www.creationline.com/lab/46861. 設定 > プライバシーとセキュリティ > フルディスクアクセス

2023年5月2日 · 1 分

Django Simple Docker File

% tree . -I '__*|db*' . ├── Dockerfile ├── poetry.lock ├── pyproject.toml └── web ├── blogsite │ ├── asgi.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── manage.py └── pages ├── admin.py ├── apps.py ├── migrations ├── models.py ├── tests.py ├── urls.py └── views.py 4 directories, 14 files

2021年2月19日 · 1 分