Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
CircleCI_Serverの利用状況を可視化した話 / CircleCI Server Visualization of usage status
dehio3
August 23, 2019
Technology
0
480
CircleCI_Serverの利用状況を可視化した話 / CircleCI Server Visualization of usage status
CircleCI ユーザーコミュニティミートアップ 【LT会】
https://circleci.connpass.com/event/140666/
dehio3
August 23, 2019
Tweet
Share
More Decks by dehio3
See All by dehio3
AWSソリューションを活用して 1ヶ月で動画配信機能をリリースした話 / The story of releasing the Video distribution service in one month using AWS solutions
tomohide_tanaka
1
1k
GitHub Actionsで Terraformをplan&applyしてみた / I tried to plan and apply Terraform with GitHub Actions
tomohide_tanaka
5
3.4k
CircleCI Server運用のポイント / Point of CirlceCI Server operation
tomohide_tanaka
1
400
Other Decks in Technology
See All in Technology
PUTとPOSTどっち使う?
hankehly
0
280
Apa itu DevOps & Kenapa perlu belajar DevOps?
dicodingevent
0
120
機械学習システムのアーキテクチャとデザインパターン
washizaki
1
680
JAWS-UG re:Habilitaion 報告 / JAWS-UG OITA rehabilitation
hiranofumio
0
130
Meet passkeys
satotakeshi
1
130
QiitaConference2022
fuwasegu
0
200
Security Hub のマルチアカウント 管理・運用をサーバレスでやってみる
ch6noota
0
940
Camp Digital 2022: tailored advice
kyliehavelock
0
150
ノーコードで Stripeを使いこなす3つの方法 / jp-stripes-online-vol-4
stripehideokamoto
0
320
現状のFedCMの動作解説と OIDCとの親和性について- OpenID TechNight vol.19
ritou
2
460
GeoLocationAnchor and MKTileOverlay
toyship
0
110
プログラマがオブジェクト指向しても幸せになれない理由
shirayanagiryuji
0
160
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
63
7.6k
Facilitating Awesome Meetings
lara
29
4k
Stop Working from a Prison Cell
hatefulcrawdad
261
17k
Producing Creativity
orderedlist
PRO
334
37k
Gamification - CAS2011
davidbonilla
75
3.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
12
930
BBQ
matthewcrist
74
7.9k
What's new in Ruby 2.0
geeforr
336
30k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
212
20k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
5
510
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
269
11k
KATA
mclloyd
7
8.7k
Transcript
CircleCI Serverの 利用状況を可視化した話 CircleCI ユーザーコミュニティミートアップ #6
自己紹介 Tanaka Tomohide • twitter: @dehio3 • blog:https://www.dehio3.com/ • 音響屋→インフラエンジニア
• CircleCI運用歴:10ヶ月 2
はじめに 3
注意 Workflow、OrbsなどCircle機能の話は 一切出ません!! (そもそもオンプレはOrbs対応してない) 4
CircleCI Serverの 利用状況を可視化した話
CircleCI Serverとは • オンプレミス版のCircleCI • AWS上で利用可能 • 構築用のTerraformが提供 ◦ https://github.com/circleci/enterprise-setup
6
可視化の背景 7
顧客からこんな依頼が 「チーム毎での利用比率を取れない?」 8
なぜ? • ライセンス費は年払い • ユーザー数分ライセンス費がかかる • 利用してるチーム毎に予算を振り分けたい 9
こんなものを作った 10
CircleCIコスト按分ダッシュボード 11
構成 12
lambda + S3 + Athena + Redash 13
ポイント • APIを利用し日次でビルド情報を収集 • AthenaでJSONデータをテーブル化 • Redashにてテーブルデータを可視化 14
ポイント • APIを利用し日次でビルド情報を収集 • AthenaでJSONデータをテーブル化 • Redashにてテーブルデータを可視化 15
APIの選択 / resent-builds API実行時から指定のビルド情報を取得 16
https://circleci.com/docs/api/#recent-builds-across-all-projects
APIの選択 / limitパラメータ • マニュアルでは「Maixmum 100」とあるがオンプレ は制限なし? • limitを大きめの5000にして、取りこぼしのないよう にビルド情報を取得
17
ビルド日時の判断 • ビルド情報を集計する時に日付の判断が必要 • 「queued_at」からビルドの実施日を判断 • 実施日毎でJSONファイルを作成 "queued_at" : "2013-02-12T21:33:30Z"
// time build was queued "start_time" : "2013-02-12T21:33:38Z", // time build started "stop_time" : "2013-02-12T21:34:01Z", // time build finished 18
JSONファイルの管理 作成したJSONファイルはS3で管理 19
ポイント • APIを利用し日次でビルド情報を収集 • AthenaでJSONデータをテーブル化 • Redashにてテーブルデータを可視化 20
JSON用ライブラリでのテーブル作成 CREATE EXTERNAL TABLE circleci_buids_data ( username string, // GitHubのorganization
build_url string, status string, // ビルドのステータス queued_at timestamp, start_time timestamp, stop_time timestamp, build_time_millis int // ビルド走行時間 ) ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe' LOCATION 's3://<バケット名>/' 21
そのままテーブルを参照するとエラー 日付の取得でERRORが発生する Error running query: HIVE_BAD_DATA: Error parsing field value
'2019-04-11T14:45:00.417Z' for field 3: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff] 22
テーブル作成時はstring型 ”Athena は、Java の TIMESTAMP 形式「YYYY-MM-DD HH:MM:SS.fffffffff」 (小数点以下 9 桁)
を必要とします。 データが必須の TIMESTAMP 形式でない場合は、列を STRING として定義し、次に Presto の日付と時刻の関数を使用してフィー ルドを DATE または TIMESTAMP としてクエリ内に読み取りま す。” https://aws.amazon.com/jp/premiumsupport/knowledge-center/query-table-athena- timestamp-empty/ 23
最終的なテーブル作成クエリ CREATE EXTERNAL TABLE circleci_buids_data ( username string, // GitHubのorganization
build_url string, status string, // ビルドのステータス queued_at string, start_time string, stop_time string, build_time_millis int // ビルド走行時間 ) ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe' LOCATION 's3://<バケット名>/' 24
ポイント • APIを利用し日次でビルド情報を収集 • AthenaでJSONデータをテーブル化 • Redashにてテーブルデータを可視化 25
string型をtimestamp型に変換 “注意: データが ISO 8601 形式である場合は、操作を進める前に from_iso8601_timestamp() 関数を使用してデータを TIMESTAMP に変換してください。”
https://aws.amazon.com/jp/premiumsupport/knowledge-center/query-table-athena- timestamp-empty/ 26
string型をtimestamp型に変換 from_iso8601_timestamp関数を使用して、参照時にtimestamp型に 変換 SELECT queued_at, typeof(queued_at) as "type", from_iso8601_timestamp(queued_at) as
"queued_at timestamp", typeof(from_iso8601_timestamp(queued_at)) as "type" FROM circleci_buids_data; 27
Redash上でのクエリ 28 https://github.com/kakakakakku/redash-hands-on
CircleCIコスト按分ダッシュボード 29
こんなデータも可視化 30
日毎のOrganization別ビルド数 31
曜日別、時間帯別ビルド数 32
ビルドステータス推移(success以外) 33
まとめ 34
まとめ 35 • APIを使って簡単にビルド情報が取れる • AthenaとBIツールでJSONデータを簡単に可視化 できる • ビルド状況の可視化する事で、チームの活動状 況を把握する事ができる
Thank you!! 36