Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
タグバンガーズのDevOpsと CWL-Jiraログ連携について
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Alisa Sasaki
May 21, 2019
Technology
180
0
Share
タグバンガーズのDevOpsと CWL-Jiraログ連携について
2019.5.20 JAWS-UG Yokohama発表 タグバンガーズ 佐々木
Alisa Sasaki
May 21, 2019
Other Decks in Technology
See All in Technology
APIテストとは?
nagix
0
160
さきさん文庫の書籍ができるまで
sakiengineer
0
320
「コーディング」しない人のための Claude Code 入門 ChatGPT の次の一歩 — 業務に組み込む 育成・共有・自動化
rfdnxbro
1
230
A Harness for Behaviour: how to get AI to generate code that does what we intend, or "TDD in the age of AI"
xpmatteo
1
520
Claude Codeを組織で使いこなす— サーバサイドAIエージェント運用の実践知
techtekt
PRO
0
130
Java正規表現エンジン(NFA)の仕組みと パフォーマンスを維持するための最適化手法
takeuchi_132917
0
150
はじめてのDatadog
kairim0
0
240
大学生が本気でDatabricksを活用してDiscordサークルをデータ駆動させてみた
phantomjuju
1
290
Generative UI × A2UI で AI エージェントを作った話 AI-DLC も使ってみた!
kmiya84377
1
290
Javaで学ぶSOLID原則
negima
1
240
Diagnosing performance problems without the guesswork
elenatanasoiu
0
120
AIが変えた"品質の守り方"
kkakizaki
13
5.4k
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
920
Mobile First: as difficult as doing things right
swwweet
225
10k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
120
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
ラッコキーワード サービス紹介資料
rakko
1
3.5M
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
520
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
280
Building a Scalable Design System with Sketch
lauravandoore
463
34k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Making Projects Easy
brettharned
120
6.7k
Transcript
タグバンガーズのDevOpsと CWL-Jiraログ連携について タグバンガーズ 佐々⽊ 2019.5.20
⾃⼰紹介 • 株式会社タグバンガーズからきました • JSUG(Spring), JAWS-UG Yokohamaスタッフ(NEW!) • 好きなAWSのサービス:Beanstalk •
好きなAtlassianのサービス:Confluence Atlassian アトラシアン製品導⼊⽀援 AWS AWS導⼊⽀援・構築 Web/Smartphone App モダンな業務システム開発
タグバンガーズのDevOps DEV OPS 提案書 仕様書 リリースノート スプリントで開発、タスク管理 gitリポジトリ ビルドツール デプロイツール
顧客サポート受付・対応 チャットツール コードクオリティ分析 Atlassian のサービスを利⽤したチケット駆動のプロジェクト管理
タスクが発⽣したらJiraからBitbucketに対してブランチを作成 タスク管理ツール リポジトリ
BitbucketのPRでタスクのコミット内容やビルド結果を確認 AWS CodeCommit is like リポジトリ
Bambooでビルド・デプロイのステップを指定 AWS CodeDeploy AWS CodeBuild AWS CodePipeline is like Bamboo:ブランチベース
Bitbucket Pipeline:PRベース ビルド・デプロイ
Bambooでビルド・デプロイのステップを指定
None
成果物を顧客のAWS環境にデプロイ Beanstalk デプロイ EC2 Beanstalk Beanstalk AWS Cloud AWS Cloud
AWS Cloud AWS Cloud クライアント クライアント クライアント push
CWL + Jira でシステムのログ連携機能を作りました フィルター条件に⼀致した怪しいログをニアリアルタイムに JIRAへチケット化するための仕組み
AWS Cloud ログを監視し、Exceptionが発⽣したときにJiraにタスクを⾃動⽣成する AWS Cloud クライアント Log publishers Amazon Kinesis
Data Stream Amazon DynamoDB Amazon CloudWatch Logs AWS Key Management Service AWS Cloud Subscription Filter(メトリク スフィルタ) バッファリング+ 複数アカウント連携 Subscription Decrypted Credentials REST API GET Jira Project ID CloudWatch Logsのロググループと 対応するJIRAプロジェクトの マッピングを保持する Log publishers AWS Lambda EC2 Subscription Filter Jiraのログイン情報をもって プロジェクトに対し チケットを作成する Amazon CloudWatch Logs 5SJHHFS ϩάͷऩूͱӾཡͷ ϑΟϧλϦϯά͞ΕͨϩάΛ νέοτ͢Δ
使⽤したツール • packaging, deploy: AWS SAM • CWLでサブスクリプションフィルタに⼀致したレコードを受信する Kinesis Data
Stream • CWLがKinesis Data Streamへ送信するときに利⽤するIAM Role • KinesisをポーリングしてJiraへチケットを作成するラムダファンク ション • Jira エンドポイント/ユーザ名/パスワード • CWL LogGroup と Jira のプロジェクトとの相関情報を保持する DynamoDB • Lambda: GoLang
CWLDestination: Type: AWS::Logs::Destination Properties: DestinationName: go-notify-logs-central-destination DestinationPolicy: > { "Version"
: "2012-10-17", "Statement" : [ { "Effect" : "Allow", "Principal" : { "AWS" : [ ”123456789012", ”123451234512" ] }, "Action" : "logs:PutSubscriptionFilter", "Resource" : "arn:aws:logs:*:*:destination:go-notify-logs-central-destination" } ] } RoleArn: !GetAtt CWLStreamRole.Arn TargetArn: !GetAtt CWLStream.Arn CWLがKinesis Data Streamへ送信するときに利⽤するIAM CWLでサブスクリプションフィルタに⼀致したレコードを受信するkinesis data stream CloudWatchLogs Destinationを作成 AWS SAMで定義しデプロイ template.yaml
Destinationのポリシーを修正して連携アカウント追加 CWLDestination: Type: AWS::Logs::Destination Properties: DestinationName: go-notify-logs-central-destination DestinationPolicy: > {
"Version" : "2012-10-17", "Statement" : [ { "Effect" : "Allow", "Principal" : { "AWS" : [ ”123456789012", "123451234512”, "111122223333” ] }, "Action" : "logs:PutSubscriptionFilter", "Resource" : "arn:aws:logs:*:*:destination:notify-logs-destination" } ] } RoleArn: !GetAtt CWLStreamRole.Arn TargetArn: !GetAtt CWLStream.Arn アカウントのIDを信頼してクロスアカウントからの配信を可能にする 信頼するアカウントを追加するときはここにIDを追加してSAMを再度デプロイ
配信元AWSアカウントのCWLにサブスクリプションフィルターを設置 CloudWatchLogs LogGroupが既に存在する場合 locals { # SAMで作成されたDestination ARN destination_arn =
"arn:aws:logs:ap-northeast-1:*****:destination:notify-logs-destination" } module "main" { source = "../../modules/subfilter" log_group_name = “/aws/elasticbeanstalk/blog-tagbangers- product/var/log/tomcat8/catalina.out" filter_pattern = "Exception" destination_arn = "${local.destination_arn}" } Terraform
配信元AWSアカウントのCWLにサブスクリプションフィルターを設置 CloudWatchLogs LogGroupをフィルタと⼀緒に作る場合 locals { # SAMで作成されたDestination ARN destination_arn =
"arn:aws:logs:ap-northeast-1:****:destination:notify-logs-destination" } module ”test" { source = "../../modules/cwl_with_subfilter" name = "test" filter_pattern = "Exception" destination_arn = "${local.destination_arn}" }
Jira Metadataの管理 CWLLogGroup String: /aws/elasticbeanstalk/blog-tagbangers-product-alb/var/log/web-1.log JIRAAssigner String: ***@tagbangers.co.jp JIRAIssueType String:
Task JIRAPriority String: Major JIRAProjectKey String: SAP JIRAReporter String: ***@tagbangers.co.jp JIRASubject String: Exception from blog-tagbangers-product /aws/elasticbeanstalk/blog-tagbangers- product-alb/var/log/web-1.log Owner String: 153840059389 CloudWatchLogsのロググループとJIRAプロジェクトの関連はDynamoDBで管理 DynamoDB Item
Lambda Function Handler 抜粋 func handler(ctx context.Context, kinesisEvent events.KinesisEvent) error
{ if err := setup(); err != nil { return err } fmt.Printf("kinesisEvent = %#v\n", kinesisEvent) for _, record := range kinesisEvent.Records { kinesisData, err := tbaws.DecodeKinesisData(record.Kinesis.Data) fmt.Printf("kinesis decoded data = %#v\n", kinesisData) jiraMetadata, err := tbaws.GetJiraMetadata(kinesisData.LogGroup) for _, event := range kinesisData.LogEvents { res, err := jira.CreateIssue(&tbjira.CreateIssueRequest{ ProjectKey: jiraMetadata.JIRAProjectKey, Description: event.Message, Summary: "TestTask by Lambda", Issuetype: jiraMetadata.JIRAIssueType, Assigner: jiraMetadata.JIRAAssigner, Reporter: jiraMetadata.JIRAReporter, }) fmt.Printf("created jira issue = %#v\n", res) } } return nil }
作成された課題
TODO • EBクローンするたびに環境名subscription filterの設定する必要がある • ロググループは共通のものを作って、ログストリームを環境名 + InstanceIDにする • Jira
サーバが落ちると何もできない • スケールさせてHA構成にする(LB+Jira DC) • DLQリソース設定 • 失敗時もキューにイベントを貯めるようにする
ご静聴ありがとうございました。